Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[HttpClient] Fix buffering after calling AsyncContext::passthru()#47879

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Conversation

@lubo13
Copy link
Contributor

@lubo13lubo13 commentedOct 16, 2022
edited by nicolas-grekas
Loading

QA
Branch?5.4
Bug fix?yes
New feature?no
Deprecations?no
Tickets-
LicenseMIT
Doc PR-

Hi, guys, I think there is an issue with the RetryableHttpClient, let me explain to you what I've seen.

  1. Request is executed into AsyncResponse::__construct

  2. The initializer Closure executes AsyncResponse::passthru, there the AsyncContext and a new stream are created

  3. The next step is yielding from passthruStream and there the stream is checked -$r->stream->valid(). Here the stream is not a valid iterator, because the last retry attempt has already been made and the generator is closed.

  4. This leads the response body stream to be unseekable because the$r->openBuffer() is not called. The content is left with a valuenull and whenAsyncResponse->toStream() is called fromPsr18Client::110 the content with value null is bound to thecontent of StreamWrapper.

  5. After that this newly generated resource is passed to thePsr17Factory->createStreamFromResource() and the resulted (unseekable body) stream is passed to the$response->withBody($body) ontoPsr18Client::121

  6. The result is that the Response body stream is not seekable and when I execute two times(string) $response->getBody() after the first attempt the body is an empty string.

Let me know what you think.

Thank you.

@carsonbot
Copy link

Hey!

I see that this is your first PR. That is great! Welcome!

Symfony has acontribution guide which I suggest you to read.

In short:

  • Always add tests
  • Keep backward compatibility (seehttps://symfony.com/bc).
  • Bug fixes must be submitted against the lowest maintained branch where they apply (seehttps://symfony.com/releases)
  • Features and deprecations must be submitted against the 6.2 branch.

Review the GitHub status checks of your pull request and try to solve the reported issues. If some tests are failing, try to see if they are failing because of this change.

When two Symfony core team members approve this change, it will be merged and you will become an official Symfony contributor!
If this PR is merged in a lower version branch, it will be merged up to all maintained branches within a few days.

I am going to sit back now and wait for the reviews.

Cheers!

Carsonbot

@carsonbotcarsonbot changed the title[Bug]RetryableHttpClient - unseekable body streamRetryableHttpClient - unseekable body streamOct 16, 2022
@nicolas-grekas
Copy link
Member

The attached patch doesn't look correct to me because it'd mean yielding a $chunk that should be skipped, since it belongs to a response that should be retried instead.

Can you reproduce your scenario in a test case so that we can figure out another fix maybe?

@lubo13
Copy link
ContributorAuthor

Yes, sure it's not the correct one, it's just a dirty hack to try it out if we open the buffer do we receive the seekable stream?
I will try to reproduce it with tests.
But meanwhile, do you have anything in mind is this an expected behaviour?

@nicolas-grekas
Copy link
Member

Not yet sorry. The test case would help a lot!

lubo13 reacted with thumbs up emoji

@lubo13
Copy link
ContributorAuthor

@nicolas-grekas the test has been added, I will waiting for your response
Thank you

nicolas-grekas reacted with heart emoji

@nicolas-grekasnicolas-grekas changed the base branch from6.2 to5.4October 18, 2022 12:03
@carsonbotcarsonbot changed the titleRetryableHttpClient - unseekable body stream[HttpClient] RetryableHttpClient - unseekable body streamOct 18, 2022
@nicolas-grekasnicolas-grekasforce-pushed theretryable-http-client-unseekable-stream branch from8cc9e10 tob1d03d1CompareOctober 18, 2022 12:04
@nicolas-grekasnicolas-grekas changed the title[HttpClient] RetryableHttpClient - unseekable body stream[HttpClient] Fix buffering of after calling AsyncContext::passthru()Oct 18, 2022
Copy link
Member

@nicolas-grekasnicolas-grekas left a comment

Choose a reason for hiding this comment

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

(I added the fix to the PR)

@nicolas-grekasnicolas-grekas changed the title[HttpClient] Fix buffering of after calling AsyncContext::passthru()[HttpClient] Fix buffering after calling AsyncContext::passthru()Oct 18, 2022
@nicolas-grekasnicolas-grekasforce-pushed theretryable-http-client-unseekable-stream branch fromb1d03d1 tob559f80CompareOctober 18, 2022 12:08
@nicolas-grekasnicolas-grekas removed this from the6.2 milestoneOct 18, 2022
@nicolas-grekasnicolas-grekas added this to the5.4 milestoneOct 18, 2022
@nicolas-grekas
Copy link
Member

Thank you@lubo13.

lubo13 reacted with thumbs up emoji

@nicolas-grekasnicolas-grekas merged commitd50fbf6 intosymfony:5.4Oct 18, 2022
@lubo13lubo13 deleted the retryable-http-client-unseekable-stream branchOctober 18, 2022 17:00
@lubo13
Copy link
ContributorAuthor

@nicolas-grekas Thank you, could we apply this fix to 6.1 with a new bugfix version? Sorry, but I could find the tag, if you already have created such please share it.

@nicolas-grekas
Copy link
Member

It's already merged up. Releases happen at the end of the month.

@lubo13
Copy link
ContributorAuthor

Okay, Thank you

This was referencedOct 28, 2022
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@nicolas-grekasnicolas-grekasnicolas-grekas approved these changes

@lyrixxlyrixxAwaiting requested review from lyrixx

@ycerutoycerutoAwaiting requested review from yceruto

@wouterjwouterjAwaiting requested review from wouterj

@chalasrchalasrAwaiting requested review from chalasr

@dunglasdunglasAwaiting requested review from dunglas

@OskarStarkOskarStarkAwaiting requested review from OskarStark

@jderussejderusseAwaiting requested review from jderusse

@xabbuhxabbuhAwaiting requested review from xabbuh

Assignees

No one assigned

Projects

None yet

Milestone

5.4

Development

Successfully merging this pull request may close these issues.

3 participants

@lubo13@carsonbot@nicolas-grekas

[8]ページ先頭

©2009-2025 Movatter.jp