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

Cloudflare pages deployment issue #1679

Open
AsyncFox opened this issue Aug 30, 2023 · 4 comments
Open

Cloudflare pages deployment issue #1679

AsyncFox opened this issue Aug 30, 2023 · 4 comments

Comments

@AsyncFox
Copy link

AsyncFox commented Aug 30, 2023

Environment

Nuxt 3.7
Nitro 2.6.2
Cloudflare Wrangler 3.6.0

Reproduction

StackBlitz: https://stackblitz.com/github/AsyncFox/nuxt-trpc-drizzle-repro
Github repo: https://github.com/AsyncFox/nuxt-trpc-drizzle-repro

Describe the bug

After nuxi build , I tried wrangler pages dev dist/ to run locally, but it shows an error. I also tried deploy to cloudflare pages but it also failed.
Using nuxi dev works fine.

Additional context

I am using trpc-nuxt and drizzle-orm.
If you remove other procedures and only reserve hello procedure in server\trpc\routers\index.ts, it works fine.
I guess it is also drizzle-orm related because hello procedure does not require any db operation.

Logs

Starting local server...
[mf:wrn] The latest compatibility date supported by the installed Cloudflare Workers Runtime is "2023-08-14", but you've requested "2023-08-30". Falling back to "2023-08-14"...
service core:user:worker: Uncaught TypeError: P.exit is not a function
  at 1pqueguojs8.js:6475:119
X [ERROR] MiniflareCoreError [ERR_RUNTIME_FAILURE]: The Workers runtime failed to start. There is likely additional logging output above.

And on cloudflare pages:

Error: Failed to publish your Function. Got error: Uncaught TypeError: P.exit is not a function
  at functionsWorker-0.297748013825073.js:6386:119
@Hebilicious
Copy link
Member

Hebilicious commented Sep 1, 2023

Hi @AsyncFox, this might be related to the fact that cloudflare doesn't support the postgres package, could you try with pg ? https://developers.cloudflare.com/workers/databases/connect-to-postgres/#requirements
This is because workerd doesn't support TCP and needs a compatible driver to connect to postgres instances.

@AsyncFox
Copy link
Author

AsyncFox commented Sep 1, 2023

Hi @Hebilicious , I tried pg but when using nuxi build it generates a new error. I found a discussion post related to this but it was not helpful to this situation. But anyway, thanks for your reach out, I have temporarily moved to vercel for deployment.

Logs

[nitro 22:47:00]  ERROR  Error: Cannot resolve "pg-native" from "\\node_modules\\.pnpm\\pg@8.11.3\\node_modules\\pg\\lib\\native\\client.js" and externals are not allowed!

@Hebilicious
Copy link
Member

Hebilicious commented Sep 1, 2023

Hi @Hebilicious , I tried pg but when using nuxi build it generates a new error. I found a discussion post related to this but it was not helpful to this situation. But anyway, thanks for your reach out, I have temporarily moved to vercel for deployment.

Logs

[nitro 22:47:00]  ERROR  Error: Cannot resolve "pg-native" from "\\node_modules\\.pnpm\\pg@8.11.3\\node_modules\\pg\\lib\\native\\client.js" and externals are not allowed!

I tried building your project on stackblitz by swapping out postgres for pg and did not encounter a build error.
Are you able to build with pg for vercel, but not for cloudflare-pages ?

@AsyncFox
Copy link
Author

AsyncFox commented Sep 2, 2023

Are you able to build with pg for vercel, but not for cloudflare-pages ?

Yes, that's right. Building for vercel works fine, but not for cloudflare-pages

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

No branches or pull requests

2 participants