Skip to content

proxied Error instances return an undefined stack #60862

Description

@eps1lon

Version

24.11.1

Platform

Darwin Mac.fritz.box 24.6.0 Darwin Kernel Version 24.6.0: Mon Jul 14 11:28:30 PDT 2025; root:xnu-11417.140.69~1/RELEASE_ARM64_T6030 arm64

Subsystem

No response

What steps will reproduce the bug?

console.log(
  new Proxy(new Error(), {
    get(target, key, receiver) {
      // Need to return `target.stack` instead of `Reflect.get` starting with Node.js v21.0.0
      // when trying to get the `stack`.
      return Reflect.get(target, key, receiver);
    },
  }).stack
);

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

always

What is the expected behavior? Why is that the expected behavior?

A stacktrace is logged. Reflect.get is supposed to be equivalent to target[propertyKey]

What do you see instead?

undefined is logged.

Additional information

Started with Node.js v21.0.0. Once I return target.stack from the Proxy getter, a stack is returned as usual. Reflect.get(error, 'stack', receiver) just doesn't work. Though it does work with Reflect.get(error, 'stack')

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions