Hey, I have an application that has been using express and I'd like to replace it with hono, but in the development mode the app is using 3 express middlewares (webpack-dev-middleware, webpack-hot-middleware and connect-history-api-fallback) that I can not simply "drop".
The thing is each time I allow the hono middleware to resolve the ERR_HTTP_HEADERS_SENT error is being thrown. The only solution that I've figured is to leak memory by not resolving the middleware:
app.use(
async (c, next) => {
try {
const { resolve, reject, promise: deferred } = defer<void>()
const {
incoming,
outgoing,
} = c.env
outgoing.once('finish', reject)
await devMiddleware(
incoming,
outgoing,
resolve,
)
await deferred
// `deferred` is resolved, it means `next` has been called in the express middleware, so hono's next can also be called
await next()
} catch (error) {
// request has been handled by the express middleware, how to signal that to hono?
// this will never resolve, ergo the request will never be full handled by hono, but that's a memory leak
return new Promise<void>(() => {})
}
},
)
As you may suspect doing so is not the most optimal solution. But is there another, recommended way of handling express/connect middlewares?
Hey, I have an application that has been using
express
and I'd like to replace it withhono
, but in the development mode the app is using 3 express middlewares (webpack-dev-middleware
,webpack-hot-middleware
andconnect-history-api-fallback
) that I can not simply "drop".The thing is each time I allow the hono middleware to resolve the
ERR_HTTP_HEADERS_SENT
error is being thrown. The only solution that I've figured is to leak memory by not resolving the middleware:As you may suspect doing so is not the most optimal solution. But is there another, recommended way of handling express/connect middlewares?