Add XHR timeout handler

This commit is contained in:
Rob Lourens 2017-11-22 09:46:52 -08:00
parent 9dbb1a1786
commit a858ad5434
2 changed files with 2 additions and 1 deletions

View file

@ -61,6 +61,7 @@ export const xhrRequest: IRequestFunction = (options: IRequestOptions): TPromise
stream: new ArrayBufferStream(xhr.response)
});
};
xhr.ontimeout = e => reject(new Error(`XHR timeout: ${options.timeout}ms`));
if (options.timeout) {
xhr.timeout = options.timeout;

View file

@ -189,7 +189,7 @@ class RemoteSearchProvider {
'Content-Type': 'application/json; charset=utf-8',
'api-key': endpoint.key
},
timeout: 4000
timeout: 5000
})
.then(context => {
if (context.res.statusCode >= 300) {