File tree Expand file tree Collapse file tree 1 file changed +2
-2
lines changed
Expand file tree Collapse file tree 1 file changed +2
-2
lines changed Original file line number Diff line number Diff line change @@ -294,15 +294,15 @@ export function defineJsonRpcHandler<RequestT extends EventHandlerRequest = Even
294294 // Filter out notifications (undefined responses) before returning.
295295 const finalResponses = responses . filter ( ( r ) : r is JsonRpcResponse => r !== undefined ) ;
296296
297- event . res . headers . set ( "Content-Type" , "application/json" ) ;
298-
299297 // Per spec §6, even when request is a batch, the server MUST NOT return an empty array.
300298 // If there are no responses to return (e.g. all notifications), return nothing.
301299 if ( finalResponses . length === 0 ) {
302300 event . res . status = 202 ;
303301 return "" ;
304302 }
305303
304+ event . res . headers . set ( "Content-Type" , "application/json" ) ;
305+
306306 // For a single request, return the single response object.
307307 // For a batch request, return the array of response objects.
308308 return isBatch ? finalResponses : finalResponses [ 0 ] ;
You can’t perform that action at this time.
0 commit comments