-
-
Notifications
You must be signed in to change notification settings - Fork 580
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
Use XHR onprogress to debounce http._request timeout #392
Conversation
Instead of just using a timeout to reject ongoing requests, reset the timeout when progress is observed (at least when requests are done from browsers). This is to fix element-hq/element-web#2737
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks good otherwise
src/http-api.js
Outdated
@@ -679,6 +686,11 @@ module.exports.MatrixHttpApi.prototype = { | |||
handlerFn(err, response, body); | |||
}, | |||
); | |||
req.onprogress = (e) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you should comment that this will only work in the browser (where opts.request
is browser-request
instead of request
).
Indeed, I'm not sure about the morality of setting onprogress
attributes on the request
object. Perhaps this should be protected by if ('onprogress' in req)
or something?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
Instead of just using a timeout to reject ongoing requests, reset the timeout when progress is observed (at least when requests are done from browsers).
This is to fix element-hq/element-web#2737
Supersedes #390