0

I am calling process.send(val) with an IPC message between parent and child. The object val has some arbitrary circular references, that are hard to prune, reliably. I have a custom JSON stringify function that can handle circular refs. Is there a way to override the JSON.stringify method within process.send()?

Something like:

const serializableObj = {
  [process.send.stringify](){
      return myCustomStringify(this);
  }
}
Alexander Mills
  • 90,741
  • 139
  • 482
  • 817
  • 1
    Stringify it before sending – Konrad Nov 27 '22 at 21:22
  • 1
    If it's your code on both ends, then just send your custom JSON string that you can decode properly on the other end. Or, create a duplicate object that has only what you're trying to send in it (and no circular references) and send that safe duplicate. – jfriend00 Nov 27 '22 at 21:46

0 Answers0