COMPOSED_HANDLER
mismatch when using different version of hono
#3760
Labels
COMPOSED_HANDLER
mismatch when using different version of hono
#3760
What version of Hono are you using?
4.6.14
What runtime/platform is your app running on? (with version if possible)
any
What steps can reproduce the bug?
Sorry to reproduce and explain this problem is super difficult.
For example, this problem occurs when using the SSG helper. Suppose there are two projects in a monorepo: one called
app
, which defines the application, and one calledssg
, which is used for SSG. If they are both using the same version ofhono
, there will be no problem. However, if they are using different versions, for example,app
is using4.6.13
andssg
is using4.6.14
, the SSG helper will not generate the files.Repro: https://github.com/yusukebe/composed-handler-mismatch
This happens when
onError
is defined insubApp
within theapp
application.This is because the handler to handle
GET /
request is marked as middleware not as a handler in the following code:hono/src/helper/ssg/utils.ts
Lines 65 to 68 in 4eb101d
The reason is that the Symbol
COMPOSED_HANDLER
is recognized as a different key if the version is different in the following locations.hono/src/utils/handler.ts
Lines 9 to 15 in 4eb101d
COMPOSED_HANDLER
is defined inhono-base.ts
.hono/src/hono-base.ts
Line 34 in 4eb101d
If you change the value of this
COMPOSED_HANDLER
to a string, this problem will be solved.Should it be a Symbol?
How about using a string like
__COMPOSED_HANDLER
instead of the Symbol? I think it is not a problem.Is this a rare case?
Yes, it's a rare case. But this causes the issues: honojs/honox#234 honojs/honox#236 in HonoX. The issue is not caused by a difference in the version of
hono
, but it has deep nested dependencies. That will be resolved if making it string.The text was updated successfully, but these errors were encountered: