Skip to content

Commit

Permalink
try alternative
Browse files Browse the repository at this point in the history
  • Loading branch information
lforst committed Apr 12, 2024
1 parent 5d4d977 commit 298f067
Showing 1 changed file with 5 additions and 20 deletions.
25 changes: 5 additions & 20 deletions packages/utils/src/instrument/fetch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,21 +64,10 @@ function instrumentFetch(): void {
DEBUG_BUILD && logger.warn('Failed to clone response body.');
}

if (clonedResponseForResolving && clonedResponseForResolving.body) {
const responseReader = clonedResponseForResolving.body.getReader();

// eslint-disable-next-line no-inner-declarations
function consumeChunks({ done }: { done: boolean }): Promise<void> {
if (!done) {
return responseReader.read().then(consumeChunks);
} else {
return Promise.resolve();
}
}

responseReader
.read()
.then(consumeChunks)
if (clonedResponseForResolving) {
clonedResponseForResolving
// This waits until the full body has been received
.text()
.then(() => {
triggerHandlers('fetch', {
...handlerData,
Expand All @@ -97,11 +86,7 @@ function instrumentFetch(): void {
});
}

return new Promise(resolve => {
setTimeout(() => {
resolve(response);
}, 0);
});
return response;
},
(error: Error) => {
const erroredHandlerData: HandlerDataFetch = {
Expand Down

0 comments on commit 298f067

Please sign in to comment.