Skip to content

Commit

Permalink
fix(src): ensure AsyncLocalStorage is available globally (might fix #875
Browse files Browse the repository at this point in the history
)
  • Loading branch information
Xunnamius committed Jan 8, 2024
1 parent 0e65e72 commit 43680d9
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,10 @@ export async function testApiHandler<NextResponseJsonType = any>({
let deferredReject: ((error?: unknown) => void) | null = null;

try {
if (!globalThis.AsyncLocalStorage) {
globalThis.AsyncLocalStorage = (await import('node:async_hooks')).AsyncLocalStorage;
}

if (!apiResolver) {
({ apiResolver } = await Promise.reject()
// ? The following is for next@>=13.5.4:
Expand Down

0 comments on commit 43680d9

Please sign in to comment.