Skip to content

Commit a86f1f0

Browse files
committed
reset code in cloudflare SDK
1 parent 3ccab0c commit a86f1f0

File tree

2 files changed

+19
-12
lines changed

2 files changed

+19
-12
lines changed

packages/cloudflare/src/request.ts

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -76,18 +76,24 @@ export function wrapRequestHandler(
7676
// Note: This span will not have a duration unless I/O happens in the handler. This is
7777
// because of how the cloudflare workers runtime works.
7878
// See: https://developers.cloudflare.com/workers/runtime-apis/performance/
79-
return startSpan({ name, attributes }, async (span: Span) => {
80-
try {
81-
const res = await handler();
82-
setHttpStatus(span, res.status);
83-
return res;
84-
} catch (e) {
85-
captureException(e, { mechanism: { handled: false, type: 'cloudflare' } });
86-
throw e;
87-
} finally {
88-
context?.waitUntil(flush(2000));
89-
}
90-
});
79+
return startSpan(
80+
{
81+
name,
82+
attributes,
83+
},
84+
async span => {
85+
try {
86+
const res = await handler();
87+
setHttpStatus(span, res.status);
88+
return res;
89+
} catch (e) {
90+
captureException(e, { mechanism: { handled: false, type: 'cloudflare' } });
91+
throw e;
92+
} finally {
93+
context?.waitUntil(flush(2000));
94+
}
95+
},
96+
);
9197
},
9298
);
9399
});

packages/cloudflare/test/request.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,7 @@ describe('withSentry', () => {
220220
trace_id: '12312012123120121231201212312012',
221221
});
222222
});
223+
223224
test('creates a span that wraps request handler', async () => {
224225
const mockRequest = new Request('https://example.com') as any;
225226
mockRequest.cf = {

0 commit comments

Comments
 (0)