@@ -47,7 +47,7 @@ const createSandbox = async (
47
47
response : info . response
48
48
? {
49
49
status : info . response . status ,
50
- headers : Object . fromEntries ( info . response . headers . entries ( ) ) ,
50
+ headers : [ ... info . response . headers . entries ( ) ] ,
51
51
body : pack . permissions ?. body
52
52
? await extractBody ( info . response )
53
53
: undefined ,
@@ -113,20 +113,26 @@ export const runSandbox = async (
113
113
)
114
114
) ;
115
115
116
- // logger.debug(`[${requestId}] pack ran`);
116
+ if ( output ) {
117
+ const result = output ?. json ( ) as PluginOutput ;
117
118
118
- const result = output ?. json ( ) as PluginOutput ;
119
+ if ( result . context ) {
120
+ context [ `${ index } ` ] = result . context ;
121
+ }
119
122
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
+ ) ;
122
129
}
123
-
124
- await callbacks . onResult ( pack , result ) ;
125
130
} )
126
131
) ;
127
132
128
133
for ( const hook of preHooks ) {
129
134
if ( hook . status === "rejected" ) {
135
+ logger . error ( `${ hook . reason } ` ) ;
130
136
callbacks . onError ( hook . reason ) ;
131
137
}
132
138
}
@@ -180,18 +186,25 @@ export const runSandbox = async (
180
186
)
181
187
) ;
182
188
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
+ }
184
194
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
+ ) ;
187
201
}
188
-
189
- await callbacks . onResult ( pack , result ) ;
190
202
} )
191
203
) ;
192
204
193
205
for ( const hook of postHooks ) {
194
206
if ( hook . status === "rejected" ) {
207
+ logger . error ( `${ hook . reason } ` ) ;
195
208
callbacks . onError ( hook . reason ) ;
196
209
}
197
210
}
0 commit comments