weird errors dealing with env vars in convex functions
Hi team! I'm running into some weird errors
also when i try to use t3-oss/env-nextjs, im getting
does anyone have any idea? thanks!
// works when client is init in the func
export const sendEmail = action({
handler: async () => {
const resend = new Resend(process.env.RESEND_API_KEY)
await resend.emails.send({
...
})
},
})
// fails when client is init outside of the func
// 400 Bad Request: InvalidModules: Hit an error while pushing:
// Loading the pushed modules encountered the following
// error:
// Failed to analyze purchaseOrderFuncs.js: Uncaught Error: Missing API key. Pass it to the constructor `new // Resend("re_123")`
const resend = new Resend(process.env.RESEND_API_KEY)
export const sendEmail = action({
handler: async () => {
await resend.emails.send({
...
})
},
})
// works when client is init outside of the func but using the real API key
const resend = new Resend("re_MY_API_KEY")
export const sendEmail = action({
handler: async () => {
await resend.emails.send({
...
})
},
})// works when client is init in the func
export const sendEmail = action({
handler: async () => {
const resend = new Resend(process.env.RESEND_API_KEY)
await resend.emails.send({
...
})
},
})
// fails when client is init outside of the func
// 400 Bad Request: InvalidModules: Hit an error while pushing:
// Loading the pushed modules encountered the following
// error:
// Failed to analyze purchaseOrderFuncs.js: Uncaught Error: Missing API key. Pass it to the constructor `new // Resend("re_123")`
const resend = new Resend(process.env.RESEND_API_KEY)
export const sendEmail = action({
handler: async () => {
await resend.emails.send({
...
})
},
})
// works when client is init outside of the func but using the real API key
const resend = new Resend("re_MY_API_KEY")
export const sendEmail = action({
handler: async () => {
await resend.emails.send({
...
})
},
})also when i try to use t3-oss/env-nextjs, im getting
node_modules/@t3-oss/env-nextjs/dist/index.d.ts:50:434 - error TS2536: Type 'k' cannot be used to index type 'addQuestionMarks<{ [k_1 in keyof TServer]: TServer[k_1]["_output"]; }, requiredKeys<{ [k_1 in keyof TServer]: TServer[k_1]["_output"]; }>>'.node_modules/@t3-oss/env-nextjs/dist/index.d.ts:50:434 - error TS2536: Type 'k' cannot be used to index type 'addQuestionMarks<{ [k_1 in keyof TServer]: TServer[k_1]["_output"]; }, requiredKeys<{ [k_1 in keyof TServer]: TServer[k_1]["_output"]; }>>'.does anyone have any idea? thanks!
