Skip to content

Commit

Permalink
Add error codes, export renderToNodeStream/renderToStaticNodeStream
Browse files Browse the repository at this point in the history
  • Loading branch information
Colin McDonnell committed Nov 3, 2022
1 parent e6c39fd commit d7078c6
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 7 deletions.
14 changes: 14 additions & 0 deletions packages/react-dom/server.bun.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,17 @@ export function renderToReadableStream() {
arguments,
);
}

export function renderToNodeStream() {
throw new Error(
'ReactDOMServer.renderToNodeStream(): The Node Stream API is not available ' +
'in Bun. Use ReactDOMServer.renderToReadableStream() instead.',
);
}

export function renderToStaticNodeStream() {
throw new Error(
'ReactDOMServer.renderToStaticNodeStream(): The Node Stream API is not available ' +
'in Bun. Use ReactDOMServer.renderToReadableStream() instead.',
);
}
7 changes: 1 addition & 6 deletions packages/react-server/src/ReactServerStreamConfigBun.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,7 @@ export function flushBuffered(destination: Destination) {
// transform streams. https://github.com/whatwg/streams/issues/960
}

// For now we support AsyncLocalStorage as a global for the "browser" builds
// TODO: Move this to some special WinterCG build.
// export const supportsRequestStorage = typeof AsyncLocalStorage === 'function';
// export const requestStorage: AsyncLocalStorage<
// Map<Function, mixed>,
// > = supportsRequestStorage ? new AsyncLocalStorage() : (null: any);
// AsyncLocalStorage is not available in bun
export const supportsRequestStorage = false;
export const requestStorage = (null: any);

Expand Down
4 changes: 3 additions & 1 deletion scripts/error-codes/codes.json
Original file line number Diff line number Diff line change
Expand Up @@ -445,5 +445,7 @@
"457": "acquireHeadResource encountered a resource type it did not expect: \"%s\". This is a bug in React.",
"458": "Currently React only supports one RSC renderer at a time.",
"459": "Expected a suspended thenable. This is a bug in React. Please file an issue.",
"460": "Suspense Exception: This is not a real error! It's an implementation detail of `use` to interrupt the current render. You must either rethrow it immediately, or move the `use` call outside of the `try/catch` block. Capturing without rethrowing will lead to unexpected behavior.\n\nTo handle async errors, wrap your component in an error boundary, or call the promise's `.catch` method and pass the result to `use`"
"460": "Suspense Exception: This is not a real error! It's an implementation detail of `use` to interrupt the current render. You must either rethrow it immediately, or move the `use` call outside of the `try/catch` block. Capturing without rethrowing will lead to unexpected behavior.\n\nTo handle async errors, wrap your component in an error boundary, or call the promise's `.catch` method and pass the result to `use`",
"461": "ReactDOMServer.renderToNodeStream(): The Node Stream API is not available in Bun. Use ReactDOMServer.renderToReadableStream() instead.",
"462": "ReactDOMServer.renderToStaticNodeStream(): The Node Stream API is not available in Bun. Use ReactDOMServer.renderToReadableStream() instead."
}

0 comments on commit d7078c6

Please sign in to comment.