Skip to main content

Overview

wreq-js can emit structured native request lifecycle events through onRequestEvent and can attach an optional diagnostics payload to the final Response when captureDiagnostics is enabled. Use this when you need to:
  • render transport-phase progress such as connecting, waiting, and loading
  • observe native download progress without consuming response.body first
  • capture timing, address, or TLS peer details for debugging

Enable request events

Event types

Progress example

Enable diagnostics

When available, response.diagnostics may include:
  • totalDurationMs
  • headersDurationMs
  • status
  • localAddr
  • remoteAddr
  • tlsPeerCertificatePresent
  • tlsPeerCertificateChainLength

Session and transport defaults

You can enable diagnostics by default on a session or transport:
onRequestEvent remains a per-request callback, so you still pass it to fetch() or session.fetch() for the specific requests you want to observe.

Notes

  • Request events come from the native layer and reflect transport lifecycle phases, not application-level parsing.
  • body_progress is emitted during native download. You can still consume response.body, response.text(), response.json(), and the other body helpers normally.
  • Diagnostics are optional and may vary by platform or native support level.