Skip to content

Commit 628c646

Browse files
committed
Flush direct streams in Bun
1 parent 9defcd5 commit 628c646

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

packages/react-server/src/ReactServerStreamConfigBun.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ type BunReadableStreamController = ReadableStreamController & {
1313
end(): mixed,
1414
write(data: Chunk | BinaryChunk): void,
1515
error(error: Error): void,
16+
flush?: () => void,
1617
};
1718
export type Destination = BunReadableStreamController;
1819

@@ -25,8 +26,12 @@ export function scheduleWork(callback: () => void) {
2526
}
2627

2728
export function flushBuffered(destination: Destination) {
28-
// WHATWG Streams do not yet have a way to flush the underlying
29-
// transform streams. https://github.com/whatwg/streams/issues/960
29+
// Bun direct streams provide a flush function.
30+
// If we don't have any more data to send right now.
31+
// Flush whatever is in the buffer to the wire.
32+
if (typeof destination.flush === 'function') {
33+
destination.flush();
34+
}
3035
}
3136

3237
export function beginWriting(destination: Destination) {}

0 commit comments

Comments
 (0)