core
core copied to clipboard
hyperdrive is not included in the runtime instance
Describe the bug
I've setup cloudflare hyperdrive correctly in the nuxt.config.ts in bindings; I noticed that in wrangler.toml it does not generate the bindings, but maybe this is due to to not working locally.
I tested in on remote, and in the logs POSTGRES env does not show up; and the process.env.POSTGRES returns null, I've also logged : event.context.cloudflare.env which returns all other bindings, and env variables, but there's no POSTGRES env variable that binds to hyperdrive.
Steps to reproduce
- Setup the
hub.bindings.hyperdrive - create an API handler with logs for
process.env.POSTGRESorevent.context.cloudflare.env - call API
- No
hyperdrive
Expected behavior
POSTGRES should have hyperdrive bindings
Indeed we don't generate it for now: https://github.com/nuxt-hub/core/blob/33612ee58104fe4ed523e933ae45bcb9a1615a32/src/utils/wrangler.ts#L43-L58
The feature for local development in wrangler was released 4 days ago: https://github.com/cloudflare/workers-sdk/pull/6612
I will have a look this week to fix this
Hey @atinux cool, thank you, but there seem to be another issue actually, and why hyperdrive does not show up in runtime. The problem seem to be nodejs_compat_v2
https://developers.cloudflare.com/hyperdrive/configuration/connect-to-postgres/
- I've set it on
nuxt.configbut does not show up - I set it manually, and told me I must use
experimental:nodejs_compat_v2 - When used
experimental:nodejs_compat_v2still failed.Error: Failed to publish your Function. Got error: No such compatibility flag: experimental:nodejs_compat_v2
I'm not sure where to go from where, any idea?
This is how you can enable it:
export default defineNuxtConfig({
hub: {
bindings: {
compatibilityFlags: 'nodejs_compat_v2'
}
}
})
Doesn't seem to set it/change it. By any chance if this is set manually through cloudflare, it wont let nuxt overwrite the config, maybe?