Skip to content

Commit 91b409f

Browse files
author
Colin McDonnell
committed
Add error codes, export renderToNodeStream/renderToStaticNodeStream
1 parent 6ba8e35 commit 91b409f

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
@@ -443,5 +443,7 @@
443443
"455": "This CacheSignal was requested outside React which means that it is immediately aborted.",
444444
"456": "Calling Offscreen.detach before instance handle has been set.",
445445
"457": "acquireHeadResource encountered a resource type it did not expect: \"%s\". This is a bug in React.",
446-
"458": "Currently React only supports one RSC renderer at a time."
446+
"458": "Currently React only supports one RSC renderer at a time.",
447+
"459": "ReactDOMServer.renderToNodeStream(): The Node Stream API is not available in Bun. Use ReactDOMServer.renderToReadableStream() instead.",
448+
"460": "ReactDOMServer.renderToStaticNodeStream(): The Node Stream API is not available in Bun. Use ReactDOMServer.renderToReadableStream() instead."
447449
}

0 commit comments

Comments
 (0)