-
Notifications
You must be signed in to change notification settings - Fork 29.7k
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
Source maps not supported in eval
and new Function
#43047
Comments
/cc @bcoe This is how it looks like in Edge: |
Support for I would be interested to know how v8 approaches this problem. |
V8 allows hooking into |
@legendecas awesome, will be excited to see this patch. |
As mentioned in #43428, the line number in |
Dynamic sources with FunctionConstructor is not supported yet as V8 prepends lines to the sources which makes the stack line number incorrect. PR-URL: nodejs/node#43428 Refs: nodejs/node#43047 Reviewed-By: Ben Coe <bencoe@gmail.com>
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
According to step 12 of https://tc39.es/ecma262/#sec-createdynamicfunction, the |
Version
v18.0.0
Platform
Microsoft Windows NT 10.0.19044.0 x64
Subsystem
No response
What steps will reproduce the bug?
eval
node --enable-source-maps example.js
whereexample.js
the following file:new Function
node --enable-source-maps example.js
whereexample.js
the following file: (only the last line differs from the previous example)Source
This example was generated from a one-line
simple.coffee
—throw new Error 'hello'
— viacoffee -M -c simple.coffee
. I replaced//#
with a string interpolation so the source map isn't applied toexample.js
itself.How often does it reproduce? Is there a required condition?
Always
What is the expected behavior?
eval
This produces the following stack trace:
The line numbers for
simple.coffee
(lines 3 and 5) are incorrect (both should be line 1).new Function
This produces the following stack trace:
The line numbers for
simple.coffee
(lines 5 and 7) are incorrect (both should be line 1), and different from theeval
case.What do you see instead?
I expect everything to refer to line 1 of
simple.coffee
, as that's the only line.Running
npm install coffeescript
andcoffee simple.coffee
, wheresimple.coffee
is the following file:produces the correct line numbers (via a specialized mapping implemented by CoffeeScript, I believe):
Additional information
The source map spec explicitly mentions code "being evaluated as a string with the
eval()
function or vianew Function()
" so I assume this is supposed to work.The text was updated successfully, but these errors were encountered: