-
Notifications
You must be signed in to change notification settings - Fork 49.2k
Update bun
's condition of react-dom/server
to have latest normal node
functions
#34193
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Hi @RiskyMH! Thank you for your pull request and welcome to our community. Action RequiredIn order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you. ProcessIn order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA. Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks! |
Comparing: 14c50e3...0a67a33 Critical size changesIncludes critical production bundles, as well as any change greater than 2%: Significant size changesIncludes any change greater than 0.2%: Expand to show
|
export { | ||
renderToPipeableStream, | ||
resumeToPipeableStream, | ||
// $FlowFixMe[cannot-resolve-module] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did try to add it to inlinedHostConfigs.js
, but then I got weird errors that didn't make too much sense to me. If it worked in normal node and the built one included the exports (that are usable correctly), then I can't understand how bun fails when exporting it.
An error
Error ┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈ packages/react-dom/src/server/ReactDOMFizzServerNode.js:50:38
Cannot call startFlowing with destination bound to destination because: [incompatible-call]
• Either stream$Writable [1] is incompatible with ReadableStreamController [2].
• Or MightBeFlushable [3] is incompatible with ReadableStreamController [2].
packages/react-dom/src/server/ReactDOMFizzServerNode.js
47│ ensureCorrectIsomorphicReactVersion();
48│
49│ function createDrainHandler(destination: Destination, request: Request) {
50│ return () => startFlowing(request, destination);
51│ }
52│
53│ function createCancelHandler(request: Request, reason: string) {
packages/react-server/src/ReactServerStreamConfigBun.js
[2] 12│ type BunReadableStreamController = ReadableStreamController & {
packages/react-server/src/ReactServerStreamConfigNode.js
[1][3] 19│ export type Destination = Writable & MightBeFlushable;
Error ┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈ packages/react-dom/src/server/ReactDOMFizzServerNode.js:50:38
Cannot call startFlowing with destination bound to destination because: [incompatible-call]
• Either inexact stream$Writable [1] is incompatible with exact object type [2].
• Or inexact MightBeFlushable [3] is incompatible with exact object type [2].
packages/react-dom/src/server/ReactDOMFizzServerNode.js
47│ ensureCorrectIsomorphicReactVersion();
48│
49│ function createDrainHandler(destination: Destination, request: Request) {
50│ return () => startFlowing(request, destination);
51│ }
52│
53│ function createCancelHandler(request: Request, reason: string) {
packages/react-server/src/ReactServerStreamConfigBun.js
[2] 12│ type BunReadableStreamController = ReadableStreamController & {
13│ end(): mixed,
14│ write(data: Chunk | BinaryChunk): void,
15│ error(error: Error): void,
16│ flush?: () => void,
17│ };
packages/react-server/src/ReactServerStreamConfigNode.js
[1][3] 19│ export type Destination = Writable & MightBeFlushable;
Error ┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈ packages/react-dom/src/server/ReactDOMFizzServerNode.js:151:29
Cannot call startFlowing with destination bound to destination because stream$Writable [1] is incompatible with
ReadableStreamController [2]. [incompatible-call]
packages/react-dom/src/server/ReactDOMFizzServerNode.js
[1] 143│ pipe<T: Writable>(destination: T): T {
:
148│ }
149│ hasStartedFlowing = true;
150│ prepareForStartFlowingIfBeforeAllReady(request);
151│ startFlowing(request, destination);
152│ destination.on('drain', createDrainHandler(destination, request));
153│ destination.on(
154│ 'error',
packages/react-server/src/ReactServerStreamConfigBun.js
[2] 12│ type BunReadableStreamController = ReadableStreamController & {
Error ┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈ packages/react-dom/src/server/ReactDOMFizzServerNode.js:151:29
Cannot call startFlowing with destination bound to destination because inexact stream$Writable [1] is incompatible with
exact object type [2]. [incompatible-exact]
packages/react-dom/src/server/ReactDOMFizzServerNode.js
[1] 143│ pipe<T: Writable>(destination: T): T {
:
148│ }
149│ hasStartedFlowing = true;
150│ prepareForStartFlowingIfBeforeAllReady(request);
151│ startFlowing(request, destination);
152│ destination.on('drain', createDrainHandler(destination, request));
153│ destination.on(
154│ 'error',
packages/react-server/src/ReactServerStreamConfigBun.js
[2] 12│ type BunReadableStreamController = ReadableStreamController & {
13│ end(): mixed,
14│ write(data: Chunk | BinaryChunk): void,
15│ error(error: Error): void,
16│ flush?: () => void,
17│ };
Error ┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈ packages/react-dom/src/server/ReactDOMFizzServerNode.js:233:35
Cannot call startFlowing with writable bound to destination because stream$Writable [1] is incompatible with
ReadableStreamController [2]. [incompatible-call]
packages/react-dom/src/server/ReactDOMFizzServerNode.js
[1] 224│ let writable: Writable;
:
230│ createFakeWritableFromReadableStreamController(controller);
231│ },
232│ pull: (controller): ?Promise<void> => {
233│ startFlowing(request, writable);
234│ },
235│ cancel: (reason): ?Promise<void> => {
236│ stopFlowing(request);
packages/react-server/src/ReactServerStreamConfigBun.js
[2] 12│ type BunReadableStreamController = ReadableStreamController & {
Error ┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈ packages/react-dom/src/server/ReactDOMFizzServerNode.js:233:35
Cannot call startFlowing with writable bound to destination because inexact stream$Writable [1] is incompatible with
exact object type [2]. [incompatible-exact]
packages/react-dom/src/server/ReactDOMFizzServerNode.js
[1] 224│ let writable: Writable;
:
230│ createFakeWritableFromReadableStreamController(controller);
231│ },
232│ pull: (controller): ?Promise<void> => {
233│ startFlowing(request, writable);
234│ },
235│ cancel: (reason): ?Promise<void> => {
236│ stopFlowing(request);
packages/react-server/src/ReactServerStreamConfigBun.js
[2] 12│ type BunReadableStreamController = ReadableStreamController & {
13│ end(): mixed,
14│ write(data: Chunk | BinaryChunk): void,
15│ error(error: Error): void,
16│ flush?: () => void,
17│ };
Error ┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈ packages/react-dom/src/server/ReactDOMFizzServerNode.js:344:29
Cannot call startFlowing with destination bound to destination because stream$Writable [1] is incompatible with
ReadableStreamController [2]. [incompatible-call]
packages/react-dom/src/server/ReactDOMFizzServerNode.js
[1] 337│ pipe<T: Writable>(destination: T): T {
338│ if (hasStartedFlowing) {
339│ throw new Error(
340│ 'React currently only supports piping to one writable stream.',
341│ );
342│ }
343│ hasStartedFlowing = true;
344│ startFlowing(request, destination);
345│ destination.on('drain', createDrainHandler(destination, request));
346│ destination.on(
347│ 'error',
packages/react-server/src/ReactServerStreamConfigBun.js
[2] 12│ type BunReadableStreamController = ReadableStreamController & {
Error ┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈ packages/react-dom/src/server/ReactDOMFizzServerNode.js:344:29
Cannot call startFlowing with destination bound to destination because inexact stream$Writable [1] is incompatible with
exact object type [2]. [incompatible-exact]
packages/react-dom/src/server/ReactDOMFizzServerNode.js
[1] 337│ pipe<T: Writable>(destination: T): T {
338│ if (hasStartedFlowing) {
339│ throw new Error(
340│ 'React currently only supports piping to one writable stream.',
341│ );
342│ }
343│ hasStartedFlowing = true;
344│ startFlowing(request, destination);
345│ destination.on('drain', createDrainHandler(destination, request));
346│ destination.on(
347│ 'error',
packages/react-server/src/ReactServerStreamConfigBun.js
[2] 12│ type BunReadableStreamController = ReadableStreamController & {
13│ end(): mixed,
14│ write(data: Chunk | BinaryChunk): void,
15│ error(error: Error): void,
16│ flush?: () => void,
17│ };
Error ┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈ packages/react-dom/src/server/ReactDOMFizzServerNode.js:393:35
Cannot call startFlowing with writable bound to destination because stream$Writable [1] is incompatible with
ReadableStreamController [2]. [incompatible-call]
packages/react-dom/src/server/ReactDOMFizzServerNode.js
[1] 384│ let writable: Writable;
:
390│ createFakeWritableFromReadableStreamController(controller);
391│ },
392│ pull: (controller): ?Promise<void> => {
393│ startFlowing(request, writable);
394│ },
395│ cancel: (reason): ?Promise<void> => {
396│ stopFlowing(request);
packages/react-server/src/ReactServerStreamConfigBun.js
[2] 12│ type BunReadableStreamController = ReadableStreamController & {
Error ┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈ packages/react-dom/src/server/ReactDOMFizzServerNode.js:393:35
Cannot call startFlowing with writable bound to destination because inexact stream$Writable [1] is incompatible with
exact object type [2]. [incompatible-exact]
packages/react-dom/src/server/ReactDOMFizzServerNode.js
[1] 384│ let writable: Writable;
:
390│ createFakeWritableFromReadableStreamController(controller);
391│ },
392│ pull: (controller): ?Promise<void> => {
393│ startFlowing(request, writable);
394│ },
395│ cancel: (reason): ?Promise<void> => {
396│ stopFlowing(request);
packages/react-server/src/ReactServerStreamConfigBun.js
[2] 12│ type BunReadableStreamController = ReadableStreamController & {
13│ end(): mixed,
14│ write(data: Chunk | BinaryChunk): void,
15│ error(error: Error): void,
16│ flush?: () => void,
17│ };
Found 10 errors
Flow failed for the dom-bun renderer
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The type errors don't seem surprising to me considering you're using Node interfaces with Bun's implementation. These don't necessarily match.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, so you're saying I should update those types to make it work and not error anywhere? I just didn't want to do a refactor in case it broke other stuff. I kind of thought it was already consistent tbh, but maybe more consistency is better to do!
From my testing, I believe the actual code itself works which is good I think.
Summary
fixes remix-run/react-router#12568
The custom bun export condition seems to be missing some of the newer apis that normal node one has, so this PR adds the missing exports so that users of bun don't have errors.
How did you test this change?
used the built output and verified the functions are now present in the bun bundles