Skip to content

Commit 36fadf0

Browse files
committed
resolve tests
1 parent 2f940d3 commit 36fadf0

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

packages/cloudflare/src/request.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,10 +108,11 @@ export function wrapRequestHandler(
108108
res = await handler();
109109
setHttpStatus(span, res.status);
110110
} catch (e) {
111-
span.end(); // End span on error
111+
span.end();
112112
if (captureErrors) {
113113
captureException(e, { mechanism: { handled: false, type: 'auto.http.cloudflare' } });
114114
}
115+
waitUntil?.(flush(2000));
115116
throw e;
116117
}
117118

packages/cloudflare/test/request.test.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,10 @@ describe('withSentry', () => {
104104

105105
await wrapRequestHandler({ options: MOCK_OPTIONS, request: new Request('https://example.com'), context }, () => {
106106
addDelayedWaitUntil(context);
107-
return new Response('test');
107+
const response = new Response('test');
108+
// Add Content-Length to skip probing
109+
response.headers.set('content-length', '4');
110+
return response;
108111
});
109112
expect(flush).not.toBeCalled();
110113
expect(waitUntil).toBeCalled();

0 commit comments

Comments
 (0)