-
Notifications
You must be signed in to change notification settings - Fork 290
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
Stop REPL stack traces at the REPL eval frame #1263
Stop REPL stack traces at the REPL eval frame #1263
Conversation
You probably have a mismatched version of Node.js locally -- V8 renamed that property a while ago. Usually I run |
As in, this repo needs node 14? I had been using 16 because the repo uses npm lockfile v2 (otherwise I will break my node 14 install I use for TS, which is still on npm6), but I can just go back to 14 and leave my lock unclean while working. |
The test failures are at least the ones I was expecting, so that's good. I'll fix things up. |
There's still a failure in the console log tests because it looks like the eval source mapping overrides the one in the evaluated code. I'm not quite sure what to do about that. Additionally, the new source file extension I invented is shown in traces that contain frames from the eval more than once (since the REPL can call back into itself and those frames are shown). I don't think that's ideal, but I'm not sure what to do about that one either. Making the extension be the |
I am also questioning whether or not the initial eval frame should be printed or not; given it can show up thanks to self-referential code, it's probably more consistent to show it, but I still have to solve the extension name issue. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking good to me overall, some comments
Co-authored-by: Connor Peet <[email protected]>
Making this a draft for now. I'm not exactly happy with the stack traces and how they show the faked filename. Perhaps a better method would be to instead invoke evals as an IIFE with a well-known name? |
I'd be OK merging this PR, I tested it locally and I think it's looking good. We're in full control of what filenames we show, what would you ideal solution look like? |
Preferably, I'd like the path to look somewhat like node's REPL, e.g.:
Where the filename is just "REPL" or something, versus how this PR talks about
But, I'm not sure exactly the right thing to do. I already don't like the fact that this method of identifying the eval overrides any user provided source map for the REPL, but I suppose nobody's putting their own source mapping into REPL statements. |
You can edit that here 🙂 vscode-js-debug/src/adapter/sources.ts Lines 332 to 340 in 98b20c3
It actually doesn't -- it would override the url, but not the map. It's already quite unlikely for a sourcemap with relative external references to work (which is what the url would affect) but a fully inline sourcemap would still work. |
Aha, thanks. I'll change that to switch it to |
Unfortunately that's not the right thing; stack trace printing actually looks directly at |
I've changed it so that you get However, I get this error when I run the tests (this has probably been true the whole time):
The protocol says that |
When you run the tests, on a failure, it should print the location of a |
Sorry for the delay; was OOF. Here's the JSON file (with extension txt so GitHub lets me upload it): |
src/test/console/console-format-applies-skipfiles-to-logged-stacks.txt
Outdated
Show resolved
Hide resolved
@@ -73,14 +73,14 @@ result: 3 | |||
|
|||
Evaluating#1: setTimeout(() => { throw new Error('bar')}, 0) | |||
stderr> Uncaught Error Error: bar | |||
at <anonymous> (http://localhost:8001/eval1.js:1:26) | |||
at <anonymous> (localhost꞉8001/eval1.js:1:26) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These changes are due to me dropping uiLocation?.source.url
use from formatAsNative
so the pretty name shows up instead.
@connor4312 I have merged main and simplified a few things; I don't know that the above error happens anymore locally on my machine, but it doesn't look like Pipelines is running on my PR anymore so I can't tell if I'm still breaking something on Windows. I'm thinking the undefined bug got fixed sometime this month. This stack trace thing is annoying me quite a bit so I'm hoping to see this one go in. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
Fixes #1259.
This makes errors thrown in the REPL look like this:
Cutting off all of the frames below the eval used to evaluate what was typed in the REPL, which can be arbitrarily large and is already implied by the debugger UI.
I don't have tests for this yet; I'm having trouble running them locally without a whole load timing out or failing because they expect
__proto__
and I get[[Prototype]]
or something.