Skip to content

Commit

Permalink
[dart2js] allow tabs when computing the current script.
Browse files Browse the repository at this point in the history
For unclear reasons, a JS stack trace sometimes has tabs instead of
spaces. For example, this has been observed when using the VS Code
extension host (NodeJs) in issue #55684.  When that happens, the d8
preamble function to compute the current script fails. While tabs are
not generally present there, this small change can make the logic a bit
more robust and versatile.

Fixes #55684

Change-Id: Id1833a8b550a0ba5c9822e98d9e69ea9abfd6232
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/366160
Reviewed-by: Nicholas Shahan <nshahan@google.com>
Reviewed-by: Nate Biggs <natebiggs@google.com>
Commit-Queue: Sigmund Cherem <sigmund@google.com>
  • Loading branch information
sigmundch authored and Commit Queue committed May 13, 2024
1 parent 59f57b5 commit 3f705f0
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
9 changes: 5 additions & 4 deletions sdk/lib/_internal/js_dev_runtime/private/preambles/d8.js
Original file line number Diff line number Diff line change
Expand Up @@ -305,12 +305,13 @@ if (typeof global != "undefined") self = global; // Node.js.
// at init.currentScript (/tmp/foo.js:308:19)
// at /tmp/foo.js:320:7
// at /tmp/foo.js:331:4
// Sometimes the 'init.currentScript' line is in the format without the
// Sometimes the leading spaces are tabs (http://dartbug.com/55684) and
// sometimes the 'init.currentScript' line is in the format without the
// function name, so match with or without parentheses.

// vvvvvvvvvvvv Optional prefix up to '('.
var re = /^ *at (?:[^(]*\()?(.*):[0-9]*:[0-9]*\)?$/mg
// Optional ')' at end ^^^
// vvvvvvvvvvvv Optional prefix up to '('.
var re = /^\s*at (?:[^(]*\()?(.*):[0-9]*:[0-9]*\)?$/mg
// Optional ')' at end ^^^

var lastMatch = null;
do {
Expand Down
9 changes: 5 additions & 4 deletions sdk/lib/_internal/js_runtime/lib/preambles/d8.js
Original file line number Diff line number Diff line change
Expand Up @@ -298,12 +298,13 @@ if (typeof global != "undefined") self = global; // Node.js.
// at init.currentScript (/tmp/foo.js:308:19)
// at /tmp/foo.js:320:7
// at /tmp/foo.js:331:4
// Sometimes the 'init.currentScript' line is in the format without the
// Sometimes the leading spaces are tabs (http://dartbug.com/55684) and
// sometimes the 'init.currentScript' line is in the format without the
// function name, so match with or without parentheses.

// vvvvvvvvvvvv Optional prefix up to '('.
var re = /^ *at (?:[^(]*\()?(.*):[0-9]*:[0-9]*\)?$/mg
// Optional ')' at end ^^^
// vvvvvvvvvvvv Optional prefix up to '('.
var re = /^\s*at (?:[^(]*\()?(.*):[0-9]*:[0-9]*\)?$/mg
// Optional ')' at end ^^^

var lastMatch = null;
do {
Expand Down

0 comments on commit 3f705f0

Please sign in to comment.