Skip to content

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

@ColinTimBarndt

Description

@ColinTimBarndt
  • 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

Metadata

Metadata

Assignees

No one assigned

    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