Skip to content

Commit 2c47e58

Browse files
cola119danielleadams
authored andcommitted
src: fix regression that a source marker is lost
PR-URL: #43086 Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Ben Coe <bencoe@gmail.com> Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
1 parent 5aa3b21 commit 2c47e58

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

src/node_errors.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,8 @@ static std::string GetErrorSource(Isolate* isolate,
6262
// added in the JavaScript context:
6363
Environment* env = Environment::GetCurrent(isolate);
6464
const bool has_source_map_url =
65-
!message->GetScriptOrigin().SourceMapUrl().IsEmpty();
65+
!message->GetScriptOrigin().SourceMapUrl().IsEmpty() &&
66+
!message->GetScriptOrigin().SourceMapUrl()->IsUndefined();
6667
if (has_source_map_url && env != nullptr && env->source_maps_enabled()) {
6768
return sourceline;
6869
}

test/parallel/test-error-reporting.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,10 @@ const assert = require('assert');
2525
const exec = require('child_process').exec;
2626
const fixtures = require('../common/fixtures');
2727

28-
function errExec(script, callback) {
29-
const cmd = `"${process.argv[0]}" "${fixtures.path(script)}"`;
28+
function errExec(script, option, callback) {
29+
callback = typeof option === 'function' ? option : callback;
30+
option = typeof option === 'string' ? option : '';
31+
const cmd = `"${process.argv[0]}" ${option} "${fixtures.path(script)}"`;
3032
return exec(cmd, (err, stdout, stderr) => {
3133
// There was some error
3234
assert.ok(err);
@@ -79,3 +81,8 @@ errExec('throws_error6.js', common.mustCall((err, stdout, stderr) => {
7981
errExec('throws_error7.js', common.mustCall((err, stdout, stderr) => {
8082
assert.match(stderr, /throw {\r?\n\^\r?\n{ toString: \[Function: toString] }\r?\n\r?\nNode\.js \S+\r?\n$/);
8183
}));
84+
85+
// Regression tests for https://github.com/nodejs/node/issues/39149
86+
errExec('throws_error7.js', '--enable-source-maps', common.mustCall((err, stdout, stderr) => {
87+
assert.match(stderr, /throw {\r?\n\^\r?\n{ toString: \[Function: toString] }\r?\n\r?\nNode\.js \S+\r?\n$/);
88+
}));

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy