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

Use XHR onprogress to debounce http._request timeout #392

Merged
merged 2 commits into from
Mar 16, 2017

Conversation

lukebarnard1
Copy link
Contributor

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

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
Copy link
Member

@richvdh richvdh left a 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) => {
Copy link
Member

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SGTM

@richvdh richvdh assigned lukebarnard1 and unassigned richvdh Mar 15, 2017
@lukebarnard1 lukebarnard1 assigned richvdh and unassigned lukebarnard1 Mar 16, 2017
Copy link
Member

@richvdh richvdh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants