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 6ba8e35 commit 91b409f
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 @@ -443,5 +443,7 @@
"455": "This CacheSignal was requested outside React which means that it is immediately aborted.",
"456": "Calling Offscreen.detach before instance handle has been set.",
"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."
"458": "Currently React only supports one RSC renderer at a time.",
"459": "ReactDOMServer.renderToNodeStream(): The Node Stream API is not available in Bun. Use ReactDOMServer.renderToReadableStream() instead.",
"460": "ReactDOMServer.renderToStaticNodeStream(): The Node Stream API is not available in Bun. Use ReactDOMServer.renderToReadableStream() instead."
}

0 comments on commit 91b409f

Please sign in to comment.