Zustand Devtools shows 'anonymous' actions by default when moving from vite 5.x to vite 7.x #3254
-
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 2 replies
-
|
Seems a bug I'll look into that |
Beta Was this translation helpful? Give feedback.
-
|
Is this related with #3250? |
Beta Was this translation helpful? Give feedback.
-
|
Any updates here? I am also seeing the same issue |
Beta Was this translation helpful? Give feedback.
-
|
@booherbg this is caused by vite 7's switch from esbuild to rolldown for dependency pre-bundling. the stack trace format changed, breaking zustand's action name detection. in const findCallerName = (stack: string | undefined) => {
const traceLines = stack.split('\n')
const idx = traceLines.findIndex((l) => l.includes('api.setState'))
const callerLine = traceLines[idx + 1]?.trim() || ''
return /.+ (.+) .+/.exec(callerLine)?.[1]
}rolldown produces different wrapper function names and source map alignment than esbuild, so the regex fails and falls through to fix: explicitly name your actions (recommended regardless of bundler): const useStore = create(
devtools((set) => ({
count: 0,
inc: () => set(s => ({ count: s.count + 1 }), undefined, 'inc'),
dec: () => set(s => ({ count: s.count - 1 }), undefined, 'dec'),
}))
)third argument to |
Beta Was this translation helpful? Give feedback.



@booherbg this is caused by vite 7's switch from esbuild to rolldown for dependency pre-bundling. the stack trace format changed, breaking zustand's action name detection.
in
devtools.ts(~line 176), zustand extracts action names by parsingnew Error().stack:rolldown produces different wrapper function names and source map alignment than esbuild, so the regex fails and falls through to
'anonymous'. @dai-shi's reference to #3250 …