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

HttpServer promise cancellation #443

Closed
bileslav opened this issue Feb 18, 2022 · 1 comment
Closed

HttpServer promise cancellation #443

bileslav opened this issue Feb 18, 2022 · 1 comment
Labels

Comments

@bileslav
Copy link

bileslav commented Feb 18, 2022

Hi there,

I know that HttpServer cancels the promise returned to it if the connection is closed prematurely.

My app streams large files using Browser, so logically this is very useful for me,
but here comes the difficulty when using react/async, since there's no cancellation.

It's quite hard for me to change the flow to make it work (it would be a mixture of async/await and promises), nevertheless,
there's such a possibility. Should I take care of this? Or will streaming be terminated when the connection is closed anyway?

I tried to make artificial test, but I didn't succeed to understand.
Here's a super simplified example of how it's done for me now:

$responder = function (ServerRequestInterface $request) use ($browser): ResponseInterface {
	return await($browser->requestStreaming('GET', '...'));
};

$server = new HttpServer(async($responder));
@WyriHaximus
Copy link
Member

This PR might interest you reactphp/async#20 as it brings cancellation to async and await (inside async).

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

No branches or pull requests

3 participants