perf(utils): guard useStreamJSON lifecycle#554
Closed
JustYannicc wants to merge 1 commit into
Closed
Conversation
Collaborator
Author
|
Superseded by #555, which now includes the scoped useStreamJSON lifecycle fix, focused harness, and updated performance/test evidence. |
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.
What changed
useStreamJSONso stale fetches cannot writedata,error,isLoading, or invoke callbacks after a newer run starts.RequestInit.signalwithout aborting the caller-owned signal.scripts/test-use-stream-json-lifecycle.mjshook harness.Why
useStreamJSONcould start an initial request and then another request viarevalidate(). If the older request settled later, it could overwrite the newer result or fire staleonData/onErrorcallbacks. It could also settle after unmount and attempt state updates.Compatibility impact
The public return shape and options are preserved. Existing caller
signalvalues are still observed by the fetch request; lifecycle cancellation now uses a composed signal so SuperCmd can abort stale work without mutating caller-owned controllers.How tested
node --test scripts/test-use-stream-json-lifecycle.mjsfailed before the hook change, showing stale data overwriting latest data, stale errors surfacing, missing unmount abort cleanup, and missing lifecycle signal composition.node --test scripts/test-use-stream-json-lifecycle.mjspasses.use-stream-json.tsreports no TypeScript diagnostics.git diff --check HEAD~1..HEADpasses../node_modules/.bin/tsc -p tsconfig.renderer.json --noEmit --pretty falseis blocked on the cleanorigin/mainbase by existing unrelated renderer errors outside this patch.Stack validation
This PR branch was created from
origin/mainand cherry-picked only the scoped fix fromcodex/perf-stream-json-lifecycle, so it does not include or depend on the performance integration stack.