-
Notifications
You must be signed in to change notification settings - Fork 595
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
π BUG: "Cannot convert object to primitive value" at publish time #2081
Comments
This is very interesting. I would be interested in chatting more on this, are you on the Cloudflare Discord? |
@JacobMGEvans did y'all reach any conclusions on this? |
Not currently, no. |
Hi There, I think I'm having the same issue with a Nuxt 3 build to Cloudflare Pages Functions. I've created a StackBlitz with a minimal reproduction: https://stackblitz.com/edit/nuxt-wrangler-firebase-bug?file=server/middleware/admin.ts My environment detailsnode -v
v16.18.1 yarn wrangler -v
β
οΈ wrangler 2.4.4 yarn nuxt -v
Nuxi 3.0.0 |
Exact same issue here, using Firebase Admin too, Nuxt 3, Nitro. |
One of the ways I found to work around this problem is to overwrite some things in the build: file: grpc-js/build/src/server-call.js const http2HeaderStatusSafe = ':status';
const http2HeaderContentTypeSafe = 'content-type';
const httpStatusOk = 200
const defaultResponseHeaders = {
// TODO(cjihrig): Remove these encoding headers from the default response
// once compression is integrated.
[GRPC_ACCEPT_ENCODING_HEADER]: 'identity,deflate,gzip',
[GRPC_ENCODING_HEADER]: 'identity',
[http2HeaderStatusSafe]: httpStatusOk,
[http2HeaderContentTypeSafe]: 'application/grpc+proto',
}; |
This looks very good. How did you do the overwriting? Did you manually mock the http2 or did you patch it with pnpm? Or something? |
I'm working inside of a monorepo, so cloned the grpc-js repository into the project and added the path in pnpm overrides: {
"name": "@brendonmatos/web",
"version": "1.0.0",
"private": true,
"scripts": {
"build": "turbo run build",
"test": "turbo run test",
"lint": "turbo run lint",
"dev": "turbo run dev"
},
"workspaces": {
"packages": [
"packages/*",
"apps/*"
]
},
"pnpm": {
"overrides": {
"@grpc/grpc-js": "./packages/grpc-js"
}
}
} |
@JacobMGEvans Yes! I'm on Cloudflare Server, Brendon#8334 |
I'm experiencing the same problem when pushing a Nuxt 3 web app that returns non-string values from its API endpoints. |
The |
After some troubleshooting, I've figured the This is still related to Cloudflare since the |
Hi everyone. The Environment |
I am also experincing this issue. Also with Nuxt 3, Nitro, Firebase, Cloudflare Workers. I am not using nuxt-security. Will update if I find a workaround. |
Firebase uses -> grpc-js, that uses -> http2 It seems that the problem lies in the failure or lack of implementation of this http2 polyfill in workers runtime. |
Thank you. I hope this issue will be resolved. I was then able to display the OGP image in SPA, so I reverted the app back to SPA again. It was my lack of awareness. Now it works with Cloudflare Pages without any problem. |
Related unjs/unenv#86 |
I have the same issue trying to use the @AWS-SDK v3 in a Nuxt 3 project deploying to Cloudflare Pages with wrangler, it works fine in local Nuxt 3 builds and also when deploying to Vercel though. The aws-sdk works perfectly fine in a browser environment too, but somehow it thinks its running in a full node environment when building with the Nuxt3/Nitro cloudflare_pages preset for Cloudflare/wrangler, is there any way to tell it to just use browser mode?
|
I have a similar issue related to mailgun.js. I tried to send an email locally, and it works perfectly. However, on Cloudflare Page, it returns a status code 500 and an error message: 'Cannot convert object to primitive value.' Could you help me identify which part is causing the issue? here is my package.json and here is my mailgun code: export default defineEventHandler(async (event: any) => { const mg = mailgun.client({ username: 'api', key: process.env.MAILGUN_KEY || '' }) const body = await readBody(event) const data = { return mg.messages |
@brendonmatos Interesting to close this issue. Can you give a bit of context how you solved the issue / why it is no longer an issue? Thank you. |
I genuinely feel that this might not be directly associated with Cloudflare itself. It appears to be more of a Nuxt/Nitro/Unenv issue, as indicated in the related issues. unjs/unenv#86 |
If you are using I just needed to create a plugin to work with Nuxt running locally (no need for Worker). I set the environment by the export default defineNuxtPlugin(() => {
const config = useRuntimeConfig();
if (process.server && config.public.env.toLocaleLowerCase() !== 'prod') {
const crypto = require('crypto');
global.crypto = crypto;
}
}) |
What version of
Wrangler
are you using?2.1.13
What operating system are you using?
Mac M1
Describe the Bug
Pushing my nuxt 3 website from local and github actions, I get the following error:
It's kind of weird because I have two nuxt projects in the same monorepo and only this one gives this error. The only difference between these two projects is the one with the problem I'm using Firebase Firestore .
Running locally + some console.log's
Logging the http2 in the setup phase
Logging the http2 in the "execution phase"
This difference is causing the problem when using these values as dynamic map key.
The text was updated successfully, but these errors were encountered: