Skip to content

Conversation

@Rakdar
Copy link
Contributor

@Rakdar Rakdar commented Jan 7, 2018

In relation to #1, i implemented a promise-timer to support timeouts.

The default is 10 seconds and the API implemented as suggested:

$browser = $browser->withOptions(array('timeout' => 10));

@clue
Copy link
Owner

clue commented Feb 9, 2018

@Rakdar Thank you for taking the time to file this PR!

I've just posted a small recap for this feature in #1 (comment), what do you think about this? I'm currently undecided if we can apply a "default timeout" here and if so, what its timeout value should be. Any input is welcome! 👍

Copy link
Owner

@clue clue left a comment

Choose a reason for hiding this comment

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

Thank you for the discussion in #1, so let's finally see what needs to be done to get this in! :shipit:

public function __construct(RequestInterface $request, Sender $sender, array $options = array(), MessageFactory $messageFactory)
{
/** @var int $timeout */
private $timeout = 10;
Copy link
Owner

Choose a reason for hiding this comment

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

Not sure about this default value, how about using http://php.net/manual/en/filesystem.configuration.php#ini.default-socket-timeout instead? (defaults to 60s)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, you're right. Using the ini-default-value as default will be better. (I personally just don't like a 60 seconds timeout; what server takes 60 seconds to send the headers? ... in 2018?)

function (ResponseInterface $response) use ($request, $that) {
return $that->onResponse($response, $request);
}
return Promise\Timer\timeout(
Copy link
Owner

Choose a reason for hiding this comment

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

This only times out a single request within this "transaction". In other words: This timeout will be restarted for each redirection and the consumer has no control over applying a total timeout.

It's my understanding that this timeout should apply to the whole "transaction", i.e. simply move this up to the send() method instead of the next() method.

What do you think about this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Now i don't get it myself why i implemented the timeout within the next() method.

- Moving timeout-promise one method up to send() instead of next().
@clue clue added this to the v2.5.0 milestone Oct 1, 2018
clue pushed a commit to clue-labs/reactphp-buzz that referenced this pull request Oct 20, 2018
Originally by @Rakdar ( clue#90 ),
rebased and squashed by @clue.
@clue clue mentioned this pull request Oct 20, 2018
@clue clue closed this in #114 Oct 20, 2018
@clue
Copy link
Owner

clue commented Oct 20, 2018

@Rakdar Thank you for filing this PR and for your patience! I've just merged #114 which supersedes this PR by making timeouts optional and adding some documentation!

@clue clue removed this from the v2.5.0 milestone Oct 20, 2018
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.

2 participants