Skip to content

Assigning a value to Array.prototype[1] will result in an error :node:internal/process/task_queues:77 callback(); #54472

@LoongZP

Description

@LoongZP

Version

v20.14.0

Platform

Microsoft Windows NT 10.0.22631.0
x64

Subsystem

No response

What steps will reproduce the bug?

code:
Array.prototype[1] = 2
console.log(Array.prototype);

result:
image

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

When I knew that Array.prototype was an Array, I tried to assign a value to Array.prototype[x].
Assigning only Array.prototype[1] results in an error that will occur when reading Array.prototype.

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

In Chrome, you will get the following results:

Array.prototype[1] = 2
console.log(Array.prototype);

result:
[1: 2, at: ƒ, concat: ƒ, copyWithin: ƒ, fill: ƒ, find: ƒ, …]

image

What do you see instead?

code:
Array.prototype[1] = 2
console.log(Array.prototype);

result:
Object(2) [ <1 empty item>, 2 ]
node:internal/process/task_queues:77
callback();
^
TypeError: callback is not a function
at process.processTicksAndRejections (node:internal/process/task_queues:77:11)

Node.js v20.14.0

image

Additional information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    async_hooksIssues and PRs related to the async hooks subsystem.confirmed-bugIssues with confirmed bugs.processIssues and PRs related to the process subsystem.

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions