nodejs-docs-samples icon indicating copy to clipboard operation
nodejs-docs-samples copied to clipboard

source map support?

Open npomfret opened this issue 2 years ago • 4 comments

Is it possible to have functions use a source map (like index.js.map) so that line number in stack traces make more sense when using TypeScript?

npomfret avatar Aug 15 '23 12:08 npomfret

I believe all that is needed is to request sourcemaps in your tsconfig.json like so:

"compilerOptions": {
    "sourceMap": true
  }

Does that address your issue, or are the sourcemaps still not being respected?

muncus avatar Aug 16 '23 21:08 muncus

Sorry I wasn't clear. Yes, the above does not work. Source maps are generated of course, but line numbers in the stack traces for errors don't match up to the original typescript code.

npomfret avatar Aug 17 '23 08:08 npomfret

Thanks for clarifying! Can you tell me a bit more about your situation, so we can reproduce this issue?

Does it happen locally when running with the functions-framework CLI, or just when deploying to GCF? Are you using the gen1 or gen2 runtime environment in GCF?

I'll continue investigating, but the more information you can provide, the better. Thanks!

muncus avatar Aug 17 '23 15:08 muncus

Just deploy a typescript function that simply throws an error. Look at the line numbers of that error in the google logs. The line numbers are wrong, they don't match the typescript code - they match the generated JS code. I don't think you need an example, the write a basic http trigger function with throw new Error() as the body

npomfret avatar Aug 17 '23 19:08 npomfret

@npomfret Thanks and will be taking this into consideration in our planning. Closing out as this does not indicate a sample error or issue and that there is a path for debugging through the generated js sample code (from the ts sample).

pattishin avatar Mar 08 '24 05:03 pattishin