File tree Expand file tree Collapse file tree
services/error-monitoring Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ ---
2+ " @inlang/cli " : patch
3+ ---
4+
5+ Fix CLI commands not terminating by removing the shutdown wait on ` fileQueueSettled ` .
6+
7+ Also silence known non-actionable shutdown noise from background file queue processing when the DB is already closed.
Original file line number Diff line number Diff line change 11/* eslint-disable @typescript-eslint/no-non-null-assertion */
22import { Command } from "commander" ;
33import { rpc } from "@inlang/rpc" ;
4- import {
5- getInlangProject ,
6- settleLastUsedProjectFileQueue ,
7- } from "../../utilities/getInlangProject.js" ;
4+ import { getInlangProject } from "../../utilities/getInlangProject.js" ;
85import { log , logError } from "../../utilities/log.js" ;
96import {
107 saveProjectToDirectory ,
@@ -41,7 +38,6 @@ export const translate = new Command()
4138 logError ( error ) ;
4239 exitCode = 1 ;
4340 } finally {
44- await settleLastUsedProjectFileQueue ( ) ;
4541 process . exit ( exitCode ) ;
4642 }
4743 } ) ;
Original file line number Diff line number Diff line change 11import { Command } from "commander" ;
2- import {
3- getInlangProject ,
4- settleLastUsedProjectFileQueue ,
5- } from "../../utilities/getInlangProject.js" ;
2+ import { getInlangProject } from "../../utilities/getInlangProject.js" ;
63import { log } from "../../utilities/log.js" ;
74import { projectOption } from "../../utilities/globalFlags.js" ;
85
@@ -32,7 +29,6 @@ export async function validateCommandAction(args: { project: string }) {
3229 log . error ( error ) ;
3330 exitCode = 1 ;
3431 } finally {
35- await settleLastUsedProjectFileQueue ( ) ;
3632 process . exit ( exitCode ) ;
3733 }
3834}
Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ import { machine } from "./commands/machine/index.js";
33import { plugin } from "./commands/plugin/index.js" ;
44import { version } from "../package.json" ;
55import { initErrorMonitoring } from "./services/error-monitoring/implementation.js" ;
6+ import { silenceKnownShutdownNoise } from "./services/error-monitoring/silenceKnownShutdownNoise.js" ;
67import { validate } from "./commands/validate/index.js" ;
78import { capture } from "./telemetry/capture.js" ;
89import { lastUsedProject } from "./utilities/getInlangProject.js" ;
@@ -11,6 +12,7 @@ import { lint } from "./commands/lint/index.js";
1112// --------------- INIT ---------------
1213
1314initErrorMonitoring ( ) ;
15+ silenceKnownShutdownNoise ( ) ;
1416// checks whether the gitOrigin corresponds to the pattern
1517
1618// beautiful logging
Original file line number Diff line number Diff line change 1+ const FILE_QUEUE_CONTEXT_PATTERN = / ( f i l e q u e u e | E r r o r p r o c e s s i n g f i l e q u e u e e n t r y ) / i;
2+ const DB_CLOSED_PATTERN = / ( D B h a s b e e n c l o s e d | d r i v e r h a s a l r e a d y b e e n d e s t r o y e d ) / i;
3+
4+ function shouldSilenceConsoleError ( args : unknown [ ] ) : boolean {
5+ if ( args . length === 0 ) {
6+ return false ;
7+ }
8+
9+ const text = args
10+ . map ( ( arg ) => {
11+ if ( arg instanceof Error ) {
12+ return `${ arg . name } : ${ arg . message } ` ;
13+ }
14+ return String ( arg ) ;
15+ } )
16+ . join ( " " ) ;
17+
18+ return FILE_QUEUE_CONTEXT_PATTERN . test ( text ) && DB_CLOSED_PATTERN . test ( text ) ;
19+ }
20+
21+ export function silenceKnownShutdownNoise ( ) : void {
22+ const originalConsoleError = console . error . bind ( console ) ;
23+
24+ console . error = ( ...args : unknown [ ] ) => {
25+ if ( shouldSilenceConsoleError ( args ) ) {
26+ return ;
27+ }
28+
29+ originalConsoleError ( ...args ) ;
30+ } ;
31+ }
Original file line number Diff line number Diff line change 11import fs from "node:fs" ;
22import { loadProjectFromDirectory , type InlangProject } from "@inlang/sdk" ;
3- import { fileQueueSettled } from "@inlang/sdk/lix" ;
43import { resolve } from "node:path" ;
54
65/**
@@ -31,14 +30,3 @@ export async function getInlangProject(args: {
3130 process . exit ( 1 ) ;
3231 }
3332}
34-
35- export async function settleLastUsedProjectFileQueue ( ) : Promise < void > {
36- if ( ! lastUsedProject ) {
37- return ;
38- }
39- try {
40- await fileQueueSettled ( { lix : lastUsedProject . lix } ) ;
41- } catch {
42- // Best-effort: ignore queue settle failures during shutdown.
43- }
44- }
You can’t perform that action at this time.
0 commit comments