From c50a12df103df41d4cbc86fd925db32fd348f5a7 Mon Sep 17 00:00:00 2001 From: s1gr1d <32902192+s1gr1d@users.noreply.github.com> Date: Mon, 24 Aug 2026 14:34:17 +0200 Subject: [PATCH] test(bun): Fix integration test on Bun 1.4.0 --- packages/bun/test/integrations/bunHttpServer.test.ts | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/packages/bun/test/integrations/bunHttpServer.test.ts b/packages/bun/test/integrations/bunHttpServer.test.ts index 07157b9dd12a..e959be856a2a 100644 --- a/packages/bun/test/integrations/bunHttpServer.test.ts +++ b/packages/bun/test/integrations/bunHttpServer.test.ts @@ -60,13 +60,15 @@ describe('Bun HTTP Server Integration', () => { let span: ReturnType | undefined; const { port, close } = await startServer((req, res) => { + // Read the span synchronously: once a request body is streamed, the 'data'/'end' events fire + // outside the handler's async context, so `getActiveSpan()` is empty there. This is how Node + // behaves too; Bun < 1.4 was more lenient, which is why reading it in 'end' used to work. + const activeSpan = getActiveSpan(); + span = activeSpan ? spanToJSON(activeSpan) : undefined; + const chunks: Buffer[] = []; req.on('data', chunk => chunks.push(chunk)); - req.on('end', () => { - const activeSpan = getActiveSpan(); - span = activeSpan ? spanToJSON(activeSpan) : undefined; - res.end(Buffer.concat(chunks)); - }); + req.on('end', () => res.end(Buffer.concat(chunks))); }); const response = await fetch(`http://localhost:${port}/search`, {