You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
An interceptor can delay XHR sending, and if the app cancels the request before it was send then the promise never resolved. HttpClient.pendingRequests collection grows with each request. Sample code:
initTest() {
console.log('Test')
this.testClient = new HttpClient();
this.testClient.configure(config => {
config.withInterceptor({
request(message) {
//Delay request for 1 second
return new Promise((resolve, reject) => {
setTimeout(() => {resolve(message)}, 1000)
})
},
});
});
}
test() {
console.log('Test')
let promise = this.testClient.get('/test'); //preserve original promise with abort method
promise.then(response => {
console.log('response', response)
})
.catch(e => {
console.log('error', e)
})
promise.abort()
console.log('Pending requests', this.testClient.pendingRequests)
}
if (this.isAborted) {
// Some interceptors can delay sending of XHR, so when abort is called
// before XHR is actually sent we abort() instead send()
this.xhr.abort();
} else {
Line 140 - xhr.onabort = (e) => { never invoked
Expected/desired behavior:
Expected result - promise either resolved or rejected
The text was updated successfully, but these errors were encountered:
I'm submitting a bug report
1.0.4
Please tell us about your environment:
Operating System:
OSX 10.x
Browser:
Chrome 56 | Firefox 51
Language:
es2015
Current behavior:
An interceptor can delay XHR sending, and if the app cancels the request before it was send then the promise never resolved. HttpClient.pendingRequests collection grows with each request. Sample code:
https://github.com/aurelia/http-client/blob/master/src/request-message-processor.js line 152 is invoked during processing phase.
Line 140 -
xhr.onabort = (e) => {
never invokedExpected/desired behavior:
Expected result - promise either resolved or rejected
The text was updated successfully, but these errors were encountered: