devtools: inferred action name is corrupted when caller's source path contains spaces #3530
Replies: 2 comments 2 replies
|
Thanks for reporting. |
|
The diagnosis and the direction of the fix are both right, worth flagging one thing before the PR lands though: the proposed regex changes the output for a couple of frame shapes that aren't in the bug report but are common in real stacks. Testing both regexes against a broader set of realistic V8 frames: The two reported cases (spaced webpack path, Windows path) come out right either way, but async functions and constructor calls pick up an "async "/"new " prefix they didn't have before, since the old regex's leading Anchoring past an optional async/new keyword keeps parity with the current output for those cases while still fixing the spaced-path bug: Re-running the same set of frames through that version gives |
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.All reactions