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

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

Open
hyrious opened this issue Aug 10, 2024 · 2 comments
Labels
buffer Issues and PRs related to the buffer subsystem. regression Issues related to regressions. v20.x v20.x Issues that can be reproduced on v20.x or PRs targeting the v20.x-staging branch.

Comments

@hyrious
Copy link

hyrious commented Aug 10, 2024

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.

@jakecastelli
Copy link
Member

Thanks for the report, this has been fixed on the v22.5 in this PR but has not been backported into v20.x release line, it possibly will be fixed in the next release in v20.x.

@RedYetiDev
Copy link
Member

I've added LTS watch labels to the PR for backporting, feel free to undone.

@RedYetiDev RedYetiDev added the v20.x v20.x Issues that can be reproduced on v20.x or PRs targeting the v20.x-staging branch. label Aug 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
buffer Issues and PRs related to the buffer subsystem. regression Issues related to regressions. v20.x v20.x Issues that can be reproduced on v20.x or PRs targeting the v20.x-staging branch.
Projects
None yet
Development

No branches or pull requests

3 participants