(result: unknown)
| 94 | process.on('message', messageListener); |
| 95 | |
| 96 | function reportSuccess(result: unknown) { |
| 97 | if (!process || !process.send) { |
| 98 | throw new Error('Child can only be used on a forked process'); |
| 99 | } |
| 100 | |
| 101 | try { |
| 102 | process.send([PARENT_MESSAGE_OK, result]); |
| 103 | } catch (error) { |
| 104 | if ( |
| 105 | isError(error) && |
| 106 | // if .send is a function, it's a serialization issue |
| 107 | !error.message.includes('.send is not a function') |
| 108 | ) { |
| 109 | // Apply specific serialization only in error cases |
| 110 | // to avoid affecting performance in regular cases. |
| 111 | process.send([PARENT_MESSAGE_OK, packMessage(result)]); |
| 112 | } else { |
| 113 | throw error; |
| 114 | } |
| 115 | } |
| 116 | } |
| 117 | |
| 118 | function reportClientError(error: Error) { |
| 119 | return reportError(error, PARENT_MESSAGE_CLIENT_ERROR); |
no test coverage detected