Follow-up to #1725 (which fixed the compile error). hono/logger now compiles, but throws at runtime.
Repro (Perry @ main 65de8ec, hono@4.10)
import { Hono } from 'hono'
import { logger } from 'hono/logger'
const app = new Hono()
app.use('*', logger())
app.get('/', (c) => c.text('ok'))
const main = async () => {
const res = await app.fetch(new Request('http://localhost/'))
console.log('status', res.status, await res.text())
}
main().catch((e) => console.log('THREW', String(e?.message ?? e)))
Observed: THREW TypeError: test is not a function (deterministic). Via @hono/perry-server + serve(), every request returns HTTP 500.
What's odd / where it isn't
hono/utils/color's getColorEnabledAsync() — which the logger awaits in colorStatus — runs fine standalone (await getColorEnabledAsync() → true), even with import { Hono } present.
- It only fails when invoked inside the Hono middleware-execution path (
logger() → app.use → compose → await next() → colorStatus → getColorEnabledAsync).
- A custom
app.use('*', async (c, next) => { await next(); await getColorEnabledAsync() }) produces no output at all (the async/middleware chain silently breaks).
- The color helper's source has no
.test( — so test is not a function is coming from Perry's machinery (async-compose / dynamic-import-resolution for the import("cloudflare:workers") branch in getColorEnabledAsync), exposed only in this execution context.
So this is a context-sensitive codegen/async bug in the middleware path, not a missing API. It's the last gap on the #1655 acceptance program's app.use('*', logger()) line; the rest (HTML, JSON, query, POST) works end-to-end.
Related
Follow-up to #1725 (which fixed the compile error).
hono/loggernow compiles, but throws at runtime.Repro (Perry @ main 65de8ec, hono@4.10)
Observed:
THREW TypeError: test is not a function(deterministic). Via@hono/perry-server+serve(), every request returns HTTP 500.What's odd / where it isn't
hono/utils/color'sgetColorEnabledAsync()— which the logger awaits incolorStatus— runs fine standalone (await getColorEnabledAsync()→true), even withimport { Hono }present.logger()→app.use→compose→await next()→colorStatus→getColorEnabledAsync).app.use('*', async (c, next) => { await next(); await getColorEnabledAsync() })produces no output at all (the async/middleware chain silently breaks)..test(— sotest is not a functionis coming from Perry's machinery (async-compose / dynamic-import-resolution for theimport("cloudflare:workers")branch ingetColorEnabledAsync), exposed only in this execution context.So this is a context-sensitive codegen/async bug in the middleware path, not a missing API. It's the last gap on the #1655 acceptance program's
app.use('*', logger())line; the rest (HTML, JSON, query, POST) works end-to-end.Related