-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Replace "request" with something else #2672
Comments
for proxy u can use https://www.npmjs.com/package/proxy-agent with got |
Oh, you already mentioned axios. |
Good to know! I was trying https://github.com/koichik/node-tunnel and that did not work. In general, I am very reluctant to use a library that's discarding low-level stack traces reported by Node.js and replacing them with a new stack pointing only to the client library. Unfortunately, that rules out both |
@bajtos @hacksparrow, do you think we should turn this into a spike to find out what's a good substitution? I'm thinking of the following acceptance criteria. Please review: Acceptance Criteria
|
I don't have strong opinions here but axios and node-fetch seem to be two popular candidates. |
Thanks @raymondfeng. How do we know which one is better? :) Any criteria to determine that? |
As of today, request has been officially deprecated at npm level. |
AFAICT, https://www.npmjs.com/package/needle should be preserving error details reported by Node.js core and supports Promise-style too. It may be a good alternative to consider. |
First step to replace The usage of |
@raymondfeng Can you please confirm that axios is preserving low-level error details? (See the discussion above.) Ideally, I'd like us to use the same library across the entire loopback-next codebase, including connectors like REST and SOAP.
IMO, we should start with looking for a library that works well for |
FYI, here is a chart comparing download numbers for different |
I did a quick experiment with I quickly scanned the source code of The good thing about Axios is that they should be preserving original Node.js errors, at least as far as I can tell - see https://github.com/axios/axios/blob/03e6f4bf4c1eced613cf60d59ef50b0e18b31907/lib/adapters/http.js#L224-L245 |
There are 2 references of the request module with https://www.npmjs.com/package/request in docs. We may want to update that as well: |
This comes from Fixed. |
IMO, we need to migrate all actively-developer connectors to use Axios instead of request. Here is why:
I am proposing to release that change in a new major version, to allow people to stick with |
To be fixed: |
request
module is moving to maintenance mode, we should eventually find a new HTTP client.I tried to upgrade to
got
.got
works well for simple use cases, but stops working for non-trivial requests (e.g. when a proxy is involved). What's worse, it replaces errors reported by Node.js core with its own error classes, which makes troubleshooting extremely difficult 😞 It seems that other popular clients likenode-fetch
andaxios
are doing the same mistake 😞(UPDATED on Jun 12, 2019)
Acceptance Criteria
request
alternatives (e.g.axios
andnode-fetch
), find one that meets the following requirements:@loopback/http-caching-proxy
too.node-fetch
API.It can be a reusable component/module where we can customize the behavior.
The text was updated successfully, but these errors were encountered: