mirror of
https://github.com/oven-sh/bun
synced 2026-02-16 22:01:47 +00:00
await flush
This commit is contained in:
@@ -1260,17 +1260,17 @@ function flushFirstWrite(self) {
|
||||
new Response(
|
||||
new ReadableStream({
|
||||
type: "direct",
|
||||
pull: controller => {
|
||||
pull: async controller => {
|
||||
self[controllerSymbol] = controller;
|
||||
if (firstWrite) {
|
||||
controller.write(firstWrite);
|
||||
controller.flush(); // flush the first write
|
||||
await controller.flush(); // flush the first write
|
||||
}
|
||||
firstWrite = undefined;
|
||||
if (!self[finishedSymbol]) {
|
||||
const { promise, resolve } = $newPromiseCapability(GlobalPromise);
|
||||
self[deferredSymbol] = resolve;
|
||||
return promise;
|
||||
return await promise;
|
||||
}
|
||||
},
|
||||
}),
|
||||
|
||||
@@ -2477,7 +2477,10 @@ it("response body streaming is immediate (#13696)", async () => {
|
||||
// chunks before real-time streaming started working.
|
||||
expect(new Date().getTime() - Number.parseInt(decoder.decode(value).trimEnd(), 10)).toBeLessThan(acceptableDelay);
|
||||
}
|
||||
// Verify that the correct number of chunks were sent (in case server
|
||||
// decides to send no chunks at all).
|
||||
expect(receivedChunks).toEqual(totalChunks);
|
||||
// Also verify the total size in case some data was lost.
|
||||
expect(receivedSize).toEqual(totalSize);
|
||||
} finally {
|
||||
server.close();
|
||||
|
||||
Reference in New Issue
Block a user