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

onlySSG middleware not support Cloudflare worker #2476

Closed
iflamed opened this issue Apr 8, 2024 · 1 comment · Fixed by #2477
Closed

onlySSG middleware not support Cloudflare worker #2476

iflamed opened this issue Apr 8, 2024 · 1 comment · Fixed by #2477
Labels

Comments

@iflamed
Copy link

iflamed commented Apr 8, 2024

What version of Hono are you using?

4.2.2

What runtime/platform is your app running on?

Cloudflare Workers

What steps can reproduce the bug?

Demo Code:

import { Hono } from 'hono'
import { onlySSG } from 'hono/ssg'

const app = new Hono()

app.get('/', onlySSG(), (c) => {
  return c.html('<h2>Hello Hono!</h2>')
})

export default app

Run command: npm run dev, will got error.

What is the expected behavior?

Miniflare start normal without error.

What do you see instead?

✘ [ERROR] service core:user:pagereader: Uncaught Error: Disallowed operation called within global scope. Asynchronous I/O (ex: fetch() or connect()), setting a timeout, and generating random values are not allowed within global scope. To fix this error, perform this operation within a handler. https://developers.cloudflare.com/workers/runtime-apis/handlers/

at null.<anonymous> (index.js:1521:29)

✘ [ERROR] MiniflareCoreError [ERR_RUNTIME_FAILURE]: The Workers runtime failed to start. There is likely additional logging output above.

Additional information

I has install the vite-ssg plugin with this command: npm i -D vite @hono/vite-ssg

@iflamed iflamed added the bug label Apr 8, 2024
@usualoma
Copy link
Member

usualoma commented Apr 8, 2024

Hi @iflamed

Thanks for the report!

There seems to be an error in the following line. We will look into how to fix it.

export const SSG_DISABLED_RESPONSE = new Response('SSG is disabled', { status: 404 })

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

Successfully merging a pull request may close this issue.

2 participants