devtools: inferred action name is corrupted when caller's source path contains spaces #3530
Unanswered
happyTaher
asked this question in
Bug report
Replies: 1 comment 1 reply
-
|
Thanks for reporting. |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Summary
When
setStateis called without an explicit action name, thedevtoolsmiddleware infers the action name from the call stack. The regex used to parse a V8 stack frame is:This captures the token between two spaces. If the caller frame's source path contains a space, the greedy match lands inside the path and the wrong text is used as the action name in Redux DevTools.
Affected cases
Common real-world paths with spaces:
at Object.increment (webpack://my app/./src/store.js:10:5)→ action name becomes"(webpack://my"at increment (C:\Program Files\app\store.js:10:5)→ action name becomes"(C:\Program"Expected action name in both cases:
increment(orObject.increment).Reproduction (regex in isolation)
Impact
Cosmetic — devtools-only. Actions still dispatch correctly; only the displayed action label is wrong. Paths without spaces and anonymous frames are unaffected.
Fix
Anchor the match to
atand stop at the first(:/^at (.+?) \(/. This is equivalent on all space-free paths (and on the cases covered by the existing tests) and fixes the spaced-path cases. PR incoming with a deterministic test.Beta Was this translation helpful? Give feedback.
All reactions