-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Remove request
and form-data
from companion
#3496
Comments
I think we should go with undici: Node.js has started vendoring it in and plans on exposing its implementation of |
Ooo nice. Never heard of it but it sounds promising. I'll add it. |
I have a feeling that |
sindresorhus, creator of Another option might be to use the |
I think the best thing to do is make a list of how we use |
Features that we need:
|
I'm not 100% sure but it seems like undici doesn't support custom redirects or hooks nodejs/undici#491 Only got, ky and axios support hooks like this, according to the
so I guess we're going with |
Note that Undici's fetch is only available for Node.js 16.8+, and we still want to support v14.20+. |
form-data
As discovered in #3477, https://github.com/form-data/form-data can cause strange bugs and crashes. Although that pr #3478 works around two of these bugs by sanitizing all metadata to strings,
form-data
seems unmaintained with many open issues/PRs and we should really rewrite our code to use something else.Although we don't depend on it directly,
request
does. We use request with form-data in Uploader for multipart XHR uploads.request
request
is deprecated and receives no more security updates or bugfixes. It does not support promises and will probably never support modern features like http2 and other neat stuff. We only use request a few places so it should be fairly straightforward to replace, although:uppy/packages/@uppy/companion/src/server/controllers/url.js
Line 67 in 7e9f34e
getRedirectEvaluator
https://github.com/transloadit/uppy/blob/main/packages/%40uppy/companion/src/server/helpers/request.jsHttpAgent
andHttpsAgent
https://github.com/transloadit/uppy/blob/main/packages/%40uppy/companion/src/server/helpers/request.jsAlternatives to replace
request
with:undici
advantages:
drawbacks:
got
advantages:
FormData
request body sindresorhus/got#1835drawbacks:
await import
.node-fetch
advantages:
drawbacks:
axios
advantages:
drawbacks:
purest
Purest is a module that provides configurable REST API for different providers with overrides for unknown providers. It is tightly integrated into companion providers.
uppy/packages/@uppy/companion/src/server/provider/index.js
Line 24 in 7e9f34e
We can either upgrade or replace purest with one of the above alternatives (replacing yields 1 request library instead of 2, so lower size).
Upgrading
purest
purest seems to have been rewritten completely recently and removed the use of
request
in v4.0.0, so we could look into upgrading to thatThere seems to be no change log for v4, just Complete rewrite of the module, so we may have to look into the code itself to see what breaking changes we need to consider.
It now depends on these modules for http request and multipart support, which seem to be not so popular:
The text was updated successfully, but these errors were encountered: