bool body_reader_catch_handler(JSContext *cx, HandleObject body_owner, HandleValue extra,
                               CallArgs args) {
  // TODO: check if this should create a rejected promise instead, so an
  // in-content handler for unhandled rejections could deal with it. The body
  // stream errored during the streaming send. Not much we can do, but at least
  // close the stream, and warn.
  fprintf(stderr, "Warning: body ReadableStream closed during body streaming. Exception: ");
  dump_value(cx, args.get(0), stderr);

  // The only response we ever send is the one passed to
  // `FetchEvent#respondWith` to send to the client. As such, we can be certain
  // that if we have a response here, we can advance the FetchState to
  // `responseDone`. (Note that even though we encountered an error,
  // `responseDone` is the right state: `responsedWithError` is for when sending
  // a response at all failed.)
  if (Response::is_instance(body_owner)) {
    FetchEvent::set_state(FetchEvent::instance(), FetchEvent::State::responseDone);
  }
  return HANDLE_RESULT(cx, xqd_body_close(RequestOrResponse::body_handle(body_owner)));
}
bool body_reader_catch_handler(JSContext *cx, HandleObject body_owner, HandleValue extra,
                               CallArgs args) {
   
   
   
   
  fprintf(stderr, "Warning: body ReadableStream closed during body streaming. Exception: ");
  dump_value(cx, args.get(0), stderr);

   
   
   
   
   
   
  if (Response::is_instance(body_owner)) {
    FetchEvent::set_state(FetchEvent::instance(), FetchEvent::State::responseDone);
  }
  return HANDLE_RESULT(cx, xqd_body_close(RequestOrResponse::body_handle(body_owner)));
}