Closed Fryuni closed 2 months ago
applyPolyfills()
should be called before the dynamic import. This was happening the Node and Netlify adapters as well and this fixed it. See https://github.com/withastro/adapters/commit/2248bc7edcbe37e4e75f573f88a200c2ba5afbae
Can you submit a PR for this?
I got it, here: https://github.com/withastro/astro/pull/11783
Astro Info
If this issue only occurs in one browser, which browser is a problem?
On the server
Describe the Bug
We generate this apply function that ends up in the entrypoint chunk to set up the Web API globals we use:
The SSR manifest goes into its own chunk that has:
The
decodeKey
comes from a separate file and is just this:Neither the manifest chunk nor the chunk defining
decodeKey
depend on the entrypoint chunk that defines and calls thatapply
function configuring crypto.It seems there is some reliance on the ordering of some of the hashes to determine how things get generated that might run the top-level code from the manifest chunk before the top-level code for the entrypoint chunk sets the crypto global. When that happens, calling any SSR route from that build on Vercel results in a 500 status with the following error on the server logs:
My guess that this is relying on ordering defined by some hash is because repeatedly building the same code either always works or always breaks, so there doesn't seem to have some randomness. Changing the name of a file (any file) changes the content of the manifest chunk and, therefore, its hash. Testing random names to see the effect it randomly works and stops working.
What's the expected result?
Build should always result in working code
Link to Minimal Reproducible Example
Only reproducible with Vercel prod builds
Participation