diff options
author | 2024-08-19 15:45:02 -0400 | |
---|---|---|
committer | 2024-08-19 15:45:02 -0400 | |
commit | fc81b01bcdd43646bcc615b16bf0400a646445c8 (patch) | |
tree | a5a135f07868719a8874d5cc4a18715025bd6fea | |
parent | c6400ab99c5e5f4477bc6ef7e801b7869b0aa9ab (diff) | |
download | astro-fc81b01bcdd43646bcc615b16bf0400a646445c8.tar.gz astro-fc81b01bcdd43646bcc615b16bf0400a646445c8.tar.zst astro-fc81b01bcdd43646bcc615b16bf0400a646445c8.zip |
Prevent race condition in Vercel adapter on Node 18 (#11783)
-rw-r--r-- | .changeset/smooth-melons-cough.md | 7 | ||||
-rw-r--r-- | packages/integrations/vercel/src/serverless/entrypoint.ts | 5 |
2 files changed, 10 insertions, 2 deletions
diff --git a/.changeset/smooth-melons-cough.md b/.changeset/smooth-melons-cough.md new file mode 100644 index 000000000..0a4a3ea9d --- /dev/null +++ b/.changeset/smooth-melons-cough.md @@ -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. diff --git a/packages/integrations/vercel/src/serverless/entrypoint.ts b/packages/integrations/vercel/src/serverless/entrypoint.ts index 876ab6b07..a881d701a 100644 --- a/packages/integrations/vercel/src/serverless/entrypoint.ts +++ b/packages/integrations/vercel/src/serverless/entrypoint.ts @@ -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 }, |