Syntax
js
getStats()
Parameters
None.
Return value
A Promise that resolves to an object containing statistics about the current stream.
The returned object has the following properties:
bytesAcknowledged-
A positive integer indicating the number of bytes written to this stream that have been sent and acknowledged as received by the server, using QUIC's ACK mechanism. Only sequential bytes up to, but not including, the first non-acknowledged byte, are counted. This number can only increase and is always less than or equal to
bytesSent. When the connection is over HTTP/2, the value will matchbytesSent. bytesSent-
A positive integer indicating the number of bytes written to this stream that have been sent at least once (but not necessarily acknowledged). This number can only increase, and is always less than or equal to
bytesWritten. Note that this count does not include bytes sent as network overhead (such as packet headers). bytesWritten-
A positive integer indicating the number of bytes successfully written to this stream. This number can only increase.
Examples
The code snippet below uses await to wait on the Promise returned by getStats().
When the promise fulfills, the result for the number of bytes that have been sent but not acknowledged is logged to the console.
js
const stats = await stream.getStats();
const bytesNotReceived = stats.bytesWritten - stats.bytesAcknowledged;
console.log(`Bytes still successfully sent: ${bytesNotReceived}`);
Specifications
| Specification |
|---|
| WebTransport # dom-webtransportsendstream-getstats |