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

Failed to load stories in chrome.docker, loki version 0.32.0 #473

Open
jamiepenney opened this issue Aug 23, 2023 · 9 comments · May be fixed by #474
Open

Failed to load stories in chrome.docker, loki version 0.32.0 #473

jamiepenney opened this issue Aug 23, 2023 · 9 comments · May be fixed by #474

Comments

@jamiepenney
Copy link

While running this command to update my local reference images: yarn build:storybook --quiet && loki update --requireReference --reactUri file:./storybook-static --chromeDockerImage yukinying/chrome-headless-browser-stable:latest

I'm getting the following error:

chrome.docker
       Fetching stories
       Failed fetching stories because the server is down
       Try starting it with "yarn storybook" or pass the --port or --host arguments if it's not running at http://192.168.1.131:49399

I have nailed this down to the chrome docker image not being able to access Storybook running on my host machine. I'm running this on an M1 Macbook running Docker Desktop 4.22.0, and if I enter the docker image while it is running then I can see that it is unable to access the host by running wget http://192.168.1.131:49399. If I access that URL locally, Storybook is successfully running on it.

If I manually edit the IP detection code on this line https://github.com/oblador/loki/blob/master/packages/target-chrome-docker/src/create-chrome-docker-target.js#L70 to instead always use host.docker.internal as the IP, then everything works correctly.

Is there a reason not to use host.docker.internal as the local IP address by default? An earlier commit added the docker argument required to ensure this works correctly on Linux: --add-host=host.docker.internal:host-gateway.

I'm not sure of the broader implications of this change. There doesn't appear to be any way to override the IP address when you are using the static Storybook build option, but I could add one if you think it's too risky to use host.docker.internal by default.

@huyit88
Copy link

huyit88 commented Aug 23, 2023

Yes, i got the same problem . Can you @jamiepenney elaborate your workaround on mac?
What do you change to make it work?
Thanks!

jamiepenney added a commit to jamiepenney/loki that referenced this issue Aug 23, 2023
Resolves oblador#473

Fixes an issue where the Chrome docker container cannot access Storybook running on the host machine via IP address, instead using the Docker `host.docker.internal` DNS entry to get access to it.
@jamiepenney
Copy link
Author

jamiepenney commented Aug 23, 2023

@huyit88 I've made a draft PR with my suggested changes. There's nothing you can do from a configuration perspective to fix it, but you could patch your local loki files in your node_modules in the mean time. The file is at node_modules/@loki/target-chrome-docker/src/create-chrome-docker-target.js

@huyit88
Copy link

huyit88 commented Aug 23, 2023

Thank you.
It works.
I am not sure why it's relative to host issue. Be the way, With different network provider, the results are also different.
I able to run loki test at my company but get the same error when i run it at home and can't figure it out why.
Not sure if this workaround can apply for below issue.
#142
Anyway, thank for your input.

@fttneto
Copy link

fttneto commented Nov 4, 2023

I'm trying for a while to run Loki with chrome.docker settings and the only way I found to get it working is by replacing the code suggested in the PR opened by @jamiepenney and also running it through build and passing --reactUri option.

Trying to run it using yarn storybook will make the process fail with the same error that @jamiepenney said here.

So here's my question, @oblador, is still the intention for #474 to be merged? It's been there for a while, and if there's something needed of contribution I would be glad to contribute to this repository so that PR got merged.

jamiepenney added a commit to jamiepenney/loki that referenced this issue Jan 8, 2024
Resolves oblador#473

Fixes an issue where the Chrome docker container cannot access Storybook running on the host machine via IP address, instead using the Docker `host.docker.internal` DNS entry to get access to it.
@eraf2135
Copy link

I'm experiencing this same issue and updating these lines of code worked for me locally also.
It would be great to get PR #474 merged. Anything in particular blocking it?

@SergeyBrukov
Copy link

Hello everybody)
I'm having a lot of trouble connecting loki to ci/cd
The error Failed fetching stories because the server is down keeps falling

Maybe someone connected story book 8 to loki and, accordingly, to ci/cd ?
"test:ui": "npx loki test",
"test:ui:ci": "npm run storybook & wait-on http://localhost:9009 && npm run test:ui",

"build-storybook": "pnpm run build:tokens && pnpm run copy-required && npx storybook build -c .storybook -o ./storybook-static && npx loki --requireReference --reactUri file:./storybook-static",

"test-visual": "loki test",

"update-visual": "yarn loki update -- --port 9009",

"test:loki:test": "npx start-server-and-test http://localhost:9009 test-visual",

"test:ui:build": "pnpm loki test --requireReference --reactUri file:./public --chromeFlags='--headless --disable-gpu --hide-scrollbars --no-sandbox' --port 9009",

"test:ui:ci:new": "concurrently --kill-others --raw --success first \"pnpm run test:ui:build --host localhost --port 9009\" \"deelay\""

const target = process.env.CI ? "chrome.app" : "chrome.docker";

module.exports = {
configurations: {
"chrome.laptop": {
target,
chromeDockerImage: "yukinying/chrome-headless-browser-stable:123.0.6312.86",
width: 1366,
height: 768,
deviceScaleFactor: 1,
mobile: false,
},
},
storiesFilter:
"^((?!Card|MainBannerV2|MainBanner|Menu|Event|ImageLazyLoader|GiftPromo|Popover|HomeTilesItem|Spinner|SportBanner|Flip|InputPassword).)*$",
reactUri: process.env.CI ? "http://localhost:9009" : "file:./public",
};

run-loki:
stage: run-loki
script:
- pnpm run i
- pnpm run start:storybook:ci > storybook.log 2>&1 & # Запуск Storybook у фоновому режимі
- npx wait-on http://localhost:9009 --timeout 60000 # Очікування доступності Storybook (збільшивши таймаут)
- cat storybook.log
- pnpm run test:loki:test
artifacts:
name: "loki"
expire_in: 1 hour
paths:
- .loki/difference/
- .loki/reference/
- .loki/current/
- storybook.log
when: always

@Vorbert-Kruk
Copy link

I'm experiencing this same issue and updating these lines of code worked for me locally also. It would be great to get PR #474 merged. Anything in particular blocking it?

Bumping the question.
Can we do anything to assist with progression on the #474 @jamiepenney?

jamiepenney added a commit to jamiepenney/loki that referenced this issue Sep 2, 2024
Resolves oblador#473

Fixes an issue where the Chrome docker container cannot access Storybook running on the host machine via IP address, instead using the Docker `host.docker.internal` DNS entry to get access to it.
@jamiepenney
Copy link
Author

@Vorbert-Kruk I pushed up the PR initially but PR build actions require a maintainer to run, the feedback loop to get the PR building was too long so I left it hoping the maintainers would take the fix and run with it. I'll have another crack at it now, hopefully it doesn't need any other changes

@Vorbert-Kruk
Copy link

@jamiepenney Thanks for sharing how to process is looking.
Indeed one of the pipeline steps was failing, but it appears that after running it again, it passes 🎉
Seems that CI gods are with us! 😄

As maintainer still would be necessary for pushing this code further (they approval is necessary), I'll try to notify them under #474.
Hope that it will enable us to move forward.

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