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

Aperta Adatta ai principianti
#586 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

@SergeyPirogov ci sta già lavorando.

Dal 22/11/2026.

  • #587 di @SergeyPirogov — aperta

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
72/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
typescript
Ambito
tooling

Direzione di ricerca

Inizia dall'assegnazione di content.mimeType in packages/trace/src/trace-har.ts, vicino alla riga 138, che legge solo entry.response?.mimeType. Verifica come i responseHeaders del collector della pagina arrivano a quella voce, poi aggiungi un fallback sull'header content-type, rimuovendo eventuali parametri. È completato quando le voci fetch/XHR di una traccia Safari ricevono un mimeType testuale e i loro body compaiono nella scheda Network; un test che passa una voce con solo responseHeaders attraverso il converter lo confermerebbe.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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' }
Lingua principale
TypeScript
Stelle
10
Fork
4
Merge medio
1g 11h
PR unite (30g)
76

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di webdriverio/devtools

Tutte le issue di webdriverio/devtools

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.