@@ -47,7 +47,7 @@ const createSandbox = async (
4747 response : info . response
4848 ? {
4949 status : info . response . status ,
50- headers : Object . fromEntries ( info . response . headers . entries ( ) ) ,
50+ headers : [ ... info . response . headers . entries ( ) ] ,
5151 body : pack . permissions ?. body
5252 ? await extractBody ( info . response )
5353 : undefined ,
@@ -113,20 +113,26 @@ export const runSandbox = async (
113113 )
114114 ) ;
115115
116- // logger.debug(`[${requestId}] pack ran`);
116+ if ( output ) {
117+ const result = output ?. json ( ) as PluginOutput ;
117118
118- const result = output ?. json ( ) as PluginOutput ;
119+ if ( result . context ) {
120+ context [ `${ index } ` ] = result . context ;
121+ }
119122
120- if ( result . context ) {
121- context [ `${ index } ` ] = result . context ;
123+ await callbacks . onResult ( pack , result ) ;
124+ logger . debug ( `[${ requestId } ] (pre) pack ${ pack . name } completed` ) ;
125+ } else {
126+ logger . debug (
127+ `[${ requestId } ] (pre) pack ${ pack . name } no output returned`
128+ ) ;
122129 }
123-
124- await callbacks . onResult ( pack , result ) ;
125130 } )
126131 ) ;
127132
128133 for ( const hook of preHooks ) {
129134 if ( hook . status === "rejected" ) {
135+ logger . error ( `${ hook . reason } ` ) ;
130136 callbacks . onError ( hook . reason ) ;
131137 }
132138 }
@@ -180,18 +186,25 @@ export const runSandbox = async (
180186 )
181187 ) ;
182188
183- const result = output ?. json ( ) as PluginOutput ;
189+ if ( output ) {
190+ const result = output ?. json ( ) as PluginOutput ;
191+ if ( result . context ) {
192+ context [ `${ index } ` ] = result . context ;
193+ }
184194
185- if ( result . context ) {
186- context [ `${ index } ` ] = result . context ;
195+ await callbacks . onResult ( pack , result ) ;
196+ logger . debug ( `[${ requestId } ] (post) pack ${ pack . name } completed` ) ;
197+ } else {
198+ logger . debug (
199+ `[${ requestId } ] (post) pack ${ pack . name } no output returned`
200+ ) ;
187201 }
188-
189- await callbacks . onResult ( pack , result ) ;
190202 } )
191203 ) ;
192204
193205 for ( const hook of postHooks ) {
194206 if ( hook . status === "rejected" ) {
207+ logger . error ( `${ hook . reason } ` ) ;
195208 callbacks . onError ( hook . reason ) ;
196209 }
197210 }
0 commit comments