Not able to use @google-cloud/speech
I am not able to use @google-cloud/speech package when i import it and just initialize class like below
import speech from '@google-cloud/speech'
// Initialize Google Speech Client
const client = new createClient.SpeechClient({
credentials: {
client_email: env.GOOGLE_CLIENT_EMAIL,
private_key: env.GOOGLE_PRIVATE_KEY
}
});
Error
service core:user:voice-call-handler-dev: Uncaught TypeError: Cannot convert object to primitive value
at null.<anonymous> (index.js:18912:101) in isEnabled
at null.<anonymous> (index.js:18915:35) in refresh
at null.<anonymous> (index.js:18956:13) in
../node_modules/.pnpm/[email protected]/node_modules/google-logging-utils/build/src/colours.js
at null.<anonymous> (index.js:19:51) in require2
at null.<anonymous> (index.js:19013:21) in
../node_modules/.pnpm/[email protected]/node_modules/google-logging-utils/build/src/logging-utils.js
at null.<anonymous> (index.js:19:51) in require2
at null.<anonymous> (index.js:19269:18) in
../node_modules/.pnpm/[email protected]/node_modules/google-logging-utils/build/src/index.js
at null.<anonymous> (index.js:19:51) in __require2
at null.<anonymous> (index.js:19318:18) in
../node_modules/.pnpm/[email protected]/node_modules/gcp-metadata/build/src/index.js
2 Replies
Having the exact same issue with "@googleapis/gmail". I'm able to work around this by deploying via "wrangler pages deploy ." or something similar. Not sure if there's a way to access and debug the files built for cloudflare page functions so I'm at an impass for automatic deployments as well.
@Aakash You can patch it out using patch package and editing the code mentioned in this issue. At least that's what worked for me.
Not sure how to point anyone in cloudflare or Google to take a look at this bug but it should be relatively quick to fix via updated polyfill or that try-catch block. Even if I write a pull request, not sure how long that will take to get looked at so just not going to bother.
npm
patch-package
Fix broken node modules with no fuss. Latest version: 8.0.0, last published: 2 years ago. Start using patch-package in your project by running
npm i patch-package
. There are 1116 other projects in the npm registry using patch-package.GitHub
Issue with importing from
@google/genai/node
fails in Cloudflare ...Problem When importing directly from @google/genai/node in a Cloudflare Worker, the application fails due to limited Node.js compatibility in the Workers environment. The specific error occurs in t...