Open klaemo opened 2 months ago
This is for a deployed Remix site?
Yeah! So, here's my understanding of installGlobals
:
installGlobals()
installs a custom fetch
polyfill the remix team maintains (https://github.com/remix-run/web-std-io). It has some slight differences to the real deal though.installGlobals({ nativeFetch: true })
which uses the same fetch
implementation node uses. This is especially needed for node versions < 20. As of node 20 node's fetch implementation is pretty solid and you might not need polyfills at all anymore.See remix's changelog: https://github.com/remix-run/remix/blob/main/CHANGELOG.md#undici
My suggestion is to switch to installGlobals({ nativeFetch: true })
and document it somewhere. And when Lambda gets node 22 in the future it should be safe to drop the polyfill altogether.
Or maybe even add a flag to let users control the polyfill behavior?!
@klaemo just to clarify, does changing installGlobals()
to installGlobals({ nativeFetch: true })
break for remix versions prior to v2.9?
If installGlobals({ nativeFetch: true })
works for everyone (node 18/20, remix prior/after v2.9), we probably don't need to expose the polyfill behavior to user?
just to clarify, does changing installGlobals() to installGlobals({ nativeFetch: true }) break for remix versions prior to v2.9?
It shouldn't, since that flag doesn't exist at all in those versions.
If installGlobals({ nativeFetch: true }) works for everyone (node 18/20, remix prior/after v2.9), we probably don't need to expose the polyfill behavior to user?
I agree that it's probably unnecessary to expose this to the user.
The
installGlobals()
polyfill is causing problems with newer remix version and certain http requests. Especially related to streams. Remix suggests that it's not necessary for node versions >=20. I wonder what the best strategy is to also support older remix versions with SST. Currently, I patched the polyfill toinstallGlobals({ nativeFetch: true })
to make it work. Maybe that's the way forward until it can be removed completely?