files/en-us/web/api/webtransportreceivestream/getstats/index.md
{{APIRef("WebTransport API")}}{{SecureContext_Header}} {{AvailableInWorkers}}
The getStats() method of the {{domxref("WebTransportReceiveStream")}} interface asynchronously returns an object containing statistics for the current stream.
The statistics include the total number of ordered bytes that have arrived on this stream (ignoring network overhead, up until the first missing byte) and the total number that have been read by the application. It therefore provides a measure of how quickly the application is consuming bytes from 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:
timestamp
bytesReceived
bytesRead
WebTransportReceiveStream stream.
This number can only increase, and is always less than or equal to bytesReceived.The code snippet below uses await to wait on the {{jsxref("Promise")}} returned by getStats().
When the promise fulfills, the number of bytes that have not yet been read is logged to the console.
const stats = await stream.getStats();
const unConsumedBytes = stats.bytesReceived - stats.bytesRead;
console.log(`Bytes in reader queue: ${unConsumedBytes}`);
{{Specifications}}
{{Compat}}