Skip to content

Commit 23c2f53

Browse files
committed
fix: prevent unhandled promise rejection when done() throws
Add .catch(safeReject) to pendingDones promises so that errors from done() (e.g. invalid output schema) are caught instead of becoming unhandled promise rejections that crash the process. In develop, these errors are caught by the worker message handler's try/catch → reject(). With pendingDones pattern, the promise could reject after the exit handler already resolved, causing a crash. Signed-off-by: NikolayZezin-envision <nikolay.zezin@envisionblockchain.com>
1 parent 796b96b commit 23c2f53

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

policy-service/src/policy-engine/blocks/custom-logic-block.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,7 @@ export class CustomLogicBlock {
305305
const pendingDones: Promise<void>[] = [];
306306
await runPythonInDocker(pythonWorkerData, {
307307
onDone: (result, final) => {
308-
pendingDones.push(done(result, final));
308+
pendingDones.push(done(result, final).catch(safeReject));
309309
},
310310
onDebug: (result) => {
311311
ref.debug(result);
@@ -362,7 +362,7 @@ export class CustomLogicBlock {
362362
}
363363
try {
364364
if (data?.type === 'done') {
365-
pendingDones.push(done(data.result, data.final));
365+
pendingDones.push(done(data.result, data.final).catch(safeReject));
366366
}
367367
if (data?.type === 'debug') {
368368
ref.debug(data.result);

0 commit comments

Comments
 (0)