From 31f96175d6ebb90204e34634c18b74c4814c17e1 Mon Sep 17 00:00:00 2001 From: l1shen Date: Tue, 12 Dec 2023 16:17:36 +0800 Subject: [PATCH] feat: add timeout option (#35) --- package.json | 2 +- src/darwin.ts | 3 ++- src/type.ts | 1 + 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index ea374e8..ea45719 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@oomol-lab/ovm", - "version": "0.2.0", + "version": "0.2.1", "description": "oomol virtual machine", "main": "src/index.ts", "module": "src/index.ts", diff --git a/src/darwin.ts b/src/darwin.ts index cbfb61c..b3dcb64 100644 --- a/src/darwin.ts +++ b/src/darwin.ts @@ -366,10 +366,11 @@ export class DarwinOVM { const cmd = [mount, authorizedKeys, ready, tz].join(";"); return new Promise((resolve, reject) => { + const timeout = this.options.timeout ?? 1000 * 20; const id = setTimeout(() => { server.close(); reject(new Error("ignition timeout")); - }, 1000 * 10); + }, timeout); const server = net.createServer((conn) => { clearTimeout(id); diff --git a/src/type.ts b/src/type.ts index ce594ce..df318dc 100644 --- a/src/type.ts +++ b/src/type.ts @@ -11,6 +11,7 @@ export interface OVMDarwinOptions { logDir: string; sshKeyDir: string; versions: OVMDarwinOptions["originPath"] + timeout?: number; } export interface OVMEventData {