File tree Expand file tree Collapse file tree 1 file changed +12
-0
lines changed
packages/open-next/src/build/edge Expand file tree Collapse file tree 1 file changed +12
-0
lines changed Original file line number Diff line number Diff line change @@ -131,6 +131,18 @@ globalThis.Buffer = Buffer;
131131import {AsyncLocalStorage} from "node:async_hooks";
132132globalThis.AsyncLocalStorage = AsyncLocalStorage;
133133
134+ ${
135+ ''
136+ /**
137+ * Next.js sets this `__import_unsupported` on `globalThis` (with `configurable: false`):
138+ * https://github.com/vercel/next.js/blob/5b7833e3/packages/next/src/server/web/globals.ts#L94-L98
139+ *
140+ * It does so in both the middleware and the main server, so if the middleware runs in the same place
141+ * as the main handler this code gets run twice triggering a runtime error.
142+ *
143+ * For this reason we need to patch `Object.defineProperty` to avoid this issue.
144+ */
145+ }
134146const defaultDefineProperty = Object.defineProperty;
135147Object.defineProperty = function(o, p, a) {
136148 if(p=== '__import_unsupported' && Boolean(globalThis.__import_unsupported)) {
You can’t perform that action at this time.
0 commit comments