Skip to content
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

--enable-source-maps throws internal TypeError when throwing non-object value #38945

Closed
ColinTimBarndt opened this issue Jun 6, 2021 · 2 comments
Labels
source maps Issues and PRs related to source map support.

Comments

@ColinTimBarndt
Copy link

  • Version: v16.2.0
  • Platform: Microsoft Windows NT 10.0.18363.0 x64
  • Subsystem: none

What steps will reproduce the bug?

Run node --enable-source-maps test.js where test.js has a SourceMap, it can be generated from this code:

// Typescript
throw "Not an error";

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

The thrown object must not be typeof "object". When the error is thrown (and uncaught), throwing the error causes an internal error that does not expose any information about the source code that originally caused it.

What is the expected behavior?

A correct stack trace should be generated either way.

What do you see instead?

TypeError: WeakRef: target must be an object
    at new WeakRef (<anonymous>)
    at new SafeWeakRef (node:internal/per_context/primordials:383:27)
    at IterableWeakMap.set (node:internal/util/iterable_weak_map:28:19)
    at rekeySourceMap (node:internal/source_map/source_map_cache:179:23)
    at Function.Module._load (node:internal/modules/cjs/loader:825:9)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:76:12)
    at node:internal/main/run_main_module:17:47
@targos
Copy link
Member

targos commented Jun 6, 2021

@bcoe

@Ayase-252 Ayase-252 added the source maps Issues and PRs related to source map support. label Jun 6, 2021
@bcoe
Copy link
Contributor

bcoe commented Jun 8, 2021

@targos @ColinTimBarndt acknowledged. We should catch and suppress this specific error.

bcoe added a commit to bcoe/node-1 that referenced this issue Jun 13, 2021
If an error is thrown before a module is loaded, we attempt to cache
source map against error object, rather than module object. We
can't do this if the error is a primitive type

Fixes nodejs#38945
@bcoe bcoe closed this as completed in c5cc3d4 Jun 22, 2021
danielleadams pushed a commit that referenced this issue Jun 22, 2021
If an error is thrown before a module is loaded, we attempt to cache
source map against error object, rather than module object. We
can't do this if the error is a primitive type

Fixes #38945

PR-URL: #39025
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: Rich Trott <[email protected]>
Reviewed-By: Michaël Zasso <[email protected]>
Reviewed-By: Antoine du Hamel <[email protected]>
richardlau pushed a commit that referenced this issue Jul 19, 2021
If an error is thrown before a module is loaded, we attempt to cache
source map against error object, rather than module object. We
can't do this if the error is a primitive type

Fixes #38945

PR-URL: #39025
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: Rich Trott <[email protected]>
Reviewed-By: Michaël Zasso <[email protected]>
Reviewed-By: Antoine du Hamel <[email protected]>
richardlau pushed a commit that referenced this issue Jul 20, 2021
If an error is thrown before a module is loaded, we attempt to cache
source map against error object, rather than module object. We
can't do this if the error is a primitive type

Fixes #38945

PR-URL: #39025
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: Rich Trott <[email protected]>
Reviewed-By: Michaël Zasso <[email protected]>
Reviewed-By: Antoine du Hamel <[email protected]>
foxxyz pushed a commit to foxxyz/node that referenced this issue Oct 18, 2021
If an error is thrown before a module is loaded, we attempt to cache
source map against error object, rather than module object. We
can't do this if the error is a primitive type

Fixes nodejs#38945

PR-URL: nodejs#39025
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: Rich Trott <[email protected]>
Reviewed-By: Michaël Zasso <[email protected]>
Reviewed-By: Antoine du Hamel <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
source maps Issues and PRs related to source map support.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants