MCPcopy Index your code
hub / github.com/nodejs/node / wrapMessage

Function wrapMessage

lib/internal/modules/esm/worker.js:109–133  ·  view source on GitHub ↗

* 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)

Source from the content-addressed store, hash-verified

107 * @returns {{status: string, body: any}}
108 */
109function 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.

Callers 2

customizedModuleWorkerFunction · 0.85
handleMessageFunction · 0.85

Calls 2

requireFunction · 0.50
serializeErrorFunction · 0.50

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…