Skip to content

Commit d7078c6

Browse files
author
Colin McDonnell
committed
Add error codes, export renderToNodeStream/renderToStaticNodeStream
1 parent e6c39fd commit d7078c6

File tree

3 files changed

+18
-7
lines changed

3 files changed

+18
-7
lines changed

packages/react-dom/server.bun.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,17 @@ export function renderToReadableStream() {
3131
arguments,
3232
);
3333
}
34+
35+
export function renderToNodeStream() {
36+
throw new Error(
37+
'ReactDOMServer.renderToNodeStream(): The Node Stream API is not available ' +
38+
'in Bun. Use ReactDOMServer.renderToReadableStream() instead.',
39+
);
40+
}
41+
42+
export function renderToStaticNodeStream() {
43+
throw new Error(
44+
'ReactDOMServer.renderToStaticNodeStream(): The Node Stream API is not available ' +
45+
'in Bun. Use ReactDOMServer.renderToReadableStream() instead.',
46+
);
47+
}

packages/react-server/src/ReactServerStreamConfigBun.js

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,7 @@ export function flushBuffered(destination: Destination) {
2626
// transform streams. https://github.com/whatwg/streams/issues/960
2727
}
2828

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

scripts/error-codes/codes.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -445,5 +445,7 @@
445445
"457": "acquireHeadResource encountered a resource type it did not expect: \"%s\". This is a bug in React.",
446446
"458": "Currently React only supports one RSC renderer at a time.",
447447
"459": "Expected a suspended thenable. This is a bug in React. Please file an issue.",
448-
"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`"
448+
"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`",
449+
"461": "ReactDOMServer.renderToNodeStream(): The Node Stream API is not available in Bun. Use ReactDOMServer.renderToReadableStream() instead.",
450+
"462": "ReactDOMServer.renderToStaticNodeStream(): The Node Stream API is not available in Bun. Use ReactDOMServer.renderToReadableStream() instead."
449451
}

0 commit comments

Comments
 (0)