Skip to content

test: cover Suspense retries in React streaming SSR#17

Merged
aose-yuu merged 4 commits into
mainfrom
codex/react-ssr-contracts
Apr 17, 2026
Merged

test: cover Suspense retries in React streaming SSR#17
aose-yuu merged 4 commits into
mainfrom
codex/react-ssr-contracts

Conversation

@aose-yuu
Copy link
Copy Markdown
Contributor

@aose-yuu aose-yuu commented Apr 17, 2026

Purpose

Extend the React adapter SSR test coverage so streaming Suspense retries cannot regress molecule cleanup behavior.

Summary

  • Add streaming SSR Suspense retry coverage for useMolecule using a React.use()-based test fixture.
  • Verify renderToPipeableStream keeps suspended molecules undisposed at shell time and disposes every server-created instance after retries finish.
  • Verify renderToReadableStream also disposes every retry-created molecule instance and keeps mount-time work disabled on the server.
  • Leave the runtime and public API unchanged, and treat this as a test-only guardrail update.

Verification

  • pnpm test packages/__tests__/useMolecule.ssr.test.tsx
  • pnpm test
  • pnpm typecheck
  • pnpm build
  • mise run ci

@aose-yuu aose-yuu marked this pull request as ready for review April 17, 2026 08:42
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: bb342110ed

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread packages/useMolecule.ts
Comment on lines +95 to +99
if (isServerEnvironment) {
const token = Symbol("pending-server-dispose");
nextState.pendingDisposeToken = token;
schedulePendingDispose(stateRef, nextState.instance, token);
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Delay server disposal until render completion

useMolecule now schedules disposal as soon as the hook creates a server-side instance, but in streaming SSR (renderToPipeableStream / renderToReadableStream) a component can suspend and be retried later in the same request. In that case this microtask can run before the retry, so onDispose fires mid-render and the molecule is recreated on resume, which can duplicate teardown/setup side effects and break code that expects disposal only after the full server render finishes. This is introduced by scheduling from render-time rather than from a stream completion signal.

Useful? React with 👍 / 👎.

@aose-yuu aose-yuu merged commit 9ff97d3 into main Apr 17, 2026
1 check passed
@aose-yuu aose-yuu deleted the codex/react-ssr-contracts branch April 17, 2026 08:58
@aose-yuu aose-yuu changed the title fix: tighten React adapter signal and SSR contracts test: cover Suspense retries in React streaming SSR Apr 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant