Skip to content

Commit

Permalink
Selectively copy request to prevent used request error.
Browse files Browse the repository at this point in the history
  • Loading branch information
aljones15 committed Oct 23, 2024
1 parent 1b0ffc8 commit fb3bc7c
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion lib/requests.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,20 @@ function _sanitizeErrorHeaders({error}) {
});
}
if(error.request) {
error.request = new global.Request(error.request, {
// get the url and the remaining properties from the request
const {url, ...props} = error.request;
// create an options object to pass to the new request
const options = {};
// do not copy these properties from the request
const skipKeys = new Set(['body', 'headers']);
for(const key in props) {
if(skipKeys.has(key)) {
continue;
}
options[key] = error.request[key];
}
error.request = new global.Request(url, {
...options,
headers: _sanitizeHeaders({httpMessage: error.request})
});
}
Expand Down

0 comments on commit fb3bc7c

Please sign in to comment.