@@ -126,7 +126,7 @@ export class HonoHttpServer implements IHttpServer {
126126 } ) ;
127127
128128 const streamResponse = await streamPromise ;
129- return streamResponse ?? capturedResponse ;
129+ return streamResponse ?? capturedResponse ?? c . json ( { error : 'No response from handler' } , 500 ) ;
130130 } ;
131131 }
132132
@@ -148,16 +148,18 @@ export class HonoHttpServer implements IHttpServer {
148148
149149 use ( pathOrHandler : string | Middleware , handler ?: Middleware ) {
150150 if ( typeof pathOrHandler === 'string' && handler ) {
151- // Path based middleware
152- // Hono middleware signature is different (c, next) => ...
153151 this . app . use ( pathOrHandler , async ( c , next ) => {
154- // Simplistic conversion
155- await handler ( { } as any , { } as any , next ) ;
152+ let nextCalled = false ;
153+ const wrappedNext = ( ) => { nextCalled = true ; return next ( ) ; } ;
154+ await handler ( { } as any , { } as any , wrappedNext ) ;
155+ if ( ! nextCalled ) await next ( ) ;
156156 } ) ;
157157 } else if ( typeof pathOrHandler === 'function' ) {
158- // Global middleware
159158 this . app . use ( '*' , async ( c , next ) => {
160- await pathOrHandler ( { } as any , { } as any , next ) ;
159+ let nextCalled = false ;
160+ const wrappedNext = ( ) => { nextCalled = true ; return next ( ) ; } ;
161+ await pathOrHandler ( { } as any , { } as any , wrappedNext ) ;
162+ if ( ! nextCalled ) await next ( ) ;
161163 } ) ;
162164 }
163165 }
0 commit comments