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

[Feature Request] Unable to use CDN that doesn't support HEAD requests #375

Closed
stramel opened this issue Nov 3, 2023 · 2 comments · Fixed by #385
Closed

[Feature Request] Unable to use CDN that doesn't support HEAD requests #375

stramel opened this issue Nov 3, 2023 · 2 comments · Fixed by #385
Labels

Comments

@stramel
Copy link
Contributor

stramel commented Nov 3, 2023

Context
I'm using an internal basic Git based CDN and it currently doesn't support HEAD requests. This makes it impossible to run storybook tests against the hosted versions.

const res = await fetch(url, { method: 'HEAD', headers });

Proposed Solution
switch to using GET for the request instead of HEAD

Alternate Solutions

  • adding a configuration flag for the type of request to make to ensure the server is running, such as --req-method=GET
  • adding a CLI flag to be able to skip the server check such as --skip-server-check
@cfrank
Copy link

cfrank commented Nov 3, 2023

I understand the reasoning behind choosing to use a HEAD request, but to reduce these kinds of issues in the future I believe it makes sense to just switch this to a GET request.

There isn't any side-effects from this, since fetch buffers the response body and we never read from it.

(async () => {
    console.time('HEAD');
    const head = await fetch('https://raw.githubusercontent.com/json-iterator/test-data/master/large-file.json', {
        method: 'HEAD',
    });
    console.log(head.status);
    console.timeEnd('HEAD');

    console.time('GET');
    const get = await fetch('https://raw.githubusercontent.com/json-iterator/test-data/master/large-file.json');
    console.log(get.status);
    console.timeEnd('GET');
})();
200
HEAD: 104.648ms
200
GET: 93.117ms

In my tests the GET request usually resolve negligibly faster, though the primary benefit is just using the most basic request method and avoiding these types of issues being brought up in the future.

Copy link

🚀 Issue was released in v0.15.0 🚀

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

Successfully merging a pull request may close this issue.

2 participants