Skip to content

Commit da3f9b3

Browse files
committed
fix(compiler): propagate suspensions from catch-only @Try in SSR
A catch-only @Try (with @catch but no @pending) should behave like ErrorBoundary on the server: suspensions propagate to the nearest Suspense boundary rather than registering as a stream boundary. Without this, a catch-only @Try that suspends creates a pending stream entry, and a later rejection is silently recovered instead of failing the stream as the contract requires.
1 parent 338fbb4 commit da3f9b3

1 file changed

Lines changed: 9 additions & 3 deletions

File tree

‎packages/octane/src/compiler/compile.js‎

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16638,25 +16638,31 @@ function ssrEmitTry(node, ctx, name, inlinedSubs, parentNs, cssHash, componentNs
1663816638
// boundary registration + `<template data-oct-b>` sentinel). As React's server
1663916639
// never runs an error boundary, the @catch arm is client-only: any other
1664016640
// thrown error marks a @pending boundary for a client render, or rethrows.
16641+
// A catch-only boundary (handler but no @pending) propagates suspensions
16642+
// exactly like ErrorBoundary, so it never registers as a stream boundary
16643+
// whose later rejection would be silently recovered.
1664116644
// Output is byte-identical to the old inline try/catch emit for buffered
1664216645
// renders (hydration compatibility).
1664316646
// `siteKey` is a stable source-position hash so a boundary keeps its identity
1664416647
// across streaming passes (the runtime adds the frame path per instance).
16648+
const catchOnly =
16649+
node.handler && !node.propagateSuspense && pendFn.type === 'Literal' && pendFn.value === null;
16650+
const propagateSuspense = node.propagateSuspense === true || catchOnly;
1664516651
const trailing = [];
1664616652
// A presentation-binding view names its @try region on the boundary's own
1664716653
// range; the arm suffix is appended by ssrTry once it knows what it rendered.
1664816654
const bindingSite = node._octaneBindingSite
1664916655
? inheritOriginLoc(b.literal(bindingMarker(node._octaneBindingSite, 'y')), node)
1665016656
: null;
16651-
if (componentNs !== null || node.propagateSuspense === true || bindingSite !== null) {
16657+
if (componentNs !== null || propagateSuspense || bindingSite !== null) {
1665216658
trailing.push(
1665316659
componentNs === null
1665416660
? inheritOriginLoc(b.id('undefined'), node)
1665516661
: inheritOriginLoc(b.literal(componentNs, JSON.stringify(componentNs)), node),
1665616662
);
1665716663
}
16658-
if (node.propagateSuspense === true || bindingSite !== null) {
16659-
trailing.push(inheritOriginLoc(b.literal(node.propagateSuspense === true), node));
16664+
if (propagateSuspense || bindingSite !== null) {
16665+
trailing.push(inheritOriginLoc(b.literal(propagateSuspense), node));
1666016666
}
1666116667
if (bindingSite !== null) trailing.push(bindingSite);
1666216668
return ssrCall(

0 commit comments

Comments
 (0)