WebTransportError: thuộc tính streamErrorCode

Baseline 2026
Newly available

Since March 2026, this feature works across the latest devices and browser versions. This feature might not work in older devices or browsers.

Secure context: This feature is available only in secure contexts (HTTPS), in some or all supporting browsers.

Note: This feature is available in Web Workers.

Thuộc tính chỉ đọc streamErrorCode của giao diện WebTransportError trả về một số trong khoảng 0-255 cho biết mã lỗi giao thức ứng dụng cho lỗi này, hoặc null nếu không có.

Giá trị

Một số, hoặc null.

Ví dụ

js
const url = "not-a-url";

async function initTransport(url) {
  try {
    // Initialize transport connection
    const transport = new WebTransport(url);

    // The connection can be used once ready fulfills
    await transport.ready;

    // …
  } catch (error) {
    const msg = `Transport initialization failed.
                 Reason: ${error.message}.
                 Source: ${error.source}.
                 Error code: ${error.streamErrorCode}.`;
    console.log(msg);
  }
}

Thông số kỹ thuật

Thông số kỹ thuật
WebTransport
# dom-webtransporterror-streamerrorcode

Tương thích trình duyệt

Xem thêm