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

Fix double drain bug #8297

Closed
wants to merge 1 commit into from
Closed

Conversation

cvializ
Copy link
Contributor

@cvializ cvializ commented Mar 21, 2017

This should fix the issue @jridgewell raised since it temporarily caches the original response and only gives callers cloned responses. The previous implementation cached a cloned response and returned it, allowing a potential double drain.

@cvializ cvializ requested a review from jridgewell March 21, 2017 20:03
@ampprojectbot
Copy link
Member

Hi, ampproject bot here! Here are a list of the owners that can approve your files.

You may leave an issue comment stating "@ampprojectbot retry!" to force me to re-evaluate this Pull Request's status

/to dvoytenko jridgewell

  • src/service/batched-xhr-impl.js

For any issues please file a bug at https://github.com/google/github-owners-bot/issues

Copy link
Contributor

@jridgewell jridgewell left a comment

Choose a reason for hiding this comment

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

Test please.

@@ -61,7 +61,8 @@ export class BatchedXhr extends Xhr {
const fetchPromise = super.fetch(input, opt_init);

if (isBatchable) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: Let's rearrange a bit:

if (!isBatchable) {
  return fetchPromise
}

if (this.fetchPromises_[key]) {
  return this.fetchPromises_[key].then(resp => resp.clone());
}

this.fetchPromises_[key] = fetchPromise;

return fetchPromise.then(...)

@cvializ
Copy link
Contributor Author

cvializ commented Mar 21, 2017

After some more thought, this may not be necessary. I will close this PR unless you think the nit you raised above should be carried to the code before this PR.

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

Successfully merging this pull request may close these issues.

4 participants