question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

The latest version of Storybook couldn't be fetched (in static build)

See original GitHub issue

Describe the bug In the static build of Storybook, the latest version of Storybook cannot be fetched. It doesn’t matter if I open the index.html locally or open the deployed version on my server.

To Reproduce Steps to reproduce the behavior:

  1. Build Storybook
  2. Open storybook-static/index.html in your browser
  3. Got to the “About your Storybook” page
  4. Error: Oops! The latest version of Storybook couldn't be fetched.

Screenshots Bildschirmfoto 2020-08-04 um 17 49 50@2x

Expected behavior Fetch the current version of Storybook and display the information like in the served version: Bildschirmfoto 2020-08-04 um 18 05 23

System: npx -p @storybook/cli@next sb info (or without @next) is throwing an error:

Environment Info:
(node:45923) UnhandledPromiseRejectionWarning: TypeError: (e || []).filter is not a function
    at /Users/<my name>/.npm/_npx/45915/lib/node_modules/@storybook/cli/node_modules/envinfo/dist/envinfo.js:1:73314
    at processTicksAndRejections (internal/process/task_queues.js:97:5)
    at async Promise.all (index 6)
(node:45923) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:45923) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:4
  • Comments:14 (7 by maintainers)

github_iconTop GitHub Comments

2reactions
holamaucommented, Oct 29, 2021

Yeah… the deployed (build) version of sb always throws this error. currently on 6.3.12 Screen Shot 2021-10-29 at 2 14 13 PM

0reactions
telestrialcommented, Jun 20, 2022

I decided to take a look at this one, and I have some information to push it ahead. I do not have a solve, yet.

  1. First off, the actual object coming into the AboutScreen component in about.tsx looks like this:

sb_version1

And so it is no wonder that this always happens. Our canUpdate in this file will always evaluate to null, which means we will always take the Oops! ... route.

  1. Following this to the base of where I think this “latest” property gets fetched brings us to updateCheck in update-check.ts:
export const updateCheck = async (version: string): Promise<VersionCheck> => {
  let result;
  const time = Date.now();
  try {
    const fromCache = await cache.get('lastUpdateCheck', { success: false, time: 0 });

    // if last check was more then 24h ago
    if (time - 86400000 > fromCache.time && !CI) {
      const fromFetch: any = await Promise.race([
        fetch(`${STORYBOOK_VERSION_BASE}/versions.json?current=${version}`),
        // if fetch is too slow, we won't wait for it
        new Promise((res, rej) => global.setTimeout(rej, 1500)),
      ]);
      const data = await fromFetch.json();
      result = { success: true, data, time };
      await cache.set('lastUpdateCheck', result);
    } else {
      result = fromCache;
    }
  } catch (error) {
    result = { success: false, error, time };
  }
  return result;
};

To be honest, I’m a junior developer and don’t understand everything about what I’m looking at here. However, I do not think that the problem is that we’re hitting the timeout promise. I believe someone alludes to that upward in this thread, and I just can’t see it. https://storybook.js.org/versions.json responds well within 1500 milliseconds–around 200 for me. It should nearly always win the promise race unless the server is down. Here are some questions I have:

  • What’s the best way to log output from this? I’ve been trying different methods and I can’t seem to get output either when I build or within the browser. Is nodelogger the thing to use here? Any help here would be appreciated as I could step through this function and get more details about what it’s doing and when.
  • Are we querying this address because we’re capturing this information server-side to keep track of what versions are being used?
  • Is there some error here around time such that the fetch just simply never, ever happens? If I understand how to log out of this function, I can check this one.

It’s completely possible that updateCheck is fine, but I thought starting here would be the right choice just in terms of troubleshooting.

UPDATE: Additional question:

  • Does updateCheck run in the non-dev standalone build at all?
Read more comments on GitHub >

github_iconTop Results From Across the Web

Gatsby - The result of this StaticQuery could not be fetched
A fix has just been made on the gatsby project (github.com/gatsbyjs/gatsby/pull/26077/). It is now available on version 2.24.13.
Read more >
[Gatsby] Solutions to "The result of this StaticQuery could not ...
Error: The result of this StaticQuery could not be fetched. This is likely a bug in Gatsby and if refreshing the page does...
Read more >
CLI options - Storybook
Storybook comes with two CLI utilities: start-storybook and build-storybook . Storybook collects completely anonymous data to help us improve user experience.
Read more >
storybook failed to fetch dynamically imported module - You.com
Had multiple issues upgrading through yarn upgrade so the final solution was to remove all old packages and run npx -p @storybook/cli@ sb...
Read more >
Storybook & Gatsby - Staticquery could not be fetched
Gatsby provides static files that are created during the initial compilation of the build process, which is when the GraphQL queries are run....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found