MCPcopy
hub / github.com/lingodotdev/lingo.dev / exitGracefully

Function exitGracefully

packages/cli/src/cli/utils/exit-gracefully.ts:4–18  ·  view source on GitHub ↗
(elapsedMs = 0)

Source from the content-addressed store, hash-verified

2const MAX_WAIT_INTERVAL = 2000;
3
4export function exitGracefully(elapsedMs = 0) {
5 // Check if there are any pending operations
6 const hasPendingOperations = checkForPendingOperations();
7
8 if (hasPendingOperations && elapsedMs < MAX_WAIT_INTERVAL) {
9 // Wait a bit longer if there are pending operations
10 setTimeout(
11 () => exitGracefully(elapsedMs + STEP_WAIT_INTERVAL),
12 STEP_WAIT_INTERVAL,
13 );
14 } else {
15 // Exit immediately if no pending operations
16 process.exit(0);
17 }
18}
19
20function checkForPendingOperations(): boolean {
21 // Check for active handles and requests using internal Node.js methods

Callers 2

status.tsFile · 0.90

Calls 1

Tested by

no test coverage detected