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

Offen Anfängerfreundlich
#586 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Maintainer antworten meist innerhalb von 1 Tag

@SergeyPirogov arbeitet bereits daran.

Seit 22.11.2026.

  • #587 von @SergeyPirogov — offen

Bewertung

Schwierigkeit
2/5
Geschätzter Aufwand
1-3 Stunden
Anfängerfreundlichkeit
72/100
Issue-Typ
Bug
Klarheit
Klar beschrieben
Aktivitätsstatus
Aktiv
Tech-Stack
typescript
Bereich
tooling

Rechercherichtung

Beginne bei der Zuweisung content.mimeType in packages/trace/src/trace-har.ts nahe Zeile 138, die nur entry.response?.mimeType liest. Prüfe, wie die responseHeaders des Page-Collectors in diesen Eintrag gelangen, und füge dann einen Fallback auf den Header content-type hinzu, wobei Parameter entfernt werden. Fertig, wenn Fetch-/XHR-Einträge aus einem Safari-Trace einen textuellen mimeType erhalten und ihre Bodies im Network-Tab erscheinen; ein Test, der einen Eintrag nur mit responseHeaders durch den Converter schickt, würde dies bestätigen.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Beschreibung

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' }
Vorherrschende Sprache
TypeScript
Sterne
10
Forks
4
Ø Merge
1 T. 11 Std.
Gemergte PRs (30 T.)
76

Entwicklungsumgebung

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus webdriverio/devtools

Alle Issues in webdriverio/devtools

Ähnliche Issues

Weitere Issues zu TypeScript

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.