Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Mechanism to let nodes contribute with references that must be preserved during cloning #5881

Copy link
Copy link

Description

@HenryTJr
Issue body actions

Node authors attach a Symbol that Node-RED core uses to decided if it should keep references after cloning messages

Node-RED core or utils

export const PRESERVE_REF = Symbol.for("node-red.preserve");

In a node

import { PRESERVE_REF } from "node-red/core"; 
msg.file = {
  [PRESERVE_REF]: true,
  handle: fsHandle
}; 
send(msg);

Somewhere inside https://github.com/node-red/node-red/blob/main/packages/node_modules/%40node-red/util/lib/util.js#L98
Do something like shown below for each prop in the msg and store references before cloning and restore them after

import { PRESERVE_REF } from "../symbols"; 

function clone(msg) {
   // for each prop in msg
   if (value && typeof value === "object") {
    if (value[PRESERVE_REF]) {
      // store it by its key and delete the key
    }}
   // deep clone as today
   // for each prop in store restore refs in msg by key
  }
}

Symbol must be available to the function node scope

Reactions are currently unavailable

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    Morty Proxy This is a proxified and sanitized view of the page, visit original site.