大网数据广告活动
Web 标准与前端开发

WebTransportSendStream: getStats() method

· 52CE 我爱测

The **`getStats()`** method of the WebTransportSendStream interface asynchronously returns an object containing statistics for the current stream.

WebTransport API

The getStats() method of the 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.

Syntax

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 match bytesSent.
  • 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.

const stats = await stream.getStats();
const bytesNotReceived = stats.bytesSent - stats.bytesAcknowledged;
console.log(`Bytes sent but not acknowledged: ${bytesNotReceived}`);

Specifications

Browser compatibility

来源:MDN Web Docs / Mozilla 贡献者 · 作者与贡献记录 · CC BY-SA 2.5。离线整理了版式、链接和媒体显示。

资料来源与适用范围

资料来源
MDN Web Docs / Mozilla 贡献者
适用范围
请按文中版本与环境说明核对
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 2.5

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。