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:
parent
c6400ab99c
commit
fc81b01bcd
2 changed files with 10 additions and 2 deletions
7
.changeset/smooth-melons-cough.md
Normal file
7
.changeset/smooth-melons-cough.md
Normal 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.
|
|
@ -8,14 +8,15 @@ import {
|
||||||
ASTRO_PATH_PARAM,
|
ASTRO_PATH_PARAM,
|
||||||
} from './adapter.js';
|
} 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
|
// 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
|
// the users's astro version or if astro:env is not enabled in the project
|
||||||
await import('astro/env/setup')
|
await import('astro/env/setup')
|
||||||
.then((mod) => mod.setGetEnv((key) => process.env[key]))
|
.then((mod) => mod.setGetEnv((key) => process.env[key]))
|
||||||
.catch(() => {});
|
.catch(() => {});
|
||||||
|
|
||||||
applyPolyfills();
|
|
||||||
|
|
||||||
export const createExports = (
|
export const createExports = (
|
||||||
manifest: SSRManifest,
|
manifest: SSRManifest,
|
||||||
{ middlewareSecret, skewProtection }: { middlewareSecret: string; skewProtection: boolean },
|
{ middlewareSecret, skewProtection }: { middlewareSecret: string; skewProtection: boolean },
|
||||||
|
|
Loading…
Add table
Reference in a new issue