Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Studio: Increase timeout in wp-cli-process and terminate database import on timeout #741

Open
wants to merge 8 commits into
base: trunk
Choose a base branch
from
Open
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions src/lib/wp-cli-process.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -121,9 +121,15 @@ export default class WpCliProcess {
resolve( data );
};

const timeoutHandler = () => {
reject( new Error( `Request for message ${ originalMessage } timed out` ) );
const timeoutHandler = async () => {
try {
await this.#killProcess();
} catch ( error ) {
console.error( 'Failed to kill process after timeout:', error );
Sentry.captureException( error );
katinthehatsite marked this conversation as resolved.
Show resolved Hide resolved
}
process.removeListener( 'message', handler );
reject( new Error( `Request for message ${ originalMessage } timed out` ) );
};
const timeoutId = setTimeout( timeoutHandler, timeout );
const cancelHandler = () => {
Expand Down
Loading