| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -88,8 +88,9 @@ const prepareStackTrace = (globalThis, error, trace) => { | |||
| 88 | 88 | } | |
| 89 | 89 | // Construct call site name based on: v8.dev/docs/stack-trace-api: | |
| 90 | 90 | const fnName = t.getFunctionName() ?? t.getMethodName(); | |
| 91 | - const originalName = `${t.getTypeName() !== 'global' ? | ||
| 92 | - `${t.getTypeName()}.` : ''}${fnName || '<anonymous>'}`; | ||
| 91 | + const typeName = t.getTypeName(); | ||
| 92 | + const namePrefix = typeName !== null && typeName !== 'global' ? `${typeName}.` : ''; | ||
| 93 | + const originalName = `${namePrefix}${fnName || '<anonymous>'}`; | ||
| 93 | 94 | // The original call site may have a different symbol name | |
| 94 | 95 | // associated with it, use it: | |
| 95 | 96 | const prefix = (name && name !== originalName) ? | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,11 @@ | |||
| 1 | + const message = 'Message ' + Math.random(); | ||
| 2 | + export async function Throw() { | ||
| 3 | + throw new Error(message); | ||
| 4 | + } | ||
| 5 | + await Throw(); | ||
| 6 | + // To recreate: | ||
| 7 | + // | ||
| 8 | + // npx tsc --module esnext --target es2017 --outDir test/fixtures/source-map --sourceMap test/fixtures/source-map/throw-async.ts | ||
| 9 | + // + rename js to mjs | ||
| 10 | + // + rename js to mjs in source map comment in mjs file | ||
| 11 | + //# sourceMappingURL=throw-async.mjs.map | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,13 @@ | |||
| 1 | + const message = 'Message ' + Math.random(); | ||
| 2 | + | ||
| 3 | + export async function Throw() { | ||
| 4 | + throw new Error(message) | ||
| 5 | + } | ||
| 6 | + | ||
| 7 | + await Throw(); | ||
| 8 | + | ||
| 9 | + // To recreate: | ||
| 10 | + // | ||
| 11 | + // npx tsc --module esnext --target es2017 --outDir test/fixtures/source-map --sourceMap test/fixtures/source-map/throw-async.ts | ||
| 12 | + // + rename js to mjs | ||
| 13 | + // + rename js to mjs in source map comment in mjs file | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -343,6 +343,22 @@ function nextdir() { | |||
| 343 | 343 | assert.ok(sourceMap); | |
| 344 | 344 | } | |
| 345 | 345 | ||
| 346 | + // Does not include null for async/await with esm | ||
| 347 | + // Refs: https://github.com/nodejs/node/issues/42417 | ||
| 348 | + { | ||
| 349 | + const output = spawnSync(process.execPath, [ | ||
| 350 | + '--enable-source-maps', | ||
| 351 | + require.resolve('../fixtures/source-map/throw-async.mjs'), | ||
| 352 | + ]); | ||
| 353 | + // Error in original context of source content: | ||
| 354 | + assert.match( | ||
| 355 | + output.stderr.toString(), | ||
| 356 | + /throw new Error\(message\)\r?\n.*\^/ | ||
| 357 | + ); | ||
| 358 | + // Rewritten stack trace: | ||
| 359 | + assert.match(output.stderr.toString(), /at Throw \([^)]+throw-async\.ts:4:9\)/); | ||
| 360 | + } | ||
| 361 | + | ||
| 346 | 362 | function getSourceMapFromCache(fixtureFile, coverageDirectory) { | |
| 347 | 363 | const jsonFiles = fs.readdirSync(coverageDirectory); | |
| 348 | 364 | for (const jsonFile of jsonFiles) { | |
| Back | FazBrowse Home | New Git URL |
0 commit comments