Skip to content

Conversation

RiskyMH
Copy link

@RiskyMH RiskyMH commented Aug 13, 2025

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

Copy link

meta-cla bot commented Aug 13, 2025

Hi @RiskyMH!

Thank you for your pull request and welcome to our community.

Action Required

In 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.

Process

In 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 CLA signed. The tagging process may take up to 1 hour after signing. Please give it that time before contacting us about it.

If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks!

@meta-cla meta-cla bot added the CLA Signed label Aug 13, 2025
@react-sizebot
Copy link

react-sizebot commented Aug 13, 2025

Comparing: 14c50e3...0a67a33

Critical size changes

Includes critical production bundles, as well as any change greater than 2%:

Name +/- Base Current +/- gzip Base gzip Current gzip
oss-stable/react-dom/cjs/react-dom.production.js = 6.68 kB 6.68 kB = 1.83 kB 1.83 kB
oss-stable/react-dom/cjs/react-dom-client.production.js = 530.18 kB 530.18 kB = 93.39 kB 93.39 kB
oss-experimental/react-dom/cjs/react-dom.production.js = 6.69 kB 6.69 kB = 1.83 kB 1.83 kB
oss-experimental/react-dom/cjs/react-dom-client.production.js = 654.55 kB 654.55 kB = 115.11 kB 115.11 kB
facebook-www/ReactDOM-prod.classic.js = 674.32 kB 674.32 kB = 118.29 kB 118.29 kB
facebook-www/ReactDOM-prod.modern.js = 664.74 kB 664.74 kB = 116.65 kB 116.65 kB
oss-experimental/react-dom/server.bun.js +26.60% 0.58 kB 0.73 kB +7.36% 0.26 kB 0.28 kB
oss-stable-semver/react-dom/server.bun.js +26.60% 0.58 kB 0.73 kB +7.36% 0.26 kB 0.28 kB
oss-stable/react-dom/server.bun.js +26.60% 0.58 kB 0.73 kB +7.36% 0.26 kB 0.28 kB
oss-experimental/react-dom/cjs/react-dom-server.bun.production.js +5.98% 275.49 kB 291.97 kB +3.47% 49.37 kB 51.08 kB
oss-experimental/react-dom/cjs/react-dom-server.bun.development.js +4.31% 384.05 kB 400.62 kB +2.24% 73.54 kB 75.19 kB
oss-stable-semver/react-dom/cjs/react-dom-server.bun.production.js +3.41% 240.93 kB 249.14 kB +2.02% 43.95 kB 44.83 kB
oss-stable/react-dom/cjs/react-dom-server.bun.production.js +3.41% 241.00 kB 249.22 kB +2.01% 43.98 kB 44.86 kB
oss-stable-semver/react-dom/cjs/react-dom-server.bun.development.js +2.32% 350.07 kB 358.19 kB +1.30% 67.77 kB 68.65 kB
oss-stable/react-dom/cjs/react-dom-server.bun.development.js +2.32% 350.15 kB 358.27 kB +1.30% 67.80 kB 68.68 kB

Significant size changes

Includes any change greater than 0.2%:

Expand to show
Name +/- Base Current +/- gzip Base gzip Current gzip
oss-experimental/react-dom/server.bun.js +26.60% 0.58 kB 0.73 kB +7.36% 0.26 kB 0.28 kB
oss-stable-semver/react-dom/server.bun.js +26.60% 0.58 kB 0.73 kB +7.36% 0.26 kB 0.28 kB
oss-stable/react-dom/server.bun.js +26.60% 0.58 kB 0.73 kB +7.36% 0.26 kB 0.28 kB
oss-experimental/react-dom/cjs/react-dom-server.bun.production.js +5.98% 275.49 kB 291.97 kB +3.47% 49.37 kB 51.08 kB
oss-experimental/react-dom/cjs/react-dom-server.bun.development.js +4.31% 384.05 kB 400.62 kB +2.24% 73.54 kB 75.19 kB
oss-stable-semver/react-dom/cjs/react-dom-server.bun.production.js +3.41% 240.93 kB 249.14 kB +2.02% 43.95 kB 44.83 kB
oss-stable/react-dom/cjs/react-dom-server.bun.production.js +3.41% 241.00 kB 249.22 kB +2.01% 43.98 kB 44.86 kB
oss-stable-semver/react-dom/cjs/react-dom-server.bun.development.js +2.32% 350.07 kB 358.19 kB +1.30% 67.77 kB 68.65 kB
oss-stable/react-dom/cjs/react-dom-server.bun.development.js +2.32% 350.15 kB 358.27 kB +1.30% 67.80 kB 68.68 kB

Generated by 🚫 dangerJS against 0a67a33

export {
renderToPipeableStream,
resumeToPipeableStream,
// $FlowFixMe[cannot-resolve-module]
Copy link
Author

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

Copy link
Collaborator

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.

Copy link
Author

@RiskyMH RiskyMH Aug 21, 2025

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

renderToPipeableStream export missing in production build when starting production server with Bun
3 participants