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

oneBehindFetch does not always fetch #719

Open
ithinkihaveacat opened this issue Apr 19, 2020 · 1 comment
Open

oneBehindFetch does not always fetch #719

ithinkihaveacat opened this issue Apr 19, 2020 · 1 comment

Comments

@ithinkihaveacat
Copy link
Collaborator

This is quite bizarre. For large files, oneBehindFetch() does not return any response:

const fetch = require("@ampproject/toolbox-core").oneBehindFetch;

fetch("https://amp.dev/manifest.json")
  .then((res) => res.text())
  .then((text) => console.log(`length of manifest.json = ${text.length}`));

fetch("https://amp.dev/")
  .then((res) => res.text())
  .then((text) => console.log(`length of index.html = ${text.length}`));

On node 12.16.1, this outputs:

length of manifest.json = 1136

(That is, the length of index.html is not output.) Removing and reordering requests, etc. does not help.

The problem here seems to be that Response.clone() (as indirectly used by oneBehindFetch) is essentially broken for rather complicated reasons).

The recommended way of fixing this is to resolve the cloned responses in parallel, however this is not really suitable for oneBehindFetch's use case, since it endeavours to be a drop-in replacement for fetch().

This is related to #712 and #378. It may also be a factor in #650, since one of the consequences of this is that responses are not cached as expected. (Although that involved a small file, so maybe not.)

@sebastianbenz
Copy link
Collaborator

Thanks for investigating. I think we need to completely re-think how we want to perform caching. Currently, I'm leaning towards an explicit file-system based caching interface.

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

No branches or pull requests

2 participants