Repository navigation
Stop the Recovery and Reuse modelizers throwing without core data - #129
Open
ZayanKhan-12 wants to merge 1 commit into
Open
ZayanKhan-12 wants to merge 1 commit into
ZayanKhan-12 wants to merge 1 commit into
Conversation
Both blocks index straight into arrays that are empty with the data the site currently receives, and reading through the missing element throws. The page is rendered at build time, so each of these fails the whole build rather than one section, which is why neither block can be re-enabled in Root.tsx. The Launch Library transformer reports every launch with `landing: null` and `fairings.recoveryAttempt: false`, and supplies no cores at all, so all four of these are hit on every build: - landingHistory chart: no landing attempts, so `landingAttempts[0].launch` threw while working out the year range. - fairingsRecovery chart: no recovery attempts, same pattern. - Reuse modelizer: no cores, so `mostLaunchedCore.serial` threw. - getQuickestReuseTurnaround: declared as returning Turnaround, but returned undefined when no core had flown twice. The charts now use an empty year range, which the rest of their code already handles, and the two Reuse lookups fall back to a placeholder. Verified by running both modelizers directly. With real data they still report the same numbers: fairings recovery charts the right years with successes and failures split correctly, reflownFairingsCount counts reflown fairings, and the most-reflown core and quickest turnaround are unchanged. With the current data, and with no past launches at all, they return placeholders instead of throwing. Refs r-spacex#73 Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
ZayanKhan-12
pushed a commit
to ZayanKhan-12/spacexstats-react
that referenced
this pull request
Sep 17, 2026
…no-core-data Stop the Recovery and Reuse modelizers throwing without core data (refs r-spacex#73) Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Refs #73.
@MarkusPiotrowski asked for more detail on fairings — which ones reflew, and how they were recovered. Most of that is already written.
Recoveryhas a fairings recovery chart splitting attempts into successes and failures per year, andReusereportsreflownFairingsCount. Both blocks are commented out inRoot.tsx, alongside recovery, reuse, starlink, dragon and people, after the r/spacex API shutdown the site banner mentions.This PR does not turn them back on, but it removes the reason they cannot be.
The bug
Both modelizers index straight into arrays that are empty with the data the site currently receives, and reading through the missing element throws. Since the page is rendered at build time, each of these fails the whole build, not one section.
The Launch Library transformer reports every launch with
landing: nullandfairings.recoveryAttempt: false, and supplies no cores at all, so all four are hit on every build:landingHistory.tslandingAttempts[0].launchfairingsRecovery.tsrecoveryAttempts[0]Reuse/modelizer.tsmostLaunchedCore.serialgetQuickestReuseTurnaroundundefinedwhile declaredTurnaroundRunning the two modelizers against a launch shaped the way the transformer produces them:
The charts now use an empty year range, which the rest of their code already handles, and the two
Reuselookups fall back to a placeholder.This is the same shape of fix as #128, which I opened for the
Payloadsblock after #120; these are the remaining blocks with the same problem.Verified the working path is unchanged
Degrading is only worth anything if the numbers are still right when data exists. Running both modelizers over launches with real fairing, landing and core data:
Each of the four guards is load-bearing: reverting any one of them individually puts two of the four cases back to throwing.
What this does not fix, and what #73 really needs
Worth stating plainly, because the fairings stats will read as zero even once the blocks are enabled: Launch Library 2 carries no fairing data at all. I checked the API rather than assuming — a launch fetched with
mode=detailedhasrocket.launcher_stagecovering the booster (reused,landing,previous_flight,turn_around_time_days) and nothing about fairings anywhere. The transformer hard-codesfairings: { reused: false, recoveryAttempt: false, recovered: false }for every launch as a result.Also worth noting for the issue itself: the "scooped from the water or caught by the net" distinction was never modelled, even under the old API.
FairingsLaunchis only{ recoveryAttempt, recovered, reused }— there is no ship or catch-method field to render. That part is a new data requirement, not a disabled feature.Separately: a units bug I found but did not fix
formatDurationtakes seconds, butReuse/modelizer.tspasses a millisecond difference of two dates, so the quickest turnaround renders as365000 daysfor what should be 365 days.Dragon'scommercialCrewFlights.tshas the mirror problem, passing hours.I left both alone. Fixing them properly means deciding what unit
formatDurationshould take and auditing every caller, which is a wider change than this one and not something I can check visually with the blocks disabled. Happy to do it separately if you would like.Checks
Per
CLAUDE.md,masterdoes not typecheck clean, so I compared rather than assumed:masternpx tsc --noEmitnpx eslinton changed filesI used
npx eslintrather thanyarn test:lint, which iseslint --fixand rewrites files. I did not rungatsby build:.nvmrcpins Node 16 and I had 18, and these blocks are disabled so a build would not execute this code. They are pure functions, which is why exercising them directly is a meaningful check.CLAUDE.mdis in my other open PR (#126) and is not duplicated here.