Source map in worker does’t work
I made a hono backend and log the error and stack somewhere in the code.
set upload_source_maps = true in the wrangler.toml and run wrangler deploy
call the API to trigger the error and stack log
You will see the stack trace doesn’t have original file location, but instead it has the bundled js file code location.
How to get the source map to work in worker?
2 Replies
{
"message": [
"{"time":"2024-09-26T10:36:41.684Z","level":"ERROR","type":"Error","msg":"TEST ERROR","stack":"Error: test error\n at getUsers2 (index.js:39683:19)\n at async dispatch (index.js:11165:17)\n at async cors2 (index.js:12082:5)\n at async dispatch (index.js:11165:17)\n at async index.js:10475:5\n at async dispatch (index.js:11165:17)\n at async dispatch (index.js:11165:17)\n at async index.js:11389:25"}"
],
"level": "log",
"timestamp": 1727347001684
}
This is the log message worker emitted.
but expected to see something like
which is what I got locally with
wrangler dev
run npx wrangler deploy --dry-run --outdir dist
I can get the index.js and index.js.map file.
also made a post here https://community.cloudflare.com/t/source-map-in-worker-doest-work/717053that looks like a manual error log based on a time being there and level: ERROR
I don't think it will remap non-default error logs