Skip to content
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

Flush direct streams in Bun #28837

Merged
merged 1 commit into from
Apr 15, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 7 additions & 2 deletions packages/react-server/src/ReactServerStreamConfigBun.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ type BunReadableStreamController = ReadableStreamController & {
end(): mixed,
write(data: Chunk | BinaryChunk): void,
error(error: Error): void,
flush?: () => void,
};
export type Destination = BunReadableStreamController;

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

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

export function beginWriting(destination: Destination) {}
Expand Down