Skip to content

Commit f7e6b65

Browse files
authored
fix: bugbot
1 parent 523331b commit f7e6b65

1 file changed

Lines changed: 9 additions & 2 deletions

File tree

‎packages/deno/test/streaming.test.ts‎

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,14 @@ Deno.test('calls onEnd before ending the span for a non-streamed response', asyn
9696

9797
Deno.test('calls onEnd before ending the span when a streamed response finishes', async () => {
9898
const calls: string[] = [];
99-
const span = { end: () => calls.push('end') } as unknown as Parameters<typeof streamResponse>[0];
99+
let resolveEnded: () => void;
100+
const ended = new Promise<void>(resolve => (resolveEnded = resolve));
101+
const span = {
102+
end: () => {
103+
calls.push('end');
104+
resolveEnded();
105+
},
106+
} as unknown as Parameters<typeof streamResponse>[0];
100107

101108
let sourceController: ReadableStreamDefaultController<Uint8Array> | undefined;
102109
const source = new ReadableStream<Uint8Array>({
@@ -115,6 +122,6 @@ Deno.test('calls onEnd before ending the span when a streamed response finishes'
115122
assertEquals(calls, []);
116123
sourceController!.close();
117124
assertEquals(await response.text(), 'chunk');
118-
await new Promise(resolve => setTimeout(resolve, 0));
125+
await ended;
119126
assertEquals(calls, ['onEnd', 'end']);
120127
});

0 commit comments

Comments
 (0)