-
-
Notifications
You must be signed in to change notification settings - Fork 43
Bun adapter does not pass server to Hono fetch #187
Description
Describe the feature
the bun adapter only provides the Request argument to fetchHandler. as a result, when using with hono + bun, the hono Env isn't being populated with the bun server.
hono's fetch function accepts the bun server (or cloudflare env) as an optional second argument: https://github.com/honojs/hono/blob/790c57baa24b628a37b95025a8d41b1911b99d5d/src/hono-base.ts#L475
locally, passing the server as a second argument resolves the issue:
return fetchHandler(request, server);neither the bun nor cloudflare adapter passes the server/env. i expect that for cloudflare apps, the env import can be used instead, but i'm not aware of an equivalent for bun.
i'm really enjoying using srvx (via vike), but the inability to access the server is a blocker. currently i'm trying to get the remote info. i see that the remote ip is added to the request, but the other Bun.SocketAddress properties are omitted, and it's necessary to brute-force the type safety when consuming via hono Context:
import type { Context } from 'hono'
const exampleHandler = async (c: Context) => {
const ip = 'ip' in c.req.raw && typeof c.req.raw.ip === 'string'
? c.req.raw.ip
: null
}it seems like an easy fix, and i'm happy to open a PR to address, but i understand that there may be downstream consequences i'm unaware of. i appreciate your consideration, and thanks for a great library!
Additional information
- Would you be willing to help implement this feature?