Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed a regression bug with unsubscribing from cancel token & signal inside http adapter; #4819

Merged
merged 3 commits into from Sep 14, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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);
});
}