Skip to content

Commit f44cecc

Browse files
Copilotdai-shi
andauthored
fix(devtools): correct V8 stack regex when source path contains spaces (#3531)
* fix(devtools): fix v8 stack regex to handle spaces in source paths Fixes the greedy regex `/.+ (.+) .+/` which would incorrectly capture text when the caller's source path contains a space (e.g. webpack namespaces like `webpack://my app/...` or Windows paths under `C:\Program Files\...`). Replace with `/^at (.+?) \(/` which anchors at `at `, uses a lazy quantifier, and stops at the first ` (` — the boundary between the function name and the source location in a V8 stack frame. Adds deterministic regression tests for: - webpack namespace with a space in the path - Windows path with a space in the path - space-free path (regression guard) Closes #3530 * fix(devtools): strip async/new keywords from v8 stack frame action name The regex /^at (.+?) \(/ from the previous fix correctly handles source paths with spaces, but captures "async " and "new " as part of the function name for async functions and constructors: at async Object.increment (file.js:10:5) → "async Object.increment" at new Foo (file.js:10:5) → "new Foo" The original greedy regex happened to strip those keywords as a side-effect of its own matching. Preserve that behavior with an optional non-capturing group: /^at (?:new |async )?(.+?) \(/ Now async frames yield "Object.increment" and constructor frames yield "Foo", matching the pre-fix behavior, while the spaced-path fix is kept intact. Adds regression tests for both the async and constructor cases. --------- Co-authored-by: copilot-swe-agent[bot] <[email protected]> Co-authored-by: Daishi Kato <[email protected]>
1 parent beca84e commit f44cecc

3 files changed

Lines changed: 9150 additions & 2 deletions

File tree

0 commit comments

Comments
 (0)