MCPcopy
hub / github.com/jestjs/jest / reportSuccess

Function reportSuccess

packages/jest-worker/src/workers/threadChild.ts:112–135  ·  view source on GitHub ↗
(result: unknown)

Source from the content-addressed store, hash-verified

110}
111
112function reportSuccess(result: unknown) {
113 if (isMainThread) {
114 throw new Error('Child can only be used on a forked process');
115 }
116
117 try {
118 parentPort!.postMessage([PARENT_MESSAGE_OK, result]);
119 } catch (error) {
120 let resolvedError = error;
121 // Try to handle https://html.spec.whatwg.org/multipage/structured-data.html#structuredserializeinternal
122 // for `symbols` and `functions`
123 if (isDataCloneError(error)) {
124 try {
125 parentPort!.postMessage([PARENT_MESSAGE_OK, packMessage(result)]);
126 return;
127 } catch (secondTryError) {
128 resolvedError = secondTryError;
129 }
130 }
131 // Handling it here to avoid unhandled rejection
132 // which is hard to distinguish on the parent side
133 reportClientError(resolvedError as Error);
134 }
135}
136
137function reportClientError(error: Error) {
138 return reportError(error, PARENT_MESSAGE_CLIENT_ERROR);

Callers 1

messageListenerFunction · 0.70

Calls 3

isDataCloneErrorFunction · 0.90
packMessageFunction · 0.90
reportClientErrorFunction · 0.70

Tested by

no test coverage detected