From c9065103b8ef0317fd8141f554fdc0a2f801e844 Mon Sep 17 00:00:00 2001 From: snek Date: Wed, 11 Sep 2024 22:42:26 -0700 Subject: [PATCH] fix: add test ensuring als works across dynamic import (#25593) The fix is in https://github.com/denoland/deno_core/pull/888 Fixes: https://github.com/denoland/deno/issues/25275 Signed-off-by: snek --- tests/unit_node/async_hooks_test.ts | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/tests/unit_node/async_hooks_test.ts b/tests/unit_node/async_hooks_test.ts index 91130972c5..edad57bf76 100644 --- a/tests/unit_node/async_hooks_test.ts +++ b/tests/unit_node/async_hooks_test.ts @@ -160,3 +160,15 @@ Deno.test(async function worksWithAsyncAPIs() { test(); }); }); + +Deno.test(async function worksWithDynamicImports() { + const store = new AsyncLocalStorage(); + // @ts-expect-error implicit any + globalThis.alsDynamicImport = () => store.getStore(); + const dataUrl = + `data:application/javascript,export const data = alsDynamicImport()`; + await store.run("data", async () => { + const { data } = await import(dataUrl); + assertEquals(data, "data"); + }); +});