Skip to content
This repository has been archived by the owner on Jun 20, 2024. It is now read-only.

Svelte app returns 502 #2

Open
elabx opened this issue Jun 19, 2024 · 5 comments
Open

Svelte app returns 502 #2

elabx opened this issue Jun 19, 2024 · 5 comments

Comments

@elabx
Copy link

elabx commented Jun 19, 2024

I am having an issue in a project where one of the proxied node apps is returning a 502, so I tried to reproduce it in your repository and it did exactly the same.

The steps I followed are:

  • Download repo
  • ddev start

The KeystoneCMS works correctly but the one that should be the svelte app returns a 502 from nginx.

Logs on web:

2024/06/19 03:41:55 [error] 2127#2127: *6 no live upstreams while connecting to upstream, client: 172.19.0.5, server: app.my-project.ddev.site, request: "GET / HTTP/1.1", upstream: "http://localhost/", host: "app.my-project.ddev.site"

Not sure if reproducible by anyone, I had a colleague with the same issue on Linux. I have tried this using ddev 1.23.0 - 1.23.2 with Orbstack and Docker Desktop.

@mandrasch
Copy link

Hi @elabx,

I git cloned it, started it with ddev start, got the same 502 on https://app.my-project.ddev.site/

I did

ddev ssh
pm2 stop all
cd svelte/
npm run dev

With that it responded sucessfully on https://app.my-project.ddev.site/ - so I guess it's something about the pm2 / pm2 configuration? (I'm not a pm2 expert myself yet)

@mandrasch
Copy link

mandrasch commented Jun 19, 2024

When I started it again with pm2 Svelte, Svelte(Kit) worked fine - but when I started keystone afterwards with pm2 Keystone again - keystone got the 502 Bad Gateway. 🕵️

@mandrasch
Copy link

mandrasch commented Jun 19, 2024

After I started them both again, it somehow worked in the end - maybe the 502 error is somewhere cached via nginx for some time? 🤔

ddev pm2 logs is also very helpful - it seemed to me, that they both get started after first request in browser and it can take some time for them to come online? But just checked it quickly.

(Here someone suggests increasing proxy_read_timeout - https://stackoverflow.com/a/63026555, but I'm not sure about that)

@mandrasch
Copy link

mandrasch commented Jun 19, 2024

Okay, sorry for all the messages. Should've put this into one report ;-)

After ddev restart everything worked fine.

I deleted the project and started it again

ddev delete -Oy
git clean -fdx
ddev start

There is the 502 error again and I can see in ddev pm2 logs, that there is first an error for both - and only after my first visit of https://app.my-project.ddev.site/ (SvelteKit) is started.

image

So my best current guess is that this has something to do with running npm install in pm2 and not beforehand - which then installs it and can take some time, therefore only the second request can succeed?

See apps.config.js, I guess the command is not ready in time for the first request since it has to install everything before it can be started (= longer than nginx timeout time?):

module.exports = {
  apps : [
    {
      name: "Svelte",
      cwd: "/var/www/html/svelte",
      script: "npm run dev || (rm -rf node_modules && npm install && npm run dev)"
    },
    {
      name: "Keystone",
      cwd: "/var/www/html/keystone",
      script: "npm run dev || (rm -rf node_modules && npm install && npm run dev)"
    }
  ]
}

btw: I'm on ddev version v1.23.2, Orbstack, Mac OSX.

@elabx
Copy link
Author

elabx commented Jun 19, 2024

Changing the vite server configuration 127.0.0.1 seems to fix this, can you test on your end @mandrasch?

#3

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

Successfully merging a pull request may close this issue.

2 participants