You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Get a minified stack trace instead of a link back to the original source code
What is the expected behavior?
If I run the same code with a manually thrown error but point to the typescript files directly instead of using pre-bundled ones, I get the following stack trace:
30 |
31 | // Lambda Handler
32 | async function lambdaHandler(request: Request): Promise<Response> {
33 | customizeRollbarPayload(request);
34 |
35 | throw new Error('boooo');
^
error: boooo
at /Users/egoldstein/code/babbel/get.apigateway.lambda/src/index.mts:35:9
at lambdaHandler (/Users/egoldstein/code/babbel/get.apigateway.lambda/src/index.mts:32:30)
at /Users/egoldstein/code/babbel/get.apigateway.lambda/node_modules/@mangs/bun-utils/src/networkUtils.mts:201:20
at /Users/egoldstein/code/babbel/get.apigateway.lambda/node_modules/@mangs/bun-utils/src/networkUtils.mts:190:48
at /Users/egoldstein/code/babbel/get.apigateway.lambda/node_modules/@mangs/bun-utils/src/timeUtils.mts:100:29
at measureElapsedTime (/Users/egoldstein/code/babbel/get.apigateway.lambda/node_modules/@mangs/bun-utils/src/timeUtils.mts:98:38)
at /Users/egoldstein/code/babbel/get.apigateway.lambda/node_modules/@mangs/bun-utils/src/networkUtils.mts:190:17
at fetch (/Users/egoldstein/code/babbel/get.apigateway.lambda/node_modules/@mangs/bun-utils/src/networkUtils.mts:186
The bundled app stack trace should look the same.
What do you see instead?
1 | // @bun
2 | import{d as j} from"./index.8b306d478767a477.mjs";import"./index.04c119a3beb16a35.mjs";import{m as W,q as F,r as K,t as _} from"./index.cc647d1f6d9b8e22.mjs";var{dns:x}=globalThis.Bun;var{Glob:w}=globalThis.Bun;var A=["ALL","DELETE","GET","HEAD","OPTIONS","PATCH","POST","PUT"];class B{constructor(Q=!0){this.#Y=[],this.#Z=Q}#Y;#Z;async handleRequest(Q){const Y=performance.now(),{method:Z}=Q,{pathname:$}=new URL(Q.url);for(let[X,[O,z]]of this.#Y){if(X!=="ALL"&&Z!==X)continue;if(new w(O).match($)){if(typeof z==="function"){if(this.#Z)Q.headers.append(...j("routeSync",Y));return z(Q)}const[D]=Object.entries(z);if(!D)throw new TypeError("No lazy-loaded configuration option provided");const[G,k]=D,C=(await k())[G];if(typeof C==="function"){if(this.#Z)Q.headers.append(...j("routeAsync",Y));return C(Q)}throw new TypeError(`Lazy-loaded route handler target "${G}" was not a function`)}}throw new Error("No routes matched!")}#Q(Q,Y,Z){if(!A.includes(Z))throw new TypeError(`"${Z}" is not a valid HTTP method`);return this. | ... truncated
error: boooo
at /Users/egoldstein/code/babbel/get.apigateway.lambda/dist/index.mjs:2:7221
at f (/Users/egoldstein/code/babbel/get.apigateway.lambda/dist/index.mjs:2:7512)
at /Users/egoldstein/code/babbel/get.apigateway.lambda/node_modules/@mangs/bun-utils/src/networkUtils.mts:201:20
at /Users/egoldstein/code/babbel/get.apigateway.lambda/node_modules/@mangs/bun-utils/src/networkUtils.mts:190:48
at /Users/egoldstein/code/babbel/get.apigateway.lambda/node_modules/@mangs/bun-utils/src/timeUtils.mts:100:29
at measureElapsedTime (/Users/egoldstein/code/babbel/get.apigateway.lambda/node_modules/@mangs/bun-utils/src/timeUtils.mts:98:38)
at /Users/egoldstein/code/babbel/get.apigateway.lambda/node_modules/@mangs/bun-utils/src/networkUtils.mts:190:17
at fetch (/Users/egoldstein/code/babbel/get.apigateway.lambda/node_modules/@mangs/bun-utils/src/networkUtils.mts:186
Additional information
I've been working through this with @paperdave and we've tracked this down to potentially being caused by a null byte being inserted into .map file(s). Could be more than that, but that's where we've gotten so far.
the solution for this issue should be to print warn when sourcemap loading fails. and then the second issue #11279 will be about actually fixing the invalid sourcemaps.
What version of Bun is running?
1.1.9+bb13798d9
What platform is your computer?
Darwin 23.4.0 arm64 arm
What steps can reproduce the bug?
Bun.build
and the following build configuration:What is the expected behavior?
If I run the same code with a manually thrown error but point to the typescript files directly instead of using pre-bundled ones, I get the following stack trace:
The bundled app stack trace should look the same.
What do you see instead?
Additional information
I've been working through this with @paperdave and we've tracked this down to potentially being caused by a null byte being inserted into
.map
file(s). Could be more than that, but that's where we've gotten so far.I used the esbuild sourcemap visualizer to figure that out. Thanks Dave for the suggestion.
The visualizer gives the following error when trying to examine the entrypoint code and its sourcemap:
The null byte at line 11 column 28 from the source map file looks like this in VSCode:
![Screenshot_2024-05-22_at_11 12 04_AM](https://private-user-images.githubusercontent.com/3359116/332954577-b232225a-3e50-4bb7-8c5d-d7ae198a531b.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MTg5MDk1OTcsIm5iZiI6MTcxODkwOTI5NywicGF0aCI6Ii8zMzU5MTE2LzMzMjk1NDU3Ny1iMjMyMjI1YS0zZTUwLTRiYjctOGM1ZC1kN2FlMTk4YTUzMWIucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI0MDYyMCUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNDA2MjBUMTg0ODE3WiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9MDk3YmYwZDg4NzIyNzRiOGJkZDc3NTg5N2VkZDg2YzJjY2FlYjAyYzZmM2VjMjkxMWRhMjc4MWMwMDBlNDZlZSZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QmYWN0b3JfaWQ9MCZrZXlfaWQ9MCZyZXBvX2lkPTAifQ.UCQOO0jP2dvBpWj9rCp6vFzYR9O5i-3UHme79_WQdPc)
The text was updated successfully, but these errors were encountered: