diff --git a/package.json b/package.json index aa4fc79..ced630b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "appbase-js", - "version": "5.3.3", + "version": "5.3.4", "main": "dist/appbase-js.cjs.js", "jsnext:main": "dist/appbase-js.es.js", "module": "dist/appbase-js.es.js", diff --git a/src/core/request/fetch.js b/src/core/request/fetch.js index ad873bd..f66d1b3 100644 --- a/src/core/request/fetch.js +++ b/src/core/request/fetch.js @@ -101,6 +101,10 @@ function fetchRequest(args) { const transformedRequest = Object.assign({}, ts); const { url } = transformedRequest; delete transformedRequest.url; + + const controller = new AbortController(); + const { signal } = controller; + const fetchPromise = fetch( url || finalURL, Object.assign({}, transformedRequest, { @@ -111,6 +115,7 @@ function fetchRequest(args) { 'x-timestamp': new Date().getTime(), }) : transformedRequest.headers, + signal, // Attach the abort signal to the fetch request }), ); @@ -118,6 +123,7 @@ function fetchRequest(args) { if (httpRequestTimeout > 0) { setTimeout(() => { rejectTP(new Error('Request timeout')); + controller.abort(); }, httpRequestTimeout); } });