diff --git a/packages/cli/src/commands/base-command.ts b/packages/cli/src/commands/base-command.ts index 9e48a3dda1d..b791cd8e39a 100644 --- a/packages/cli/src/commands/base-command.ts +++ b/packages/cli/src/commands/base-command.ts @@ -115,7 +115,8 @@ export abstract class BaseCommand { /** * Whether to init the regex engine. Defaults to `needsExpressionEngine`: a command * that evaluates workflow expressions also evaluates a user's regexes. Override only - * where the two genuinely diverge. + * where the two genuinely diverge, and as a getter (`override get needsRegexEngine()`): + * unlike the other `needs*` flags, this one can't be overridden as a field. */ get needsRegexEngine(): boolean { return this.needsExpressionEngine; @@ -612,6 +613,7 @@ export abstract class BaseCommand { async finally(error: Error | undefined) { if (error?.message) this.logger.error(error.message); if (inTest || this.constructor.name === 'Start') return; + if (this.needsRegexEngine) this.regexEngineService.shutdown(); if (this.dbConnection.connectionState.connected) { await sleep(100); // give any in-flight query some time to finish await this.dbConnection.close(); diff --git a/packages/cli/src/commands/engine.ts b/packages/cli/src/commands/engine.ts index 630421c308b..bdcbb087df0 100644 --- a/packages/cli/src/commands/engine.ts +++ b/packages/cli/src/commands/engine.ts @@ -77,6 +77,7 @@ export class Engine extends BaseCommand { await this.responseSender?.stop(); } await Expression.disposeExpressionEngine(); + if (this.needsRegexEngine) this.regexEngineService.shutdown(); } catch (error) { await this.exitWithCrash('There was an error shutting down the engine.', error); }