You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is a really handy way of getting started with Payload and Astro, which otherwise requires a bunch of moving parts. But both times I've first run yarn dev after downloading the repo and then hitting localhost, the process crashes. Seems like just killing it and running it again works, so there's maybe some timing issue.
I've installed with npx degit mooxl/astroad my-test, which should just download a clean copy of the repo.
Then I go into my-test and run yarn dev. After all the docker logs, the containers start, and the log messages seem to stop, like everything is set up. Among the mongo logs, I see the logs for Astro, like:
astroad-astro | 🚀 astro v2.10.12 started in 714ms
astroad-astro |
astroad-astro | ┃ Local http://localhost:3000/
astroad-astro | ┃ Network http://172.22.0.3:3000/
So I hit localhost:3000, but that shows an error in the logs:
astroad-astro | error Unexpected token '<', "<!DOCTYPE "... is not valid JSON
astroad-astro | File:
astroad-astro | /base/src/utils/payload.ts:8:4
astroad-astro | Code:
astroad-astro | 7 | export const getPosts = async () =>
astroad-astro | > 8 | (await (await fetch(`${url}/api/posts`)).json()).docs as Post[];
astroad-astro | | ^
astroad-astro | 10 | export const getPost = async (id: string) =>
astroad-astro | 11 | (await (await fetch(`${url}/api/posts/${id}`)).json()) as Post;
astroad-astro | Stacktrace:
astroad-astro | SyntaxError: Unexpected token '<', "<!DOCTYPE "... is not valid JSON
astroad-astro | at JSON.parse (<anonymous>)
astroad-astro | at parseJSONFromBytes (node:internal/deps/undici/undici:5329:19)
astroad-astro | at successSteps (node:internal/deps/undici/undici:5300:27)
astroad-astro | at fullyReadBody (node:internal/deps/undici/undici:1447:9)
astroad-astro | at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
astroad-astro | at async specConsumeBody (node:internal/deps/undici/undici:5309:7)
astroad-astro | at async Module.getPosts (/base/src/utils/payload.ts:8:4)
astroad-astro | at async eval (/base/src/pages/index.astro:5:15)
astroad-astro | at async callComponentAsTemplateResultOrResponse (file:///base/node_modules/astro/dist/runtime/server/render/astro/render.js:85:25)
astroad-astro | at async renderToReadableStream (file:///base/node_modules/astro/dist/runtime/server/render/astro/render.js:35:26)
astroad-astro |
After that, I see a message about MongoDB being ready, so maybe it was still starting when I hit the page?
astroad-mongo |
astroad-mongo | MongoDB init process complete; ready for start up.
astroad-mongo |
And a little below that there's a crash from payload:
astroad-payload | [22:04:22] ERROR (payload): Error: cannot connect to MongoDB. Details: connect ECONNREFUSED 172.23.0.2:27017
astroad-payload | [nodemon] app crashed - waiting for file changes before starting...
But if I then just hit ctrl-C and run yarn dev again, everything works fine. I'm guessing that maybe mongo wasn't fully set up when Payload was trying to connect to it on first install, and on the second launch it was. But I'm not sure how to debug that.
The above logs were from my second attempt. The first time I also got an Astro error, but a different one. The effect was the same, though.
This is a really handy way of getting started with Payload and Astro, which otherwise requires a bunch of moving parts. But both times I've first run
yarn dev
after downloading the repo and then hitting localhost, the process crashes. Seems like just killing it and running it again works, so there's maybe some timing issue.I've installed with
npx degit mooxl/astroad my-test
, which should just download a clean copy of the repo.Then I go into
my-test
and runyarn dev
. After all the docker logs, the containers start, and the log messages seem to stop, like everything is set up. Among the mongo logs, I see the logs for Astro, like:So I hit
localhost:3000
, but that shows an error in the logs:After that, I see a message about MongoDB being ready, so maybe it was still starting when I hit the page?
And a little below that there's a crash from payload:
But if I then just hit
ctrl-C
and runyarn dev
again, everything works fine. I'm guessing that maybe mongo wasn't fully set up when Payload was trying to connect to it on first install, and on the second launch it was. But I'm not sure how to debug that.The above logs were from my second attempt. The first time I also got an Astro error, but a different one. The effect was the same, though.
The text was updated successfully, but these errors were encountered: