files/en-us/web/api/webtransportsendstream/getstats/index.md
{{APIRef("WebTransport API")}}{{securecontext_header}} {{AvailableInWorkers}}
The getStats() method of the {{domxref("WebTransportSendStream")}} interface asynchronously returns an object containing statistics for the current stream.
The statistics include the total number of bytes written to the stream, the number that have been sent (ignoring packet overhead), and the number of bytes that have been set at least once, and the number that have been acknowledged (up until the first sequentially-ordered non-acknowledged byte). It therefore provides a measure of how quickly the application is sending bytes to the server on this particular stream.
getStats()
None.
A {{jsxref("Promise")}} that resolves to an object containing statistics about the current stream. The returned object has the following properties:
bytesAcknowledged
bytesSent.
When the connection is over HTTP/2, the value will match bytesSent.bytesSent
bytesWritten.
Note that this count does not include bytes sent as network overhead (such as packet headers).bytesWritten
The code snippet below uses await to wait on the {{jsxref("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.
const stats = await stream.getStats();
const bytesNotReceived = stats.bytesWritten - stats.bytesAcknowledged;
console.log(`Bytes still successfully sent: ${bytesNotReceived}`);
{{Specifications}}
{{Compat}}