Trace: fetch/XHR response bodies hidden in the player on Safari (content.mimeType is empty)

オープン 初心者向け
#586 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

@SergeyPirogov がすでに取り組んでいます。

2026年11月22日 から。

  • #587 @SergeyPirogov による — オープン

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
72/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
typescript
領域
tooling

調査の方向性

packages/trace/src/trace-har.ts の138行目付近にある content.mimeType の代入から始めてください。この箇所は entry.response?.mimeType しか読んでいません。ページコレクターの responseHeaders がそのエントリにどう渡されるかを確認し、パラメータを取り除いたうえで content-type ヘッダーへのフォールバックを追加してください。Safari のトレースから得た fetch/XHR エントリがテキスト形式の mimeType を持ち、そのボディが Network タブに表示されれば完了です。responseHeaders だけを持つエントリを converter に通すテストで確認できます。

索引モデルが issue の本文から書いたものです。

説明

What happens

In trace mode on iOS Safari (Appium XCUITest, no WebDriver BiDi), the Network tab of show-trace shows response headers for the page's fetch/XHR calls, but never the response body.

The body is in the trace. The resource-snapshot entries in trace.network carry response.content.text (or _sha1 with the file under resources/), and response.headers contains content-type: application/json. But response.content.mimeType is "":

"response": {
  "status": 200,
  "headers": [{ "name": "content-type", "value": "application/json" }, ...],
  "content": { "size": 1297, "mimeType": "", "text": "{\"id\":...}", "_sha1": "..." }
}

The player only reads a body when the mime type is textual (/json|xml|javascript|ecmascript|^text\// in the trace parser, for both inline text and _sha1), so every body is dropped.

Cause

packages/trace/src/trace-har.ts:138

const mimeType = entry.response?.mimeType ?? ''

The requests the page collector records (the fetch/XHR patch that serves Safari and Appium sessions) carry responseHeaders but no response.mimeType. With no fallback, content.mimeType ends up empty.

Suggested fix

Fall back to the content-type header:

const headers = entry.response?.headers ?? entry.responseHeaders
const mimeType =
  entry.response?.mimeType ||
  String(headers?.['content-type'] ?? '').split(';')[0].trim()

We applied the same change as a local patch to the built dist/index.js. After it, all 21 fetch/XHR entries in our trace have mimeType: application/json, and their bodies are readable. Setting response.mimeType where the collector's requests are ingested would fix it at the source too.

Environment

  • @wdio/devtools-service 11.2.0 (@wdio/devtools-app 1.13.0), WebdriverIO 9.33.1
  • Appium 3.5, XCUITest driver 12.22.8, iOS 18.6 Simulator, Safari
  • Service options: { mode: 'trace', traceFormat: 'zip', traceGranularity: 'spec' }
主要言語
TypeScript
スター
10
フォーク
4
平均マージ
1日 11時間
マージ済み PR(30日)
76

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

webdriverio/devtools のほかの issue

webdriverio/devtools の issue をすべて見る

似ている issue

TypeScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。