Skip to content

[Console][QuestionHelper] add optional timeout for human interaction #61092

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

Open
wants to merge 10 commits into
base: 7.4
Choose a base branch
from

Conversation

janedbal
Copy link
Contributor

@janedbal janedbal commented Jul 10, 2025

Q A
Branch? 7.4
Bug fix? no
New feature? yes
Deprecations? no
Issues None
License MIT

About:

  • Adds timeout functionality to console questions, allowing developers to set a maximum time limit for user input.
  • Our usecase is that some developers added interactive questions inside opened db transactions. Without timeout, it can lead to hours long trx if somebody forgets to repond and keeps the terminal open.
  • The feature is backward compatible - existing code continues to work without timeouts unless explicitly set.

@janedbal janedbal requested a review from chalasr as a code owner July 10, 2025 11:16
@carsonbot carsonbot added this to the 7.4 milestone Jul 10, 2025
@carsonbot carsonbot changed the title QuestionHelper: add optional timeout for human interaction [Console] QuestionHelper: add optional timeout for human interaction Jul 10, 2025
@OskarStark OskarStark changed the title [Console] QuestionHelper: add optional timeout for human interaction [Console][QuestionHelper] add optional timeout for human interaction Jul 10, 2025
Co-authored-by: Oskar Stark <oskarstark@googlemail.com>
janedbal and others added 2 commits July 14, 2025 15:27
Co-authored-by: Anderson Müller <anderson.a.muller@gmail.com>
@janedbal
Copy link
Contributor Author

Any chance this get approved/merged soon? I believe those CI failures are not relevant. Thanks

Comment on lines +513 to +514
$plural = 1 === $timeoutSeconds ? '' : 's';
throw new MissingInputException("Timed out after waiting for input for $timeoutSeconds second$plural.");
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
$plural = 1 === $timeoutSeconds ? '' : 's';
throw new MissingInputException("Timed out after waiting for input for $timeoutSeconds second$plural.");
throw new MissingInputException(\sprintf('Timed out after waiting for input for %d %s.', $timeoutSeconds, $timeoutSeconds === 1 ? 'second' : 'seconds'));

?


/**
* The timeout is the maximum time the user has to answer the question.
* If the user does not answer within this time, an exception will be thrown.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
* If the user does not answer within this time, an exception will be thrown.

this logic is part of the questionHelper, not the setter.

@@ -38,6 +38,7 @@ class Question
private ?\Closure $normalizer = null;
private bool $trimmable = true;
private bool $multiline = false;
private ?int $timeoutSeconds = null;
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
private ?int $timeoutSeconds = null;
private ?int $timeout = null;

same for set and get methods?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants