Closed smoothdvd closed 4 days ago
Hi, thank you for reporting this issue. There is no official Next.js support, but if you willing to make a PR that solves this issue, I'll more than happy to review it :]
Maybe cause by this Hono 4.6.9 update: refactor: use # for private methods to reduce the minified file size by @yusukebe in https://github.com/honojs/hono/pull/3596
Not using nextJs, but seeing the same error with 6.3.3 and @hono/node-server. Pinning hono to 4.6.8 fixes the problem. Agree with @smoothdvd that it's likely caused by https://github.com/honojs/hono/pull/3596
Hi @stephencoffey can you share a small repo that reproduces the issue? Where is the code that tries to touch Hono's private members?
the issue is coming from Hono 4.6.9
for the moment pin version 4.6.8
, and you are ready to go.
Hi @stephencoffey can you share a small repo that reproduces the issue? Where is the code that tries to touch Hono's private members?
Hi @felixmosh - steps to recreate here: https://github.com/stephencoffey/bull-board-issue-843-example
No longer reproducible with hono 4.6.10
@felixmosh Looks like HonoAdapter.ts is not compatible with the latest hono app:
in hono-base.ts, the errorHandler is #errorHandler now.
app.routes.map((r) => {
let handler
if (app.#errorHandler === errorHandler) {
handler = r.handler
} else {
handler = async (c: Context, next: Next) =>
(await compose<Context>([], app.#errorHandler)(c, () => r.handler(c, next))).res
;(handler as any)[COMPOSED_HANDLER] = r.handler
}
subApp.#addRoute(r.method, r.path, handler)
})
HonoAdapter.ts
setErrorHandler(handler: (error: Error) => ControllerHandlerReturnType): this {
this.errorHandler = handler;
return this;
}
This will lead error of "TypeError: Cannot read private member #errorHandler from an object whose class did not declare it" when grouping other HonoAdapter's Hono instance in Honor routes.
app.route('/bull-board', serverAdapter.registerPlugin())
@smoothdvd please update to Hono 4.6.10 (which solved this issue...)
@felixmosh I already upgrade to Hono 4.6.10.
I've just tested it locally, with the example (with-hono), with 4.6.9, it fails, with 4.6.10 it works as expected.
weird stuff....
if you use require
works, no issue
const { Hono } = require('hono');
if you use import
throws, some issue
import { Hono } from "hono";
Cannot access invalid private field (evaluating 'app.#errorHandler')
weird stuff....
if you use
require
works, no issueconst { Hono } = require('hono');
if you use
import
throws, some issueimport { Hono } from "hono";
Cannot access invalid private field (evaluating 'app.#errorHandler')
Actually it is not weird, since Node applies the private field validation on ESM only
OK, but this is an issue that we need to solve @felixmosh I think you need to reopen the issue!!!
We should use onError
instead...
Will you open a PR
I've tested the code, looks like this is related to Hono,
When using the pattern of app.route('/', new Hono())
, the code above, tries to access a private property of the second Hono instance. which is wrong.
@felixmosh the issue is solved on Hone v4.6.11
PR: https://github.com/honojs/hono/pull/3692 Relase: https://github.com/honojs/hono/releases/tag/v4.6.11
Can we close this issue?
Sorry for the trouble!
I use hono in nextjs 15 like this
rollback to hono 4.6.8, there is no issue anymore