Skip to content

Commit 3903887

Browse files
committed
fix: add AsyncLocalStorage to globalThis
1 parent cd52c07 commit 3903887

File tree

1 file changed

+6
-0
lines changed
  • packages/runtime/src/helpers

1 file changed

+6
-0
lines changed

packages/runtime/src/helpers/edge.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,12 +94,18 @@ const preamble = /* js */ `
9494
import {
9595
decode as _base64Decode,
9696
} from "https://deno.land/std@0.159.0/encoding/base64.ts";
97+
98+
import { AsyncLocalStorage } from "https://raw.githubusercontent.com/crowlKats/deno_std/asynclocalstorage/node/async_hooks.ts";
99+
97100
// Deno defines "window", but naughty libraries think this means it's a browser
98101
delete globalThis.window
99102
globalThis.process = { env: {...Deno.env.toObject(), NEXT_RUNTIME: 'edge', 'NEXT_PRIVATE_MINIMAL_MODE': '1' } }
100103
globalThis.EdgeRuntime = "netlify-edge"
101104
let _ENTRIES = {}
102105
106+
// Next.js expects this as a global
107+
globalThis.AsyncLocalStorage = AsyncLocalStorage
108+
103109
// Next.js uses this extension to the Headers API implemented by Cloudflare workerd
104110
if(!('getAll' in Headers.prototype)) {
105111
Headers.prototype.getAll = function getAll(name) {

0 commit comments

Comments
 (0)