Skip to content

--enable-source-maps does not appear to show function names with webpack sourcemaps #35325

Description

@michael-wolfenden
  • Version: v12.13.0
  • Platform: Windows 10 64-bit
  • Subsystem: sourcemaps

What steps will reproduce the bug?

Here is a complete, minimal reproduction
https://github.com/michael-wolfenden/node-sourcemap-repro

How often does it reproduce? Is there a required condition?

Always.

What is the expected behavior?

I would expect to see the real function names in the output.

Using the source-map-support package, the stack trace looks like:

> node ./dist/main.js

D:\github\node-sourcemap-repro\dist\webpack:\index-source-map-support.js:16
  throw new Error('Roh Ruh')
        ^
Error: Roh Ruh
    at functionD (D:\github\node-sourcemap-repro\dist\webpack:\index-source-map-support.js:16:9)
    at functionC (D:\github\node-sourcemap-repro\dist\webpack:\index-source-map-support.js:12:3)
    at functionB (D:\github\node-sourcemap-repro\dist\webpack:\index-source-map-support.js:8:3)
    at Object.call (D:\github\node-sourcemap-repro\dist\webpack:\index-source-map-support.js:4:3)
    at __webpack_require__ (D:\github\node-sourcemap-repro\dist\webpack:\webpack\bootstrap:19:22)
    at D:\github\node-sourcemap-repro\dist\webpack:\webpack\bootstrap:83:10
    at Object.<anonymous> (D:\github\node-sourcemap-repro\dist\main.js:1:911)
    at Module._compile (internal/modules/cjs/loader.js:956:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:973:10)
    at Module.load (internal/modules/cjs/loader.js:812:32)

What do you see instead?

Using the --enable-source-maps flag, the stack trace looks like:

> node --enable-source-maps ./dist/main.js

Error: Roh Ruh
    at o (D:\github\node-sourcemap-repro\dist\main.js:1:970)
        -> D:\github\node-sourcemap-repro\dist\webpack:\index.js:14:9
    at n (D:\github\node-sourcemap-repro\dist\main.js:1:952)
        -> D:\github\node-sourcemap-repro\dist\webpack:\index.js:10:3
    at r (D:\github\node-sourcemap-repro\dist\main.js:1:940)
        -> D:\github\node-sourcemap-repro\dist\webpack:\index.js:6:3
    at Object.<anonymous> (D:\github\node-sourcemap-repro\dist\main.js:1:992)
        -> D:\github\node-sourcemap-repro\dist\webpack:\index.js:2:3
    at r (D:\github\node-sourcemap-repro\dist\main.js:1:110)
        -> D:\github\node-sourcemap-repro\dist\webpack:\webpack\bootstrap:19:22
    at D:\github\node-sourcemap-repro\dist\main.js:1:902
        -> D:\github\node-sourcemap-repro\dist\webpack:\webpack\bootstrap:83:10
    at Object.<anonymous> (D:\github\node-sourcemap-repro\dist\main.js:1:911)
    at Module._compile (internal/modules/cjs/loader.js:956:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:973:10)        
    at Module.load (internal/modules/cjs/loader.js:812:32)

Activity

  1. added
    source mapsIssues and PRs related to source map support.
    on Sep 26, 2020
  2. self-assigned this
    on Oct 29, 2020
  3. bcoe commented on Oct 30, 2020

    @bcoe
    Contributor

    @michael-wolfenden I'm wondering if you have any recommendations on how we should display the original function name?

    The approach we've taken is to provide information about bot the call site with the error and the original call site, I'm wondering how we'd represent an alternate function name.

  4. bcoe commented on Oct 31, 2020

    @bcoe
    Contributor

    @michael-wolfenden what do you think of this?

    Error: oh no!
        at o (/Users/bencoe/oss/node-1/test/fixtures/source-map/webpack.js:1:970)
            -> [functionA] webpack:///./webpack.js:14:9
        at n (/Users/bencoe/oss/node-1/test/fixtures/source-map/webpack.js:1:952)
            -> [functionB] webpack:///./webpack.js:10:3
    
  5. michael-wolfenden commented on Oct 31, 2020

    @michael-wolfenden
    Author

    I would expect the output to look something like the output that source-map-support generates

    > node ./dist/main.js
    
    D:\github\node-sourcemap-repro\dist\webpack:\index-source-map-support.js:16
      throw new Error('Roh Ruh')
            ^
    Error: Roh Ruh
        at functionD (D:\github\node-sourcemap-repro\dist\webpack:\index-source-map-support.js:16:9)
        at functionC (D:\github\node-sourcemap-repro\dist\webpack:\index-source-map-support.js:12:3)
        at functionB (D:\github\node-sourcemap-repro\dist\webpack:\index-source-map-support.js:8:3)
        at Object.call (D:\github\node-sourcemap-repro\dist\webpack:\index-source-map-support.js:4:3)
        at __webpack_require__ (D:\github\node-sourcemap-repro\dist\webpack:\webpack\bootstrap:19:22)
        at D:\github\node-sourcemap-repro\dist\webpack:\webpack\bootstrap:83:10
        at Object.<anonymous> (D:\github\node-sourcemap-repro\dist\main.js:1:911)
        at Module._compile (internal/modules/cjs/loader.js:956:30)
        at Object.Module._extensions..js (internal/modules/cjs/loader.js:973:10)
        at Module.load (internal/modules/cjs/loader.js:812:32)
    
  6. bcoe commented on Oct 31, 2020

    @bcoe
    Contributor

    @michael-wolfenden we've opted to include both the call site where the error happened, and the original call site in our implementation of applying source maps to stack traces in Node.js.

    This is useful because sometimes you do want to look at the actual location where the error was thrown, i.e.,

    at o (/Users/bencoe/oss/node-1/test/fixtures/source-map/webpack.js:1:970)

    ☝️ especially when using a minifier there can be bugs that only crop up in the minified code, e.g., a collision on symbol names.


    I'd like to figure out a way to provide the original function name for you, without hiding the actual function name that executed.

  7. michael-wolfenden commented on Oct 31, 2020

    @michael-wolfenden
    Author

    Ah gotcha ... In that case, your suggestion looks good 👍

  8. added a commit that references this issue on Nov 27, 2020
  9. added a commit that references this issue on May 16, 2021
  10. added a commit that references this issue on Jun 11, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

source mapsIssues and PRs related to source map support.

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions