From d3081d0618216ec2f51606abdf5c64937d11b794 Mon Sep 17 00:00:00 2001 From: Kateryna Kodonenko Date: Fri, 13 Dec 2024 13:11:54 -0500 Subject: [PATCH 1/8] Increase timeout in wp-cli-process --- src/lib/wp-cli-process.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib/wp-cli-process.ts b/src/lib/wp-cli-process.ts index 3f706dcc9..09ea336c6 100644 --- a/src/lib/wp-cli-process.ts +++ b/src/lib/wp-cli-process.ts @@ -11,7 +11,7 @@ export type MessageName = 'execute'; export type WpCliResult = ReturnType< typeof executeWPCli >; export type MessageCanceled = { error: Error; canceled: boolean }; -const DEFAULT_RESPONSE_TIMEOUT = 120000; +const DEFAULT_RESPONSE_TIMEOUT = 240000; export default class WpCliProcess { lastMessageId = 0; From 4e2182fa16f16e3a6bbc0a53d42a5bc2f6853278 Mon Sep 17 00:00:00 2001 From: Kateryna Kodonenko Date: Fri, 13 Dec 2024 13:33:26 -0500 Subject: [PATCH 2/8] Drop timeout a bit --- src/lib/wp-cli-process.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib/wp-cli-process.ts b/src/lib/wp-cli-process.ts index 09ea336c6..fd8d70d76 100644 --- a/src/lib/wp-cli-process.ts +++ b/src/lib/wp-cli-process.ts @@ -11,7 +11,7 @@ export type MessageName = 'execute'; export type WpCliResult = ReturnType< typeof executeWPCli >; export type MessageCanceled = { error: Error; canceled: boolean }; -const DEFAULT_RESPONSE_TIMEOUT = 240000; +const DEFAULT_RESPONSE_TIMEOUT = 180000; export default class WpCliProcess { lastMessageId = 0; From b9cd537ede2e40e8fde2177de44ecd9263056d16 Mon Sep 17 00:00:00 2001 From: Kateryna Kodonenko Date: Mon, 16 Dec 2024 09:31:53 -0500 Subject: [PATCH 3/8] Improve readability of response timeout --- src/lib/wp-cli-process.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib/wp-cli-process.ts b/src/lib/wp-cli-process.ts index fd8d70d76..8ee21d97d 100644 --- a/src/lib/wp-cli-process.ts +++ b/src/lib/wp-cli-process.ts @@ -11,7 +11,7 @@ export type MessageName = 'execute'; export type WpCliResult = ReturnType< typeof executeWPCli >; export type MessageCanceled = { error: Error; canceled: boolean }; -const DEFAULT_RESPONSE_TIMEOUT = 180000; +const DEFAULT_RESPONSE_TIMEOUT = 180 * 1000; export default class WpCliProcess { lastMessageId = 0; From 013c6c21388825b45cf9ae74c992fb70d2281257 Mon Sep 17 00:00:00 2001 From: Kateryna Kodonenko Date: Mon, 16 Dec 2024 11:20:57 -0500 Subject: [PATCH 4/8] Ensure that we kill database import process when it fails with timeout --- src/lib/wp-cli-process.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/lib/wp-cli-process.ts b/src/lib/wp-cli-process.ts index 8ee21d97d..6fb2c8076 100644 --- a/src/lib/wp-cli-process.ts +++ b/src/lib/wp-cli-process.ts @@ -11,7 +11,7 @@ export type MessageName = 'execute'; export type WpCliResult = ReturnType< typeof executeWPCli >; export type MessageCanceled = { error: Error; canceled: boolean }; -const DEFAULT_RESPONSE_TIMEOUT = 180 * 1000; +const DEFAULT_RESPONSE_TIMEOUT = 120000; export default class WpCliProcess { lastMessageId = 0; @@ -122,8 +122,13 @@ export default class WpCliProcess { }; const timeoutHandler = () => { - reject( new Error( `Request for message ${ originalMessage } timed out` ) ); + // Kill the process on timeout + this.#killProcess().catch( ( error ) => { + console.error( 'Failed to kill process after timeout:', error ); + Sentry.captureException( error ); + } ); process.removeListener( 'message', handler ); + reject( new Error( `Request for message ${ originalMessage } timed out` ) ); }; const timeoutId = setTimeout( timeoutHandler, timeout ); const cancelHandler = () => { From 44ee173343368bf403ae4337a01798ef2e4cec8e Mon Sep 17 00:00:00 2001 From: Kateryna Kodonenko Date: Mon, 16 Dec 2024 11:23:26 -0500 Subject: [PATCH 5/8] Persist timeout increase changes --- src/lib/wp-cli-process.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib/wp-cli-process.ts b/src/lib/wp-cli-process.ts index 6fb2c8076..0ad465a58 100644 --- a/src/lib/wp-cli-process.ts +++ b/src/lib/wp-cli-process.ts @@ -11,7 +11,7 @@ export type MessageName = 'execute'; export type WpCliResult = ReturnType< typeof executeWPCli >; export type MessageCanceled = { error: Error; canceled: boolean }; -const DEFAULT_RESPONSE_TIMEOUT = 120000; +const DEFAULT_RESPONSE_TIMEOUT = 180 * 1000; export default class WpCliProcess { lastMessageId = 0; From 5a27cc5f51d4684a0611c06cecbdb2c6aa233558 Mon Sep 17 00:00:00 2001 From: Kateryna Kodonenko Date: Mon, 16 Dec 2024 11:47:36 -0500 Subject: [PATCH 6/8] Ensure that process happens async --- src/lib/wp-cli-process.ts | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/lib/wp-cli-process.ts b/src/lib/wp-cli-process.ts index 0ad465a58..d49e3200a 100644 --- a/src/lib/wp-cli-process.ts +++ b/src/lib/wp-cli-process.ts @@ -121,12 +121,13 @@ export default class WpCliProcess { resolve( data ); }; - const timeoutHandler = () => { - // Kill the process on timeout - this.#killProcess().catch( ( error ) => { + const timeoutHandler = async () => { + try { + await this.#killProcess(); + } catch ( error ) { console.error( 'Failed to kill process after timeout:', error ); Sentry.captureException( error ); - } ); + } process.removeListener( 'message', handler ); reject( new Error( `Request for message ${ originalMessage } timed out` ) ); }; From f35c88e54b57894e171c5068f2145ff4709802d7 Mon Sep 17 00:00:00 2001 From: Kateryna Kodonenko Date: Tue, 17 Dec 2024 10:01:19 -0500 Subject: [PATCH 7/8] Increase timeout to 5 mins --- src/lib/wp-cli-process.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib/wp-cli-process.ts b/src/lib/wp-cli-process.ts index d49e3200a..5a57583d5 100644 --- a/src/lib/wp-cli-process.ts +++ b/src/lib/wp-cli-process.ts @@ -11,7 +11,7 @@ export type MessageName = 'execute'; export type WpCliResult = ReturnType< typeof executeWPCli >; export type MessageCanceled = { error: Error; canceled: boolean }; -const DEFAULT_RESPONSE_TIMEOUT = 180 * 1000; +const DEFAULT_RESPONSE_TIMEOUT = 300 * 1000; export default class WpCliProcess { lastMessageId = 0; From 941ac2d3d19b22502fc890223a39f8cd4256346e Mon Sep 17 00:00:00 2001 From: Kateryna Kodonenko Date: Tue, 17 Dec 2024 10:06:33 -0500 Subject: [PATCH 8/8] Remove Sentry logging --- src/lib/wp-cli-process.ts | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/src/lib/wp-cli-process.ts b/src/lib/wp-cli-process.ts index 5a57583d5..6f4c183d9 100644 --- a/src/lib/wp-cli-process.ts +++ b/src/lib/wp-cli-process.ts @@ -122,12 +122,7 @@ export default class WpCliProcess { }; const timeoutHandler = async () => { - try { - await this.#killProcess(); - } catch ( error ) { - console.error( 'Failed to kill process after timeout:', error ); - Sentry.captureException( error ); - } + await this.#killProcess(); process.removeListener( 'message', handler ); reject( new Error( `Request for message ${ originalMessage } timed out` ) ); };