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

hyperdrive is not included in the runtime instance #279

Open
9M6 opened this issue Sep 14, 2024 · 4 comments
Open

hyperdrive is not included in the runtime instance #279

9M6 opened this issue Sep 14, 2024 · 4 comments

Comments

@9M6
Copy link

9M6 commented Sep 14, 2024

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

  1. Setup the hub.bindings.hyperdrive
  2. create an API handler with logs for process.env.POSTGRES or event.context.cloudflare.env
  3. call API
  4. No hyperdrive

Expected behavior
POSTGRES should have hyperdrive bindings

@atinux
Copy link
Contributor

atinux commented Sep 14, 2024

Indeed we don't generate it for now:

// Disabled until getPlatformProxy() returns the hyperdrive binding
// if (hub.bindings?.hyperdrive) {
// wrangler['hyperdrive'] = Object.entries(hub.bindings.hyperdrive).map(([key, value]) => {
// const envKey = `NUXT_HUB_HYPERDRIVE_${key.toUpperCase()}_URL`
// const localConnectionString = process.env[envKey]
// if (nuxt.options.dev && !localConnectionString) {
// console.error(`Missing \`${envKey}\` environment variable for Hyperdrive binding \`${key}\` (ID: ${value}).`)
// process.exit(1)
// }
// return {
// binding: key,
// id: value,
// localConnectionString
// }
// })
// }

The feature for local development in wrangler was released 4 days ago: cloudflare/workers-sdk#6612

I will have a look this week to fix this

@9M6
Copy link
Author

9M6 commented Sep 14, 2024

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/

CleanShot 2024-09-14 at 13 03 28@2x

  1. I've set it on nuxt.config but does not show up
  2. I set it manually, and told me I must use experimental:nodejs_compat_v2
  3. When used experimental:nodejs_compat_v2 still 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?

@atinux
Copy link
Contributor

atinux commented Sep 14, 2024

This is how you can enable it:

export default defineNuxtConfig({
  hub: {
    bindings: {
      compatibilityFlags: 'nodejs_compat_v2'
    }
  }
})

@9M6
Copy link
Author

9M6 commented Sep 14, 2024

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?

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

No branches or pull requests

2 participants