Skip to content

fix: use async response status for network request list and detail views - #18

Open
AlanJie wants to merge 1 commit into
zhizhuodemao:mainfrom
AlanJie:fix/network-request-status-async
Open

fix: use async response status for network request list and detail views#18
AlanJie wants to merge 1 commit into
zhizhuodemao:mainfrom
AlanJie:fix/network-request-status-async

Conversation

@AlanJie

@AlanJie AlanJie commented May 3, 2026

Copy link
Copy Markdown

Summary

  • list_network_requests list and single-request detail views always showed [pending], even after the page finished loading
  • Some requests (beacon/analytics) were incorrectly reported as [failed - net::ERR_ABORTED] when they actually returned HTTP 200

Root Cause

getShortDescriptionForRequest and getStatusFromRequest in networkFormatter.ts are synchronous, but Playwright's request.response() is async. The sync path can never obtain the real response status:

// Always returns [pending] — can't access response synchronously
export function getStatusFromRequest(request) {
    const failure = request.failure();
    if (failure) return `[failed - ${failure.errorText}]`;
    return '[pending]';
}

An async version getStatusFromRequestAsync already existed but was never called by the list or detail formatting code.

Fix

  1. src/formatters/networkFormatter.ts — Added getShortDescriptionForRequestAsync, which calls the existing getStatusFromRequestAsync
  2. src/McpResponse.ts — Updated 3 call sites to use the async versions:
    • Request list loop (in format())
    • Single-request detail status line (in #formatNetworkRequestData())
    • Redirect chain status (in #formatNetworkRequestData())
  3. format() and #formatNetworkRequestData() method signatures changed to async

Before / After

Before After
GET .../api/feed/topstory/recommend ... [pending] GET .../api/feed/topstory/recommend ... [success - 200]
POST .../za/logs/batch [failed - ERR_ABORTED] POST .../za/logs/batch [success - 200]
Status: [pending] Status: [success - 200]

🤖 Generated with Claude Code

`getShortDescriptionForRequest` and `getStatusFromRequest` in the list/detail
views were synchronous but Playwright's `request.response()` is async, so all
requests showed `[pending]` even after the page finished loading. Requests
where `request.failure()` was set (e.g. beacon/analytics) also showed
`[failed - net::ERR_ABORTED]` even though they completed successfully.

Add `getShortDescriptionForRequestAsync` that calls the existing
`getStatusFromRequestAsync`, and wire it into `McpResponse.format()` and
`#formatNetworkRequestData()` so list, detail, and redirect-chain views
all show the real HTTP status code.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant