loki icon indicating copy to clipboard operation
loki copied to clipboard

loki update: Cannot access the Story Store until the index is ready.

Open rhengles opened this issue 1 year ago • 7 comments

Just created a new SolidStart project from zero, added latest Storybook (8.3.5), tried to install and run Loki on it. But when running the command npx loki update, this was the output:

loki update v0.35.0
(node:16608) NOTE: The AWS SDK for JavaScript (v2) is in maintenance mode.
 SDK releases are limited to address critical bug fixes and security issues only.      

Please migrate your code to use AWS SDK for JavaScript (v3).
For more information, check the blog post at https://a.co/cUPnyil
(Use `node --trace-warnings ...` to show where the warning was created)
 FAIL  chrome.app
       Fetching stories
       SB_PREVIEW_API_0011 (StoryStoreAccessedBeforeInitializationError): Cannot access        the Story Store until the index is ready.
Some visual tests failed to run

Platform: Windows 10 Node v20.11.1

rhengles avatar Oct 17 '24 13:10 rhengles

I have the same error when running loki in CI with github actions:

yarn loki --requireReference --reactUri file:./storybook-static --chromeConcurrency=1

PASS chrome.docker/PREPARE
Waiting for 127.0.0.1:10098.
Connected!
PASS chrome.docker/START
FAIL chrome.docker/FETCH_STORIES: SB_PREVIEW_API_0011 (StoryStoreAccessedBeforeInitializationError): Cannot access the Story Store until the index is ready.
FAIL chrome.docker: Some tasks failed to run

ghusse avatar Oct 28 '24 07:10 ghusse

I looked at the code, and I suppose that the code that tests if a URL has been fully loaded is not working properly. If I increase the value of REQUEST_STABILIZATION_TIMEOUT to 5s I don't get the error anymore.

ghusse avatar Oct 28 '24 08:10 ghusse

@ghusse, how to change it?

evilPaprika avatar Dec 04 '24 07:12 evilPaprika

I did it with patch-package on my project to make it work.

ghusse avatar Dec 04 '24 07:12 ghusse

Hello is there any updates on this? I have similar issue but this error 'loki update: Cannot access the Story Store until the index is ready' only shows in M1 macOs.

NOI-lgtm avatar Jan 25 '25 19:01 NOI-lgtm

Hi! I changed the REQUEST_STABILIZATION_TIMEOUT like you suggested @ghusse and it worked. However, it made my tests much slower. Any idea on how to adjust the fix to not slow down the tests?

SammiKliv avatar Jan 29 '25 07:01 SammiKliv

diff --git a/src/commands/test/run-tests.js b/src/commands/test/run-tests.js
index 954460c8d2746d9f75648d59f8b214d83035378e..2eae0751e82c8264e7fac81942309e4aca6a0e89 100644
--- a/src/commands/test/run-tests.js
+++ b/src/commands/test/run-tests.js
@@ -127,7 +127,18 @@ async function runTests(flatConfigurations, options) {
               type: TASK_TYPE_FETCH_STORIES,
             },
             task: async () => {
-              storybook = await target.getStorybook();
+              while (true) {
+                try {
+                  storybook = await target.getStorybook();
+                } catch (e) {
+                  if (e.message.includes("until the index is ready")) {
+                    await new Promise(r => setTimeout(r, 500));
+                    continue;
+                  }
+                  throw e;
+                }
+                break;
+              }
               if (storybook.length === 0 && !options.passWithNoStories) {
                 throw new Error('Error: No stories were found.');
               }

I'm using this patch on @loki/runner, and 🤞 it's fixed our issues

freshollie avatar Jun 18 '25 15:06 freshollie