Skip to content

Commit

Permalink
Fixed a regression bug with unsubscribing from cancel token; (#4819)
Browse files Browse the repository at this point in the history
Reverts #4795;

Co-authored-by: Jay <jasonsaayman@gmail.com>
  • Loading branch information
DigitalBrainJS and jasonsaayman committed Sep 14, 2022
1 parent ce8a921 commit 379fdeb
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 9 deletions.
5 changes: 2 additions & 3 deletions lib/adapters/http.js
Expand Up @@ -100,7 +100,6 @@ function setProxy(options, configProxy, location) {
/*eslint consistent-return:0*/
export default function httpAdapter(config) {
return new Promise(function dispatchHttpRequest(resolvePromise, rejectPromise) {
let onCanceled;
let data = config.data;
const responseType = config.responseType;
const responseEncoding = config.responseEncoding;
Expand All @@ -118,11 +117,11 @@ export default function httpAdapter(config) {
isFinished = true;

if (config.cancelToken) {
config.cancelToken.unsubscribe(onCanceled);
config.cancelToken.unsubscribe(abort);
}

if (config.signal) {
config.signal.removeEventListener('abort', onCanceled);
config.signal.removeEventListener('abort', abort);
}

emitter.removeAllListeners();
Expand Down
7 changes: 1 addition & 6 deletions lib/adapters/xhr.js
Expand Up @@ -232,11 +232,6 @@ export default function xhrAdapter(config) {
}
}

// false, 0 (zero number), and '' (empty string) are valid JSON values
if (!requestData && requestData !== false && requestData !== 0 && requestData !== '') {
requestData = null;
}

const protocol = parseProtocol(fullPath);

if (protocol && platform.protocols.indexOf(protocol) === -1) {
Expand All @@ -246,6 +241,6 @@ export default function xhrAdapter(config) {


// Send the request
request.send(requestData);
request.send(requestData || null);
});
}

0 comments on commit 379fdeb

Please sign in to comment.