child_process: ensure message sanity at send source
Error messages coming out of de-serialization at the send target is not consumable. So detect the scenario and fix it at the send source.
Ref: https://github.com/nodejs/node/issues/20314
existing error message (sample code in the linked issue):
SUBPROCESS error: SyntaxError: Unexpected token u in JSON at position 0
at JSON.parse (<anonymous>)
at Pipe.channel.onread (internal/child_process.js:492:28)
with this change:
PARENT error: TypeError [ERR_INVALID_ARG_TYPE]: The "message" argument must be of type serializable objects. Received type symbol
at ChildProcess.target._send (internal/child_process.js:664:13)
at ChildProcess.target.send (internal/child_process.js:641:19)
at Object.<anonymous> (/home/gireesh/node/parent.js:6:14)
at Module._compile (internal/modules/cjs/loader.js:723:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:734:10)
at Module.load (internal/modules/cjs/loader.js:620:32)
at tryModuleLoad (internal/modules/cjs/loader.js:560:12)
at Function.Module._load (internal/modules/cjs/loader.js:552:3)
at Function.Module.runMain (internal/modules/cjs/loader.js:776:12)
at executeUserCode (internal/bootstrap/node.js:343:17)
/cc @vsemozhetbyt @joyeecheung @nodejs/child_process
Checklist
-
make -j4 test
(UNIX), orvcbuild test
(Windows) passes -
tests and/or benchmarks are included -
documentation is changed or added -
commit message follows commit guidelines