Skip to content

Commit

Permalink
feat: add timeout option (#35)
Browse files Browse the repository at this point in the history
  • Loading branch information
l1shen authored Dec 12, 2023
1 parent 145537a commit 31f9617
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
3 changes: 2 additions & 1 deletion src/darwin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
1 change: 1 addition & 0 deletions src/type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export interface OVMDarwinOptions {
logDir: string;
sshKeyDir: string;
versions: OVMDarwinOptions["originPath"]
timeout?: number;
}

export interface OVMEventData {
Expand Down

0 comments on commit 31f9617

Please sign in to comment.