From 0cb888e59b29618de9f9440f9b5e6fb71e8a7486 Mon Sep 17 00:00:00 2001 From: Ryan Lee Date: Wed, 22 Mar 2023 17:04:48 -0400 Subject: [PATCH 1/3] fix: run bin abort signal --- providers/frame/FrameBinProvider.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/providers/frame/FrameBinProvider.ts b/providers/frame/FrameBinProvider.ts index 46c6c7648..eaae9f36f 100644 --- a/providers/frame/FrameBinProvider.ts +++ b/providers/frame/FrameBinProvider.ts @@ -43,10 +43,10 @@ export abstract class FrameBinProvider extends FrameProxyProvider { args, stdout: "piped", stderr: "piped", + signal: this.env.signal, }) - const process = command.spawn() - this.env.signal.addEventListener("abort", () => process.kill("SIGINT")) - return process + + return command.spawn() } binValid?: Promise From 9eaa586a3c9deadd2a164b29835c952bac4b419d Mon Sep 17 00:00:00 2001 From: Ryan Lee Date: Wed, 22 Mar 2023 17:38:33 -0400 Subject: [PATCH 2/3] fix: add abort signal to other deno commands --- main.ts | 2 +- providers/frame/FrameBinProvider.ts | 1 + providers/frame/common.ts | 3 +++ 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/main.ts b/main.ts index c495e2d0b..70f745193 100644 --- a/main.ts +++ b/main.ts @@ -72,7 +72,7 @@ if (!running) { async function onReady() { const [bin, ...args] = cmd if (bin) { - const command = new Deno.Command(bin, { args }) + const command = new Deno.Command(bin, { args, signal }) const status = await command.spawn().status self.addEventListener("unload", () => Deno.exit(status.code)) controller.abort() diff --git a/providers/frame/FrameBinProvider.ts b/providers/frame/FrameBinProvider.ts index eaae9f36f..9800aa3bd 100644 --- a/providers/frame/FrameBinProvider.ts +++ b/providers/frame/FrameBinProvider.ts @@ -55,6 +55,7 @@ export abstract class FrameBinProvider extends FrameProxyProvider { const whichProcess = new Deno.Command("which", { args: [this.bin], stdout: "piped", + signal: this.env.signal, }) const { stdout } = await whichProcess.output() if (!stdout.length) { diff --git a/providers/frame/common.ts b/providers/frame/common.ts index f0969306b..7b8daa805 100644 --- a/providers/frame/common.ts +++ b/providers/frame/common.ts @@ -13,9 +13,11 @@ export async function createCustomChainSpec( bin: string, chain: string, networkPrefix: number, + signal: AbortSignal, ): Promise { const buildSpecCmd = new Deno.Command(bin, { args: ["build-spec", "--disable-default-bootnode", "--chain", chain], + signal, }) const chainSpec = JSON.parse(new TextDecoder().decode((await buildSpecCmd.output()).stdout)) const balances: [string, number][] = chainSpec.genesis.runtime.balances.balances @@ -32,6 +34,7 @@ export async function createCustomChainSpec( await Deno.writeTextFile(customChainSpecPath, JSON.stringify(chainSpec, undefined, 2)) const buildSpecRawCmd = new Deno.Command(bin, { args: ["build-spec", "--disable-default-bootnode", "--chain", customChainSpecPath, "--raw"], + signal, }) const chainSpecRaw = JSON.parse(new TextDecoder().decode((await buildSpecRawCmd.output()).stdout)) const customChainSpecRawPath = await Deno.makeTempFile({ From e32ead85e9a6bfd7488e31cdc6ecf768050db7d7 Mon Sep 17 00:00:00 2001 From: Ryan Lee Date: Wed, 22 Mar 2023 17:54:45 -0400 Subject: [PATCH 3/3] fix: compile errors --- providers/frame/contracts_dev.ts | 2 +- providers/frame/polkadot_dev.ts | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/providers/frame/contracts_dev.ts b/providers/frame/contracts_dev.ts index e26d922fa..ed21f0638 100644 --- a/providers/frame/contracts_dev.ts +++ b/providers/frame/contracts_dev.ts @@ -27,7 +27,7 @@ export class ContractsDevProvider extends FrameBinProvider { async launch() { const port = getAvailable() - const chainSpec = await createCustomChainSpec(this.bin, "dev", 42) + const chainSpec = await createCustomChainSpec(this.bin, "dev", 42, this.env.signal) await this.runBin(["--tmp", "--alice", "--ws-port", port.toString(), "--chain", chainSpec]) return port } diff --git a/providers/frame/polkadot_dev.ts b/providers/frame/polkadot_dev.ts index f6752739b..98345e854 100644 --- a/providers/frame/polkadot_dev.ts +++ b/providers/frame/polkadot_dev.ts @@ -42,6 +42,7 @@ export class PolkadotDevProvider extends FrameBinProvider { this.bin, `${runtimeName}-dev`, DEV_RUNTIME_PREFIXES[runtimeName], + this.env.signal, ) const args: string[] = ["--tmp", "--alice", "--ws-port", port.toString(), "--chain", chainSpec] await this.runBin(args)