Skip to content

structuredClone does not work on process.env #45380

Closed
@cruiseliu

Description

@cruiseliu

Version

v19.0.1

Platform

Linux x 6.0.7-arch1-1 #1 SMP PREEMPT_DYNAMIC Thu, 03 Nov 2022 18:01:58 +0000 x86_64 GNU/Linux

Subsystem

No response

What steps will reproduce the bug?

No response

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

No response

What is the expected behavior?

No response

What do you see instead?

> structuredClone(process.env)
Uncaught:
DOMException [DataCloneError]: Cannot transfer object of unsupported type.
    at new DOMException (node:internal/per_context/domexception:53:5)
    at structuredClone (node:internal/structured_clone:23:17)

Additional information

No response

Activity

bnoordhuis

bnoordhuis commented on Nov 12, 2022

@bnoordhuis
Member

I'm not sure this is fixable. If it is, it probably involves teaching WriteHostObject() in src/node_messaging.cc about process.env through a v8::ObjectTemplate::HasInstance() check.

The template is created in CreateEnvVarProxy() in src/node_env_var.cc. It should be stored on the Environment so WriteHostObject() can access it as env_->env_proxy_template().

added
c++Issues and PRs that require attention from people who are familiar with C++.
on Nov 12, 2022
MrJithil

MrJithil commented on Nov 18, 2022

@MrJithil
Member

need help on this as its involved c++

bnoordhuis

bnoordhuis commented on Dec 1, 2022

@bnoordhuis
Member

4 remaining items

Loading
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

    c++Issues and PRs that require attention from people who are familiar with C++.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Participants

    @bnoordhuis@cruiseliu@MrJithil

    Issue actions

      structuredClone does not work on process.env · Issue #45380 · nodejs/node