Skip to content

Modified object is returned on next query even when not stored persistently #8

@konacurrents

Description

@konacurrents

I posted to the node-red forum about an issue I'm having with persistence.

Basically, after a dataOut retrieval, the msg.payload contains the JSON data. I then modify a parameter, such as msg.payload.password, to return the query to the user (but with the password blanked out). This payload is NOT stored.

The next dataIn retrieval for the same query returns the modified in-memory version, instead of going to the values stored in the persistent file.

I found that RED.util.cloneMessage(msg.payload) makes a copy and I can modify that to send on in my flow.

msg.payload = RED.util.cloneMessage(msg.payload);
msg.payload.password = "";
msg.payload.guestPassword = "";

Without the clone message, the next retrieval has a JSON object with an empty password.

For me this wasn't obvious.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions