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

Hono starter application silently failing #331

Open
radu-matei opened this issue Feb 8, 2025 · 3 comments
Open

Hono starter application silently failing #331

radu-matei opened this issue Feb 8, 2025 · 3 comments
Labels
bug Something isn't working

Comments

@radu-matei
Copy link
Member

I'm trying to use the Hono framework: https://hono.dev/docs/

From the starter TypeScript template, I ran npm install hono, then added the quickstart from the docs:

import { Hono } from 'hono'

const app = new Hono()

app.get('/', (c) => c.text('Hono!'))

export default app

spin build is successful, but running results in a silent failure:

curl localhost:3001 -v
* Host localhost:3001 was resolved.
* IPv6: ::1
* IPv4: 127.0.0.1
*   Trying [::1]:3001...
* connect to ::1 port 3001 from ::1 port 54069 failed: Connection refused
*   Trying 127.0.0.1:3001...
* Connected to localhost (127.0.0.1) port 3001
> GET / HTTP/1.1
> Host: localhost:3001
> User-Agent: curl/8.7.1
> Accept: */*
>
* Request completely sent off
< HTTP/1.1 500 Internal Server Error
< transfer-encoding: chunked
< date: Sat, 08 Feb 2025 01:40:15 GMT
<
* Connection #0 to host localhost left intact

ref #330 for the silent error, as nothing is logged in the component logs.

@radu-matei radu-matei added the bug Something isn't working label Feb 8, 2025
@radu-matei
Copy link
Member Author

Manually calling app.fetch in the fetch event handler solved the issue:

import { Hono } from 'hono'

const app = new Hono()

app.get('/', (c) => c.text('Hono!'))


//@ts-ignore
addEventListener('fetch', async (event: FetchEvent) => { event.respondWith(app.fetch(event.request)) });

I think it would be incredibly helpful to handle the export default pattern as well.

@radu-matei
Copy link
Member Author

Oh nice, just discovered the app.fire() pattern:

import { Hono } from 'hono'

const app = new Hono()

app.get('/', (c) => c.text('Hono!'))


app.fire()

@karthik2804
Copy link
Collaborator

@tschneidereit would it be possible to check if handlers are attached to the fetchEvent during wizer time? The issue here comes from us keeping the fetchEvent around if we do not explicitly implement the wasi-http export and failing to attach a handler to the event.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants