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 all 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
7 changes: 4 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 = 300 * 1000;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While increasing the general timeout for every WP-CLI command. What do you think about increasing it even more for the specific import/export commands? Not a strong opinion.

We could pass the timeout as an option in executeWpCliCommand

{ targetPhpVersion }: { targetPhpVersion?: string } = {}

And then pass the value in the import

{ targetPhpVersion: DEFAULT_PHP_VERSION }

and export:

`sqlite export ${ tempFileName } --require=/tmp/sqlite-command/command.php`


export default class WpCliProcess {
lastMessageId = 0;
Expand Down Expand Up @@ -121,9 +121,10 @@ export default class WpCliProcess {
resolve( data );
};

const timeoutHandler = () => {
reject( new Error( `Request for message ${ originalMessage } timed out` ) );
const timeoutHandler = async () => {
await this.#killProcess();
process.removeListener( 'message', handler );
reject( new Error( `Request for message ${ originalMessage } timed out` ) );
};
const timeoutId = setTimeout( timeoutHandler, timeout );
const cancelHandler = () => {
Expand Down
Loading