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

Cloudflare Browser Rendering worker not showing up #381

Open
austinprice opened this issue Nov 19, 2024 · 8 comments
Open

Cloudflare Browser Rendering worker not showing up #381

austinprice opened this issue Nov 19, 2024 · 8 comments

Comments

@austinprice
Copy link

Describe the bug
I configured browser rendering using the hub config and hubBrowser(). It's working locally but when deploying, the browser rendering page in Cloudflare is empty and my API endpoint is not executing the functionality using hubBrowser(). I looked in the docs and searched the issues here, but sorry if I missed something.

Is there anything else I need to do to get browser rendering set up besides setting browser: true in the hub config?

image

Steps to reproduce
Steps to reproduce the behavior:

  1. Add browser: true to hub in nuxt.config.ts. In my API route, use hubBrowser()
  2. Test that endpoint works as expected locally
  3. Push up to Github, trigger deployment

When I test on prod, the function silently does not handle anything after initiating hubBrowser(). I have a few console statements printing just to help debug, and only see the one that prints before hubBrowser() is initiated.

@austinprice
Copy link
Author

This is the code in my API route, for reference:

const { page } = await hubBrowser()
await page.goto(siteUrl, { waitUntil: 'networkidle0' })

And here is my nuxt.config.ts:

export default defineNuxtConfig({
  compatibilityDate: '2024-04-03',
  devtools: { enabled: true },
  css: [
    './assets/css/tailwind.css',
    './assets/css/main.css',
  ],
  ssr:true,
  modules: [
    '@nuxthub/core',
    '@nuxtjs/tailwindcss',
    'shadcn-nuxt',
    '@nuxtjs/supabase',
    '@nuxt/icon',
  ],
  hub: {
    browser: true,
    kv: true
  },
  tailwindcss: {
    configPath: './tailwind.config.js',
  },
  shadcn: {
    prefix: '',
    componentDir: './components/ui'
  },
  supabase: {
    url: process.env.SUPABASE_URL,
    key: process.env.SUPABASE_KEY,
    redirectOptions: {
      login: '/login',
      callback: '/confirm'
    }
  },
  runtimeConfig: {
    OPENAI_API_KEY: process.env.OPENAI_API_KEY
  }
})

Copy link
Contributor

atinux commented Nov 19, 2024

How did you deploy your project, using the NuxtHub or the NuxtHub admin?

Copy link
Contributor

atinux commented Nov 19, 2024

I just tested deploying a small demo using hubBrowser(), deployed with nuxthub deploy and it works seamlessly:

CleanShot 2024-11-20 at 00.32.49@2x.png

CleanShot 2024-11-20 at 00.33.53@2x.png

@austinprice
Copy link
Author

I configured everything through the admin initially. Let me try running through nuxthub deploy

@austinprice
Copy link
Author

I ran npx nuxthub deploy and got a successful deployment, but the browser rendering is still showing as 0 sessions and the API behavior is unchanged. I do have a paid worker plan as well.

I'll continue to debug this and report back what I find. Just wanted to make sure there wasn't anything obvious I was missing.

@atinux
Copy link
Contributor

atinux commented Nov 19, 2024

Keep me updated, this is quite annoying :(

@austinprice
Copy link
Author

Will do, appreciate the quick reply

@austinprice
Copy link
Author

I figured out the issue, it was complete user error on my part. My API route that was using hubBrowser() was returning a response before the browser could initiate. It worked locally because it was running in the background after returning a response. After fixing that, everything worked without a hitch.

Sorry for the false alarm!

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