0
Fork 0
mirror of https://github.com/withastro/astro.git synced 2025-02-17 22:44:24 -05:00

Prevent race condition in Vercel adapter on Node 18 (#11783)

This commit is contained in:
Matthew Phillips 2024-08-19 15:45:02 -04:00 committed by GitHub
parent c6400ab99c
commit fc81b01bcd
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 10 additions and 2 deletions

View file

@ -0,0 +1,7 @@
---
'@astrojs/vercel': patch
---
Prevent race condition with Node 18
Using Node 18 there can be a race condition where polyfill for the `crypto` global is not applied in time. This change ensures the polyfills run first.

View file

@ -8,14 +8,15 @@ import {
ASTRO_PATH_PARAM,
} from './adapter.js';
// Run polyfills immediately so any dependent code can use the globals
applyPolyfills();
// Won't throw if the virtual module is not available because it's not supported in
// the users's astro version or if astro:env is not enabled in the project
await import('astro/env/setup')
.then((mod) => mod.setGetEnv((key) => process.env[key]))
.catch(() => {});
applyPolyfills();
export const createExports = (
manifest: SSRManifest,
{ middlewareSecret, skewProtection }: { middlewareSecret: string; skewProtection: boolean },