From 09b527313a29bb7545f867c8e8dd2fb4454075f6 Mon Sep 17 00:00:00 2001 From: zoltan feher Date: Thu, 26 Jun 2025 11:37:12 +0200 Subject: [PATCH] catch .clone() error properly --- dist/fetch-retry.umd.js | 7 ++++++- index.js | 7 ++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/dist/fetch-retry.umd.js b/dist/fetch-retry.umd.js index 948dde6..a06e973 100644 --- a/dist/fetch-retry.umd.js +++ b/dist/fetch-retry.umd.js @@ -68,10 +68,15 @@ var wrappedFetch = function (attempt) { // As of node 18, this is no longer needed since node comes with native support for fetch: /* istanbul ignore next */ - var _input = + try { + var _input = typeof Request !== 'undefined' && input instanceof Request ? input.clone() : input; + } catch (error) { + return reject(error); + } + fetch(_input, init) .then(function (response) { if (Array.isArray(retryOn) && retryOn.indexOf(response.status) === -1) { diff --git a/index.js b/index.js index 1a9dc43..820b9af 100644 --- a/index.js +++ b/index.js @@ -64,10 +64,15 @@ module.exports = function (fetch, defaults) { var wrappedFetch = function (attempt) { // As of node 18, this is no longer needed since node comes with native support for fetch: /* istanbul ignore next */ - var _input = + try { + var _input = typeof Request !== 'undefined' && input instanceof Request ? input.clone() : input; + } catch (error) { + return reject(error); + } + fetch(_input, init) .then(function (response) { if (Array.isArray(retryOn) && retryOn.indexOf(response.status) === -1) {