-
-
Notifications
You must be signed in to change notification settings - Fork 606
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
Consider switching http libs #801
Comments
Related: #244 |
Yes, ´superagent´ is a lot smaller than ´request´. https://bundlephobia.com/result?p=request@2.88.0 On GitHub ´superagent´ is currently labelled as passively maintained and looking for maintainers. However, this might not be a concern, as the library seems stable and well-developed at first glance. As far as I can tell, a replacement of the dependency requires a mock of Do you have a list of steps which are required to give the experiment of replacing |
Replacing Most of the HTTP code should be in one place, with the exception of all the places that rely on the response/error objects from The shorter answer is that I unfortunately don't have a list, but I do know it is a long one. |
I would recommend to use axios. request is maintance mode
|
Maybe this feature comparison is helpful in deciding which alternative to switch to: https://github.com/sindresorhus/got#comparison |
I was having some issues login in with JWT token and request.
I ended up doing this for it to work:
Since I was not able to make this endpoint work with request in any way, I even tried isolated tests and I always received 'Error: Server returned 403 error' until I switched to axios, this endpoint is working with browser-request. Since it seems like a very simple change in interface from request to axios, is there any effort already going on switching into another library? I would love to contribute to this if you think this is the right approach. |
There is a WIP PR to move over to fetch, which is a more likely candidate as it is built-in in the web |
Great! Thanks. |
This is the aforementioned PR, though it is 4 years old now: #797 |
Not sure if this helps in evaluation, but I had a use case to use Fetch with the current SDK; here's a gist of my wrapped implementation that supports aborting. Seems to work... so far? https://gist.github.com/bradjones1/dae3207aa7dce6eb508cfec56a76ae99 |
Closing in favor of element-hq/element-web#22265 which has had recent push to be part of the 2022 tech strategy. |
@MadLittleMods given that element-web is not the only consumer of the js-sdk, this is a far better place to collect opinions from other consumers |
Keeping Enhancement due to it adding new features
|
Current thinking is to switch to fetch, for js-sdk it'll still need a polyfill given the Node version where fetch support was added is more modern than our minimum supported version |
Not sure if OT for this topic or not but it'd be great if a replacing lib either has or is easy to extend with reasonable (exponential backoffs) retry behavior. I think this has the potential to improve UX greatly in scenarios with unreliable or intermittent HS connectivity. The For a nodejs-only app, Since axios was mentioned: Even if axios is popular and looks great at first glance we had so many tricky-to-debug issues and edge-cases with it over the years, some are still open. I really would not recommend a project migrating to it today. |
Retry behaviour is rarely easy, given that even if the response failed to make it to the requester, the effect may have taken place, so really you can only retry GET and PUTs which are idempotent via txnId |
Depends. Common practice is to differentiate between error codes, where e.g. |
408 Request Timeout doesn't feel safe to retry, the server may have received the request successfully here and acted upon it. 502 Bad Gateway doesn't feel safe to retry, given it is specified as
Not that the upstream server wasn't given the request 504 Gateway Timeout is certainly not safe to retry, in this case the upstream server more than likely got the request, but the response will never make it back to the caller. This is the error you'll see on matrix.org when joining a room takes too long for example. |
Honestly even limiting retries to just idempotent GETs would still cover the instances I can recall where this forced me to restart element-desktop or rendered the whole app unoperable, so I still think that's a win. |
* Changes the `uploadContent` API, kills off `request` and `browser-request` in favour of `fetch`, removed callback support on a lot of the methods, adds a lot of tests. ([\matrix-org#2719](matrix-org#2719)). Fixes matrix-org#2415 and matrix-org#801. * Remove deprecated `m.room.aliases` references ([\matrix-org#2759](matrix-org#2759)). Fixes element-hq/element-web#12680. * Remove node-specific crypto bits, use Node 16's WebCrypto ([\matrix-org#2762](matrix-org#2762)). Fixes matrix-org#2760. * Export types for MatrixEvent and Room emitted events, and make event handler map types stricter ([\matrix-org#2750](matrix-org#2750)). Contributed by @stas-demydiuk. * Use even more stable calls to `/room_keys` ([\matrix-org#2746](matrix-org#2746)). * Upgrade to Olm 3.2.13 which has been repackaged to support Node 18 ([\matrix-org#2744](matrix-org#2744)). * Fix `power_level_content_override` type ([\matrix-org#2741](matrix-org#2741)). * Add custom notification handling for MSC3401 call events ([\matrix-org#2720](matrix-org#2720)). * Add support for unread thread notifications ([\matrix-org#2726](matrix-org#2726)). * Load Thread List with server-side assistance (MSC3856) ([\matrix-org#2602](matrix-org#2602)). * Use stable calls to `/room_keys` ([\matrix-org#2729](matrix-org#2729)). Fixes element-hq/element-web#22839. * Fix POST data not being passed for registerWithIdentityServer ([\matrix-org#2769](matrix-org#2769)). Fixes matrix-org/element-web-rageshakes#16206. * Fix IdentityPrefix.V2 containing spurious `/api` ([\matrix-org#2761](matrix-org#2761)). Fixes element-hq/element-web#23505. * Always send back an httpStatus property if one is known ([\matrix-org#2753](matrix-org#2753)). * Check for AbortError, not any generic connection error, to avoid tightlooping ([\matrix-org#2752](matrix-org#2752)). * Correct the dir parameter of MSC3715 ([\matrix-org#2745](matrix-org#2745)). Contributed by @dhenneke. * Fix sync init when thread unread notif is not supported ([\matrix-org#2739](matrix-org#2739)). Fixes element-hq/element-web#23435. * Use the correct sender key when checking shared secret ([\matrix-org#2730](matrix-org#2730)). Fixes element-hq/element-web#23374.
something like https://github.com/visionmedia/superagent works nicely in both the browser and in node.
request
does work in both, but is painful and large for the browser (and causes weird problems sometimes).The text was updated successfully, but these errors were encountered: