Skip to content

util: callbackify throws when function length or name property is deleted #67745

Backlog

Description

@outslept

Version

v26.13.0

Platform

Microsoft Windows NT 10.0.19045.0 x64

Subsystem

util

What steps will reproduce the bug?

node -e "async function fn() {} delete fn.length; util.callbackify(fn)"
// deleting fn.name throws as well

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

always

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

util.callbackify(fn) should return the callbackified function without throwing (util.promisify does the same already)

What do you see instead?

node:util:422
  if (typeof descriptors.length.value === 'number') {
                                ^

TypeError: Cannot read properties of undefined (reading 'value')
    at Object.callbackify (node:util:422:33)
    at [eval]:1:47
    at runScriptInThisContext (node:internal/vm:219:10)
    at node:internal/process/execution:485:12
    at [eval]-wrapper:6:24
    at runScriptInContext (node:internal/process/execution:483:60)
    at evalFunction (node:internal/process/execution:317:30)
    at evalTypeScript (node:internal/process/execution:329:3)
    at node:internal/main/eval_string:71:3

Additional information

No response

Activity

  1. bunnysayzz commented on Nov 24, 2026

    @bunnysayzz

    traced it. callbackify copies the original's property descriptors, then reads descriptors.length.value and descriptors.name.value without checking they exist. delete the length or name first and Object.getOwnPropertyDescriptors omits the property, so the read throws before the callbackified function is even returned. promisify already tolerates the same manipulation.

    fix is up in #67754: guard both reads so a deleted property is just skipped, plus a regression test that fails on the old code and passes with the fix.

  2. added
    util
    on Nov 24, 2026
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

    util

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions