Repository navigation
fix(ssr): stop a pending seed reading the registry after a failed render - #47
Merged
Merged
Conversation
Since #39, a RegistryProvider disposes of its registry when the server render ends, failed renders included. A seed's hydratable callback that resumed after that read the disposed registry and rejected with nothing awaiting it, which failed the unit suite on main (scoped.browser.test.ts, two providers of one input). The callback now stops once the render has ended. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
Fixes the unit-test failure on
mainsince #39 landed: an unhandled rejection,Cannot access Atom … scoped-user-a: registry is disposed, which fails thecheckjob on every branch built onmain(including #37).Background: on the server, each serializable atom a component awaits gets a seed: its result, encoded and sent with the page so the browser doesn't fetch it again. Svelte's
hydratablecollects these while the page renders.A failed server render rejects with "registry is disposed"
How it happens: #45 added a test whose server render is meant to fail. Two providers make two different atoms with one serialization key, and the second reader throws. #39 then made a
RegistryProviderdispose of its registry when the render ends, failed renders included. Each passed CI on its own; together they don't.Bug: the first reader's seed callback waits a microtask before reading its atom. By then the second reader has thrown, the render has ended, and the provider has disposed of the registry. The read throws inside a promise that nothing awaits any more, and Vitest fails the run on the unhandled rejection. A real app would hit the same thing on any failed server render with a serializable atom still seeding: the error is logged, but the page fails either way.
Fix: the seed records when the render ends, as
subscribedReaderhas done since #39, and stops before reading the registry once it has. A render that succeeds waits for every seed before it ends, so this only changes failed renders.Test: the existing
scoped.browser.test.ts› "two providers of one input make two different atoms with one key, which fails the server render" covers it: the suite fails onmainand should pass here.🤖 Generated with Claude Code