Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Re-throw locations missing in the stacktrace #36485

Closed
MrQubo opened this issue Dec 11, 2020 · 1 comment
Closed

Re-throw locations missing in the stacktrace #36485

MrQubo opened this issue Dec 11, 2020 · 1 comment
Labels
wrong repo Issues that should be opened in another repository.

Comments

@MrQubo
Copy link

MrQubo commented Dec 11, 2020

What steps will reproduce the bug?

Run the following code with node:

try {
	try {
		throw new Error('test');
	} catch (err1) {
		throw err1;
	}
} catch (err2) {
	throw err2;
}

What is the expected behavior?

Lines third, fifth and eighth (i.e. all throw statements) should be included in the stacktrace.

What do you see instead?

This is the output on stderr:

/tmp/test.js:8
        throw err2;
        ^

Error: test
    at Object.<anonymous> (/tmp/test.js:3:9)
    at Module._compile (node:internal/modules/cjs/loader:1108:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1137:10)
    at Module.load (node:internal/modules/cjs/loader:973:32)
    at Function.Module._load (node:internal/modules/cjs/loader:813:14)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:76:12)
    at node:internal/main/run_main_module:17:47

Additional information

For some reason eighth line is being highlighted but not included in the stacktrace. But the fifth line is completely missing. I think that third line should be highlighted, see #36484.

@aduh95
Copy link
Contributor

aduh95 commented Dec 12, 2020

The stack trace of an error is generated based on where the Error object is created (line 3 in your example), and the highlighted line is the one which threw the error. This behaviour is produced by V8 (the JS engine Node.js is using), you can reproduce the same behaviour on Chrome browsers as well:

VM177:8 Uncaught Error: test
    at <anonymous>:3:9

If you don't like this behaviour, you can open an issue on the V8 issue tracker.

@aduh95 aduh95 closed this as completed Dec 12, 2020
@aduh95 aduh95 added the wrong repo Issues that should be opened in another repository. label Dec 12, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
wrong repo Issues that should be opened in another repository.
Projects
None yet
Development

No branches or pull requests

2 participants