You've already forked matrix-js-sdk
mirror of
https://github.com/matrix-org/matrix-js-sdk.git
synced 2025-08-09 10:22:46 +03:00
Fix undefined reference in http-api
Put the check for 'onprogress' within the check to see if req is defined, because sometimes it isn't, apparently.
This commit is contained in:
@@ -686,21 +686,22 @@ module.exports.MatrixHttpApi.prototype = {
|
|||||||
handlerFn(err, response, body);
|
handlerFn(err, response, body);
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
// This will only work in a browser, where opts.request is the
|
if (req) {
|
||||||
// `browser-request` import. Currently `request` does not support progress
|
// This will only work in a browser, where opts.request is the
|
||||||
// updates - see https://github.com/request/request/pull/2346.
|
// `browser-request` import. Currently `request` does not support progress
|
||||||
// `browser-request` returns an XHRHttpRequest which exposes `onprogress`
|
// updates - see https://github.com/request/request/pull/2346.
|
||||||
if ('onprogress' in req) {
|
// `browser-request` returns an XHRHttpRequest which exposes `onprogress`
|
||||||
req.onprogress = (e) => {
|
if ('onprogress' in req) {
|
||||||
// Prevent the timeout from rejecting the deferred promise if progress is
|
req.onprogress = (e) => {
|
||||||
// seen with the request
|
// Prevent the timeout from rejecting the deferred promise if progress is
|
||||||
resetTimeout();
|
// seen with the request
|
||||||
};
|
resetTimeout();
|
||||||
}
|
};
|
||||||
if (req && req.abort) {
|
}
|
||||||
|
|
||||||
// FIXME: This is EVIL, but I can't think of a better way to expose
|
// FIXME: This is EVIL, but I can't think of a better way to expose
|
||||||
// abort() operations on underlying HTTP requests :(
|
// abort() operations on underlying HTTP requests :(
|
||||||
reqPromise.abort = req.abort.bind(req);
|
if (req.abort) reqPromise.abort = req.abort.bind(req);
|
||||||
}
|
}
|
||||||
} catch (ex) {
|
} catch (ex) {
|
||||||
defer.reject(ex);
|
defer.reject(ex);
|
||||||
|
Reference in New Issue
Block a user