Open
Description
Even tho the sveltekit package is importing AsyncLocalStorage
from node:asyn_hooks
:
the tracing.ts
file is not prepending node:
,
which is causing an error on build on cloudflare:
15:38:03.971 ✘ [ERROR] Build failed with 1 error:
15:38:03.972
15:38:03.972 ✘ [ERROR] Could not resolve "async_hooks"
15:38:03.972
15:38:03.972 ../output/server/chunks/flags.js:1:118:
15:38:03.972 1 │ ...syncLocalStorage as q}from"async_hooks";import{AsyncLocalStorage...
15:38:03.973 ╵ ~~~~~~~~~~~~~
15:38:03.973
15:38:03.973 The package "async_hooks" wasn't found on the file system but is built into node.
I already followed the suggestions (adding nodejs_compat
and the latest compatibility_date
) with no luck. What works is patching the flag package with bun patch
, but I need to do it on every update of the flags package (which is not a burden tbh but still would prefer not to do it manually everytime)
Metadata
Metadata
Assignees
Labels
No labels
Activity
dferber90 commentedon Apr 10, 2025
We had #51 open before, where I published a snapshot release using
node:async_hooks
in this comment. Can you see if the snapshot release would fix it for you?Can you try
@vercel/flags@3.1.1-475dd26e-20250206133544
and let me know whether that works for you? The release is slightly outdated now but might be good enough to see ifnode:async_hooks
would actually work for youbuhodev commentedon Apr 23, 2025
I can confirm that using
@vercel/flags@3.1.1-475dd26e-20250206133544
works. The build was successful cc @dferber90KBeDevel commentedon May 16, 2025
Same issue using flags@4.0.0 and flags@4.0.1-ff75a409-20250506071241
dferber90 commentedon May 18, 2025
For anyone running into the async_hooks issue, can you leave more details on this issue?
flags/next
orflags/sveltekit
flags/next
, are you sure you are not using flags in client components?If possible, please share a minimal reproduction.
alehar9320 commentedon May 24, 2025
Receiving this error too. NextJS App Router.
deps:
flags.tsx
`
import { flag } from 'flags/next';
export const themableFlag = flag({
key: 'themable-flag',
decide: () => false,
});
`
mycomponent.tsx
`
import { themableFlag } from '@/app/feature-flags/flags';
import ApplicationTopBarClient from './ApplicationTopBarClient';
export default async function ApplicationTopBar() {
const isThemable = await themableFlag();
return ;
}`
Hope this helps debug.
edit: for anyone else experiencing this error - ensure that you put the call to flags inside a page.tsx or layout.tsx file, rather than a sub-component. Then pass on the value as input to the following components.