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.bodyfirst - capture timing, address, or TLS peer details for debugging
Enable request events
Event types
| Event | Meaning | Common fields |
|---|---|---|
request_start | Request has started in the native layer. | timestamp, url |
request_sent | Request has been sent and the client is waiting for a response. | timestamp, url |
response_headers | Response headers have arrived. | timestamp, status, contentLength, url |
body_progress | More response bytes were downloaded. | timestamp, downloadedBytes, contentLength, url |
body_complete | Response body download finished. | timestamp, contentLength, url |
done | Native request lifecycle completed successfully. | timestamp, status, url |
error | Native request lifecycle failed. | timestamp, message, url |
Progress example
Enable diagnostics
response.diagnostics may include:
totalDurationMsheadersDurationMsstatuslocalAddrremoteAddrtlsPeerCertificatePresenttlsPeerCertificateChainLength
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_progressis emitted during native download. You can still consumeresponse.body,response.text(),response.json(), and the other body helpers normally.- Diagnostics are optional and may vary by platform or native support level.