* Wraps a message with a status and body, and serializes the body if necessary. * @param {string} status - The status of the message. * @param {any} body - The body of the message. * @returns {{status: string, body: any}}
(status, body)
| 107 | * @returns {{status: string, body: any}} |
| 108 | */ |
| 109 | function wrapMessage(status, body) { |
| 110 | if (status === 'success' || body === null || |
| 111 | (typeof body !== 'object' && |
| 112 | typeof body !== 'function' && |
| 113 | typeof body !== 'symbol')) { |
| 114 | return { status, body }; |
| 115 | } |
| 116 | |
| 117 | let serialized; |
| 118 | let serializationFailed; |
| 119 | try { |
| 120 | const { serializeError } = require('internal/error_serdes'); |
| 121 | serialized = serializeError(body); |
| 122 | } catch { |
| 123 | serializationFailed = true; |
| 124 | } |
| 125 | |
| 126 | return { |
| 127 | status, |
| 128 | body: { |
| 129 | serialized, |
| 130 | serializationFailed, |
| 131 | }, |
| 132 | }; |
| 133 | } |
| 134 | |
| 135 | /** |
| 136 | * Initializes the loader hooks worker thread with customized asynchronous module loading hooks. |
no test coverage detected
searching dependent graphs…