From 0c0eb021ec4ed9e5cbfc081083a16b45f1399df4 Mon Sep 17 00:00:00 2001 From: nicktrn <55853254+nicktrn@users.noreply.github.com> Date: Wed, 8 May 2024 12:57:28 +0100 Subject: [PATCH] improve handling of ipc timeouts --- .../core/src/v3/runtime/prodRuntimeManager.ts | 36 +++++++++++++------ 1 file changed, 25 insertions(+), 11 deletions(-) diff --git a/packages/core/src/v3/runtime/prodRuntimeManager.ts b/packages/core/src/v3/runtime/prodRuntimeManager.ts index 02a3c8c78..3aa420409 100644 --- a/packages/core/src/v3/runtime/prodRuntimeManager.ts +++ b/packages/core/src/v3/runtime/prodRuntimeManager.ts @@ -55,10 +55,14 @@ export class ProdRuntimeManager implements RuntimeManager { this._waitForDuration = { resolve, reject }; }); - const { willCheckpointAndRestore } = await this.ipc.sendWithAck("WAIT_FOR_DURATION", { - ms, - now, - }); + const { willCheckpointAndRestore } = await this.ipc.sendWithAck( + "WAIT_FOR_DURATION", + { + ms, + now, + }, + 10_000 + ); if (!willCheckpointAndRestore) { await internalTimeout; @@ -74,14 +78,24 @@ export class ProdRuntimeManager implements RuntimeManager { // Resets the clock to the current time clock.reset(); - // The coordinator should cancel any in-progress checkpoints - const { checkpointCanceled, version } = await this.ipc.sendWithAck("CANCEL_CHECKPOINT", { - version: "v2", - reason: "WAIT_FOR_DURATION", - }); + try { + // The coordinator should cancel any in-progress checkpoints + const { checkpointCanceled, version } = await this.ipc.sendWithAck( + "CANCEL_CHECKPOINT", + { + version: "v2", + reason: "WAIT_FOR_DURATION", + }, + 10_000 + ); - if (checkpointCanceled) { - // There won't be a checkpoint or external resume and we've already completed our internal timeout + if (checkpointCanceled) { + // There won't be a checkpoint or external resume and we've already completed our internal timeout + return; + } + } catch (error) { + // If the cancellation times out, we will proceed as if the checkpoint was canceled + logger.debug("Checkpoint cancellation timed out", { error }); return; }