@@ -400,7 +400,7 @@ wdm.hapiWrapper = hapiWrapper;
400400 * @param {boolean= } usePlugin whether to use as webpack plugin
401401 * @returns {(ctx: EXPECTED_ANY, next: EXPECTED_FUNCTION) => Promise<void> | void } kow wrapper
402402 */
403- function koaWrapper ( compiler , options , usePlugin ) {
403+ function koaWrapper ( compiler , options = { } , usePlugin = false ) {
404404 const devMiddleware = wdm ( compiler , options , usePlugin ) ;
405405
406406 /**
@@ -543,7 +543,7 @@ wdm.koaWrapper = koaWrapper;
543543 * @param {boolean= } usePlugin true when need to use as a plugin, otherwise false
544544 * @returns {(ctx: EXPECTED_ANY, next: EXPECTED_FUNCTION) => Promise<void> | void } hono wrapper
545545 */
546- function honoWrapper ( compiler , options , usePlugin ) {
546+ function honoWrapper ( compiler , options = { } , usePlugin = false ) {
547547 const devMiddleware = wdm ( compiler , options , usePlugin ) ;
548548
549549 /**
@@ -639,12 +639,20 @@ function honoWrapper(compiler, options, usePlugin) {
639639 * @param {import("fs").ReadStream } stream readable stream
640640 */
641641 res . stream = ( stream ) => {
642+ if ( options . writeToDisk === true ) {
643+ console . error ( stream ) ;
644+ }
645+
642646 let isResolved = false ;
643647
644648 /**
645649 * @param {Error= } err err
646650 */
647651 const onEvent = ( err ) => {
652+ if ( options . writeToDisk === true ) {
653+ console . error ( "onEvent" , err ) ;
654+ }
655+
648656 if ( isResolved ) return ;
649657 isResolved = true ;
650658
@@ -660,6 +668,11 @@ function honoWrapper(compiler, options, usePlugin) {
660668
661669 body = stream ;
662670 isFinished = true ;
671+
672+ if ( options . writeToDisk === true ) {
673+ console . error ( "resolve" , isFinished ) ;
674+ }
675+
663676 resolve ( ) ;
664677 } ;
665678
@@ -716,6 +729,10 @@ function honoWrapper(compiler, options, usePlugin) {
716729 } ,
717730 ) ;
718731 } catch ( err ) {
732+ if ( options . writeToDisk === true ) {
733+ console . error ( "catch" , err ) ;
734+ }
735+
719736 if ( options ?. forwardError ) {
720737 await next ( ) ;
721738
@@ -727,10 +744,18 @@ function honoWrapper(compiler, options, usePlugin) {
727744 return context . json ( { message : /** @type {Error } */ ( err ) . message } ) ;
728745 }
729746
747+ if ( options . writeToDisk === true ) {
748+ console . error ( "body" , body ) ;
749+ }
750+
730751 if ( typeof body !== "undefined" ) {
731752 return context . body ( body , status ) ;
732753 }
733754
755+ if ( options . writeToDisk === true ) {
756+ console . error ( "next" ) ;
757+ }
758+
734759 await next ( ) ;
735760 }
736761
0 commit comments