-
Notifications
You must be signed in to change notification settings - Fork 38
Stack tracing / debug dump of intermediate files #1227
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
base: main
Are you sure you want to change the base?
Conversation
|
@harmony7 I think the test failures here are legit ones, can you have a look? |
|
Thanks, I have been able to fix some of the problems.
However, on my local: So I'm not sure how to clear this one up.
|
|
Additionally, the docusaurus one is failing due to OOM it looks like. |
|
The code looks all reasonable to me, but @zkat would likely be a better reviewer for it as our JS build expert 😄 |
|
@TartanLlama I've applied your suggestions =) let me know if there is anything else I should do |
This PR adds two features to the JS Compute Runtime, both using just JavaScript means (rather than by modifying the C++).
Stack tracing (
--enable-stack-traces)Consider the following example code.
By enabling the new option, the above code can be made to return an error stack like this:
instead of
This also catches errors at the top level. Consider the following top-level code:
This causes an error such as the following during the Wizer step
instead of
This is done by injecting the composed source map from esbuild and magic-string, as well as a trace mapping script into the resulting bundle.
It also works with any internal or external source maps that may already exist on the input file referenced by sourceMappingURL (external or internal data-url), for example if there is an additional bundler that runs (Webpack, tsc, etc.) before js-compute-runtime.
Source code contents are only included from user code (i.e., excludes node_modules and any injected code that results from transforms), and the code dump is provided for the top-most frame that exists in user code. However, this can be removed by specifying the
--exclude-sourcesflag, resulting in the mapped stack trace only.This mode also makes two exported functions available from
fastly:experimental:This makes mapped error stacks available to user error handling code, e.g.
Then curling this would give:
This feature adds a small amount of data to the Wasm package, but parsing the sourcemap does not occur on a hot code path, so runtime performance is not expected to be impacted strongly.
Outputting intermediate files (
--debug-intermediate-files <dir>)The bundling process has the following steps
After package has been built, the runtime deletes all of the temporary files. However it is sometimes useful to have access to view the intermediate files. By specifying the
--debug-intermediate-files <dir>flag, these intermediate files are dumped into the specified directory to aid in debugging. For example:This will output the files
__1_bundled.jsand__2_postbundled.jsas well asfastly_bundle.jsto the./bindirectory, which can be examined. If--enable-stack-tracesis also set, then intermediate source map files__1_bundled.js.map,__2_postbundled.js.map, as well as the final source map filefastly_sourcemaps.jsonwill also be emitted.