From 3ca78f0b5a1433da4be586f500e970db91fc2d05 Mon Sep 17 00:00:00 2001 From: Peter Smith Date: Mon, 30 Dec 2024 11:29:33 +0000 Subject: [PATCH 1/9] chore: changeset --- .changeset/thin-planes-cover.md | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 .changeset/thin-planes-cover.md diff --git a/.changeset/thin-planes-cover.md b/.changeset/thin-planes-cover.md new file mode 100644 index 00000000000..c49eb62974d --- /dev/null +++ b/.changeset/thin-planes-cover.md @@ -0,0 +1,3 @@ +--- +"create-fuels": patch +--- From b6fb9b5e1bcbb538bd540bd863e970e21bfc46dc Mon Sep 17 00:00:00 2001 From: Peter Smith Date: Mon, 30 Dec 2024 11:29:59 +0000 Subject: [PATCH 2/9] chore: release to NPM --- .github/workflows/pr-release.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pr-release.yaml b/.github/workflows/pr-release.yaml index 6eeca1f3f04..593d7fce145 100644 --- a/.github/workflows/pr-release.yaml +++ b/.github/workflows/pr-release.yaml @@ -8,7 +8,7 @@ jobs: name: "Release PR to npm" runs-on: ubuntu-latest # comment out if:false to enable release PR to npm - if: false + # if: false permissions: write-all steps: - name: Checkout From c2ad0bc05859164ea1d850a609ebc2616e570f98 Mon Sep 17 00:00:00 2001 From: Peter Smith Date: Mon, 30 Dec 2024 11:32:13 +0000 Subject: [PATCH 3/9] chore: changeset --- .changeset/thin-planes-cover.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.changeset/thin-planes-cover.md b/.changeset/thin-planes-cover.md index c49eb62974d..733d78f3868 100644 --- a/.changeset/thin-planes-cover.md +++ b/.changeset/thin-planes-cover.md @@ -1,3 +1,5 @@ --- "create-fuels": patch --- + +fix: unable to kill `fuels dev` with `pnpm` From 035821500351722b658f67ba016b23b59828604e Mon Sep 17 00:00:00 2001 From: Peter Smith Date: Mon, 30 Dec 2024 12:39:38 +0000 Subject: [PATCH 4/9] fix: enabled killing of the underlying process --- packages/account/src/test-utils/launchNode.ts | 16 ++++++++++++---- .../src/cli/commands/dev/autoStartFuelCore.ts | 1 + 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/packages/account/src/test-utils/launchNode.ts b/packages/account/src/test-utils/launchNode.ts index 2e24f9ce4ee..c7565b00889 100644 --- a/packages/account/src/test-utils/launchNode.ts +++ b/packages/account/src/test-utils/launchNode.ts @@ -41,6 +41,7 @@ export type LaunchNodeOptions = { * */ snapshotConfig?: SnapshotConfigs; includeInitialState?: boolean; + killProcessOnExit?: boolean; }; export type LaunchNodeResult = Promise<{ @@ -143,6 +144,7 @@ export const launchNode = async ({ basePath, snapshotConfig = defaultSnapshotConfigs, includeInitialState = false, + killProcessOnExit = false, }: LaunchNodeOptions = {}): LaunchNodeResult => // eslint-disable-next-line no-async-promise-executor new Promise(async (resolve, reject) => { @@ -248,9 +250,6 @@ export const launchNode = async ({ } }; - child.on('error', removeSideffects); - child.on('exit', removeSideffects); - const childState = { isDead: false, }; @@ -331,5 +330,14 @@ export const launchNode = async ({ process.on('beforeExit', cleanup); process.on('uncaughtException', cleanup); - child.on('error', reject); + child.on('exit', (code: number | null, _signal: NodeJS.Signals | null) => { + removeSideffects(); + if (killProcessOnExit) { + process.exit(code); + } + }); + child.on('error', (err: Error) => { + removeSideffects(); + reject(err); + }); }); diff --git a/packages/fuels/src/cli/commands/dev/autoStartFuelCore.ts b/packages/fuels/src/cli/commands/dev/autoStartFuelCore.ts index 3853682c678..234a68831df 100644 --- a/packages/fuels/src/cli/commands/dev/autoStartFuelCore.ts +++ b/packages/fuels/src/cli/commands/dev/autoStartFuelCore.ts @@ -38,6 +38,7 @@ export const autoStartFuelCore = async (config: FuelsConfig) => { basePath: config.basePath, fuelCorePath: config.fuelCorePath, includeInitialState: true, + killProcessOnExit: true, }); fuelCore = { From 34ae26176f4e5cedbea1ddf44999dd74df330345 Mon Sep 17 00:00:00 2001 From: Peter Smith Date: Mon, 30 Dec 2024 12:57:58 +0000 Subject: [PATCH 5/9] chore: updated changeset --- .changeset/thin-planes-cover.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.changeset/thin-planes-cover.md b/.changeset/thin-planes-cover.md index 733d78f3868..7dc35cead1c 100644 --- a/.changeset/thin-planes-cover.md +++ b/.changeset/thin-planes-cover.md @@ -1,4 +1,6 @@ --- +"@fuel-ts/account": patch +"fuels": patch "create-fuels": patch --- From 348078aa2b9b869c93f221170987448b26c16c44 Mon Sep 17 00:00:00 2001 From: Peter Smith Date: Mon, 30 Dec 2024 13:28:09 +0000 Subject: [PATCH 6/9] chore: finalise PR --- .changeset/thin-planes-cover.md | 1 - .github/workflows/pr-release.yaml | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/.changeset/thin-planes-cover.md b/.changeset/thin-planes-cover.md index 7dc35cead1c..229f87ce8ed 100644 --- a/.changeset/thin-planes-cover.md +++ b/.changeset/thin-planes-cover.md @@ -1,7 +1,6 @@ --- "@fuel-ts/account": patch "fuels": patch -"create-fuels": patch --- fix: unable to kill `fuels dev` with `pnpm` diff --git a/.github/workflows/pr-release.yaml b/.github/workflows/pr-release.yaml index 593d7fce145..6eeca1f3f04 100644 --- a/.github/workflows/pr-release.yaml +++ b/.github/workflows/pr-release.yaml @@ -8,7 +8,7 @@ jobs: name: "Release PR to npm" runs-on: ubuntu-latest # comment out if:false to enable release PR to npm - # if: false + if: false permissions: write-all steps: - name: Checkout From 0278a27c92e14c650f6707466fed4086ffafa252 Mon Sep 17 00:00:00 2001 From: Peter Smith Date: Mon, 30 Dec 2024 18:34:37 +0000 Subject: [PATCH 7/9] fix: final issue with listeners causing `fuels dev` failures --- packages/account/src/test-utils/launchNode.ts | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/packages/account/src/test-utils/launchNode.ts b/packages/account/src/test-utils/launchNode.ts index c7565b00889..c68e7b13ca8 100644 --- a/packages/account/src/test-utils/launchNode.ts +++ b/packages/account/src/test-utils/launchNode.ts @@ -243,8 +243,10 @@ export const launchNode = async ({ }); } - const removeSideffects = () => { + const removeChildListeners = () => { child.stderr.removeAllListeners(); + }; + const removeTempDir = () => { if (existsSync(tempDir)) { rmSync(tempDir, { recursive: true }); } @@ -260,7 +262,8 @@ export const launchNode = async ({ } childState.isDead = true; - removeSideffects(); + removeChildListeners(); + if (child.pid !== undefined) { try { process.kill(-child.pid); @@ -283,6 +286,7 @@ export const launchNode = async ({ // eslint-disable-next-line no-console console.error('No PID available for the child process, unable to kill launched node'); } + removeTempDir(); }; // Look for a specific graphql start point in the output. @@ -331,13 +335,15 @@ export const launchNode = async ({ process.on('uncaughtException', cleanup); child.on('exit', (code: number | null, _signal: NodeJS.Signals | null) => { - removeSideffects(); + removeChildListeners(); + removeTempDir(); if (killProcessOnExit) { process.exit(code); } }); child.on('error', (err: Error) => { - removeSideffects(); + removeChildListeners(); + removeTempDir(); reject(err); }); }); From 47d67c529a3036923a5737f2cf7c8f12f48bdd03 Mon Sep 17 00:00:00 2001 From: Peter Smith Date: Mon, 30 Dec 2024 18:35:16 +0000 Subject: [PATCH 8/9] chore: release --- .github/workflows/pr-release.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pr-release.yaml b/.github/workflows/pr-release.yaml index 6eeca1f3f04..593d7fce145 100644 --- a/.github/workflows/pr-release.yaml +++ b/.github/workflows/pr-release.yaml @@ -8,7 +8,7 @@ jobs: name: "Release PR to npm" runs-on: ubuntu-latest # comment out if:false to enable release PR to npm - if: false + # if: false permissions: write-all steps: - name: Checkout From c1ae745bde01a1b3ddccb82bbcec981ca807d938 Mon Sep 17 00:00:00 2001 From: Peter Smith Date: Tue, 31 Dec 2024 08:57:23 +0000 Subject: [PATCH 9/9] Update .github/workflows/pr-release.yaml --- .github/workflows/pr-release.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pr-release.yaml b/.github/workflows/pr-release.yaml index 593d7fce145..6eeca1f3f04 100644 --- a/.github/workflows/pr-release.yaml +++ b/.github/workflows/pr-release.yaml @@ -8,7 +8,7 @@ jobs: name: "Release PR to npm" runs-on: ubuntu-latest # comment out if:false to enable release PR to npm - # if: false + if: false permissions: write-all steps: - name: Checkout