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 · 5 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 · 5 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?

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