Skip to content

Commit 11cbbe5

Browse files
committed
handling null-body-status response gracefully
1 parent e5ee428 commit 11cbbe5

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

  • experimental/packages/opentelemetry-instrumentation-fetch/src

experimental/packages/opentelemetry-instrumentation-fetch/src/fetch.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -507,8 +507,14 @@ export class FetchInstrumentation extends InstrumentationBase<FetchInstrumentati
507507
const body = resClone.body;
508508
if (body) {
509509
const reader = body.getReader();
510-
511-
const wrappedBody = withCancelPropagation(response.body, reader);
510+
const isNullBodyStatus =
511+
response.status === 101 ||
512+
response.status === 204 ||
513+
response.status === 205 ||
514+
response.status === 304;
515+
const wrappedBody = isNullBodyStatus
516+
? null
517+
: withCancelPropagation(response.body, reader);
512518

513519
proxiedResponse = new Response(wrappedBody, {
514520
status: response.status,

0 commit comments

Comments
 (0)