-
Notifications
You must be signed in to change notification settings - Fork 13
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
Map error positions against the original source (sourcemapping) #848
Conversation
92ae3a2
to
338e898
Compare
This comment was marked as outdated.
This comment was marked as outdated.
…a string expression
Not sure how useful this is tbh
It might be a distraction but I want to go back and look at the example in #582 It still doesn't serialize well (in prod or this branch), and just shows the error as But when I look at the stack trace, there's no stack in the job code, so we can't extract any error information. I think it's something to do with the axios callback - the error occurs in an async callstack, hence there's nothing useful in the stack to report. Is there anything we can everdo about this? Btw to repro the error (and get a real error message out), do this:
This goes away in later http versions, but I'm still worried about / interested in this async error case. |
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
* runtime: refine error output * tests: added error logging tests * compiler: append positional information to top level operations * compiler: write the operations map to the souce map * lexicon: add typings for extended source map * lexicon: tweak sourcemap types * package lock * runtime: updat error handling to handle adaptor errors with source mapping * runtime: better handling of nested adaptor errors probably * runtime: update tests * cli: types * tidy * runtime: better handling of nested errors
* compiler: append positional information to top level operations * compiler: write the operations map to the souce map * lexicon: add typings for extended source map * lexicon: tweak sourcemap types * package lock * runtime: updat error handling to handle adaptor errors with source mapping * runtime: better handling of nested adaptor errors probably * runtime: update tests * cli: types * tidy * runtime: better handling of nested errors * runtime: improvements to reporting of errors * changeset * runtime: improve error details * runtime: better frame detection for adaptor errors * runtime: fix tests * tests: update output logs
…an handle them properly
Hey @doc-han - are you up for a bit of a review over the runtime changes next week? I'll be putting this out to the team for QA in the CLI and Worker, I want to test this really thoroughly. But I'd welcome your feedback on the solution (if you can figure it out - it's quite a messy PR tbh!) |
Maybe on "error occurred at" we should say |
Make sure dist is properly cleaned each time
TODO - probably as a new issue. Pass a custom Error class into job code which generates a mapped stack trace. When job code writes |
Hey @doc-han I'm targeting a release of this on Monday next week. A review from you isn't essential but it is appreciated - if you'd like to review it, it needs to be in the next couple of days please :) |
Alright. I'll commence with review today then. |
@doc-han I think a consistently failing integration test has crept in, bit weird. I'll investigate it. |
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.
Awesome!
I was thinking we could get a path to source code for a job running via a file.
eg.
Instead of at vm:module(0): 5:8
we get at /jobs/get-data.js: 5:8
so that user can just click to file but then I started thinking of lightning.
The currently failing tests are right. We can't assume that a compiled code will always error at line |
yeah, I'm pretty sure when we create the node vm that we can control the name of the vm, so instead of I haven't found time to look into it properly. We can spin out a new issue to implement later - I'm sure it's not a big deal. We just to think about, in regard to THIS PR, making these custom vm frames easy to detect in stack traces (so maybe we prefix each name with |
Short Description
This PR uses sourcemapping to report accurate positions on error messages
It also adds some general improvements to error messages, for clarity, brevity and accuracy.
Fixes #230
Implementation Details
This is not a particularly focused bit of work, as it impacts lots of corners of code - including some gnarly bits.
The basic strategy is this:
expression.ts
now, rather than working them out later. This is so that we can map positions on top-level operations.runtime/src/util/sourcemap-errors.ts
. The sourcemap library does most of this for us - so mostly this module just updates metadata on the error object and parses the callstack to map positions there.API changes from the compiler have a big knock-on affect, resulting in a large diff.
Note that for top-level operations, this got a bit difficult because the stack trace is entirely in runtime code, not vm code. See #851 for details. Basically there's no meaningful position we can report for these cases - so what we do is work out which operation is responsible for the error, and say something like "error throw by the fn() operation on line 8".
Changes:
logger.print()
wasn't reporting to the Worker because it didn't have a timestampQA Notes
I will be asking for help testing the CLI and the worker. There are a lot of changes here
AI Usage
Please disclose how you've used AI in this work (it's cool, we just want to know!):
You can read more details in our Responsible AI Policy