| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 400d598 commit 3619dc0
6 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -32,14 +32,19 @@ function getErrorSourceLocation(error) { | |||
| 32 | 32 | startColumn, | |
| 33 | 33 | } = pos; | |
| 34 | 34 | ||
| 35 | + if (!sourceLine) { | ||
| 36 | + return; | ||
| 37 | + } | ||
| 38 | + | ||
| 35 | 39 | // Source map is not enabled. Return the source line directly. | |
| 36 | 40 | if (!getSourceMapsSupport().enabled) { | |
| 37 | 41 | return { sourceLine, startColumn }; | |
| 38 | 42 | } | |
| 39 | 43 | ||
| 40 | 44 | const sm = findSourceMap(scriptResourceName); | |
| 41 | 45 | if (sm === undefined) { | |
| 42 | - return; | ||
| 46 | + // No source map for this file; use the generated source line. | ||
| 47 | + return { sourceLine, startColumn }; | ||
| 43 | 48 | } | |
| 44 | 49 | const { | |
| 45 | 50 | originalLine, | |
@@ -49,7 +54,9 @@ function getErrorSourceLocation(error) { | |||
| 49 | 54 | const originalSourceLine = getSourceLine(sm, originalSource, originalLine, originalColumn); | |
| 50 | 55 | ||
| 51 | 56 | if (!originalSourceLine) { | |
| 52 | - return; | ||
| 57 | + // Source map exists but original source is unavailable; use the | ||
| 58 | + // generated source line rather than returning undefined. | ||
| 59 | + return { sourceLine, startColumn }; | ||
| 53 | 60 | } | |
| 54 | 61 | ||
| 55 | 62 | return { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,9 @@ | |||
| 1 | + // Flags: --enable-source-maps | ||
| 2 | + | ||
| 3 | + import '../../../common/index.mjs'; | ||
| 4 | + import { strict as assert } from 'node:assert'; | ||
| 5 | + | ||
| 6 | + // Regression test for https://github.com/nodejs/node/issues/63169 | ||
| 7 | + // Under --enable-source-maps with no source map for this file, a failing | ||
| 8 | + // assert(value) must throw AssertionError, not TypeError ERR_INVALID_ARG_TYPE. | ||
| 9 | + assert(false); // eslint-disable-line no-restricted-syntax | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,20 @@ | |||
| 1 | + node:internal/modules/run_main:<line> | ||
| 2 | + triggerUncaughtException( | ||
| 3 | + ^ | ||
| 4 | + | ||
| 5 | + AssertionError [ERR_ASSERTION]: The expression evaluated to a falsy value: | ||
| 6 | + | ||
| 7 | + assert(false) | ||
| 8 | + | ||
| 9 | + at file://<project-root>/test/fixtures/source-map/output/source_map_assert_no_source_map.mjs:9:1 | ||
| 10 | + at <node-internal-frames> | ||
| 11 | + at <node-internal-frames> { | ||
| 12 | + generatedMessage: true, | ||
| 13 | + code: 'ERR_ASSERTION', | ||
| 14 | + actual: false, | ||
| 15 | + expected: true, | ||
| 16 | + operator: '==', | ||
| 17 | + diff: 'simple' | ||
| 18 | + } | ||
| 19 | + | ||
| 20 | + Node.js <node-version> | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,10 @@ | |||
| 1 | + // Flags: --enable-source-maps | ||
| 2 | + | ||
| 3 | + 'use strict'; | ||
| 4 | + require('../../../common'); | ||
| 5 | + const assert = require('node:assert'); | ||
| 6 | + | ||
| 7 | + // Regression test for https://github.com/nodejs/node/issues/63169 | ||
| 8 | + // Under --enable-source-maps with no source map for this file, a failing | ||
| 9 | + // assert.ok(value) must throw AssertionError, not TypeError ERR_INVALID_ARG_TYPE. | ||
| 10 | + assert.ok(false); // eslint-disable-line no-restricted-syntax | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,20 @@ | |||
| 1 | + node:internal/assert/utils:<line> | ||
| 2 | + throw error; | ||
| 3 | + ^ | ||
| 4 | + | ||
| 5 | + AssertionError [ERR_ASSERTION]: The expression evaluated to a falsy value: | ||
| 6 | + | ||
| 7 | + assert.ok(false) | ||
| 8 | + | ||
| 9 | + at Object.<anonymous> (<project-root>/test/fixtures/source-map/output/source_map_assert_ok_no_source_map.cjs:10:8) | ||
| 10 | + at <node-internal-frames> | ||
| 11 | + at <node-internal-frames> { | ||
| 12 | + generatedMessage: true, | ||
| 13 | + code: 'ERR_ASSERTION', | ||
| 14 | + actual: false, | ||
| 15 | + expected: true, | ||
| 16 | + operator: '==', | ||
| 17 | + diff: 'simple' | ||
| 18 | + } | ||
| 19 | + | ||
| 20 | + Node.js <node-version> | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -5,6 +5,8 @@ import { describe, it } from 'node:test'; | |||
| 5 | 5 | ||
| 6 | 6 | describe('sourcemaps output', { concurrency: !process.env.TEST_PARALLEL }, () => { | |
| 7 | 7 | const tests = [ | |
| 8 | + { name: 'source-map/output/source_map_assert_no_source_map.mjs' }, | ||
| 9 | + { name: 'source-map/output/source_map_assert_ok_no_source_map.cjs' }, | ||
| 8 | 10 | { name: 'source-map/output/source_map_disabled_by_api.js' }, | |
| 9 | 11 | { name: 'source-map/output/source_map_disabled_by_process_api.js' }, | |
| 10 | 12 | { name: 'source-map/output/source_map_enabled_by_api.js' }, | |
| Back | FazBrowse Home | New Git URL |
0 commit comments