Skip to content

Buffer() deprecation check throws TypeError: Cannot read properties of null (reading '0') inside new Promise() #54296

Closed
@hyrious

Description

@hyrious

Version

First seen in v20.15; No issue in v20.14

Platform

Microsoft Windows NT 10.0.19045.0 x64

Subsystem

No response

What steps will reproduce the bug?

Just create a file and run:

new Promise(() => {
  new Buffer(0)
})

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

It requires Node.js ≥ v20.15. Node.js v20.14 is working fine.

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

It should not throw.

What do you see instead?

node:internal/util:508
        filename[0] !== '/' &&
                ^

TypeError: Cannot read properties of null (reading '0')
    at isInsideNodeModules (node:internal/util:508:17)
    at showFlaggedDeprecation (node:buffer:178:8)
    at new Buffer (node:buffer:266:3)
    at file:///Users/hyrious/test.js:5:3
    at new Promise (<anonymous>)
    at file:///Users/hyrious/test.js:4:1
    at ModuleJob.run (node:internal/modules/esm/module_job:222:25)
    at async ModuleLoader.import (node:internal/modules/esm/loader:316:24)
    at async asyncRunEntryPointWithESMLoader (node:internal/modules/run_main:123:5)

Additional information

The error occurs only when inside the callback of new Promise(). I looked at devtools and it says one item inside the stack has getFileName()null.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bufferIssues and PRs related to the buffer subsystem.regressionIssues related to regressions.v20.xIssues that can be reproduced on v20.x or PRs targeting the v20.x-staging branch.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions