claude-code - 💡(How to fix) Fix preview_screenshot times out (30s) when serving static HTML via python http.server [1 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
anthropics/claude-code#46507Fetched 2026-04-11 06:18:27
View on GitHub
Comments
0
Participants
1
Timeline
3
Reactions
0
Participants
Timeline (top)
labeled ×3

preview_screenshot consistently times out after 30 seconds when the dev server is a Python http.server serving a static HTML site. All other preview tools work correctly in the same session.

Root Cause

preview_screenshot consistently times out after 30 seconds when the dev server is a Python http.server serving a static HTML site. All other preview tools work correctly in the same session.

Fix Action

Workaround

Use preview_snapshot (accessibility tree) to verify content and structure. preview_eval + DOM queries to check specific elements.

Code Example

{
     "version": "0.0.1",
     "configurations": [
       { "name": "site", "runtimeExecutable": "python", "runtimeArgs": ["-m", "http.server", "3457"], "port": 3457 }
     ]
   }

---

preview_screenshot timed out after 30s. The preview window may be stuck (modal dialog, navigation hang, or unresponsive renderer).
RAW_BUFFERClick to expand / collapse

Description

preview_screenshot consistently times out after 30 seconds when the dev server is a Python http.server serving a static HTML site. All other preview tools work correctly in the same session.

Steps to reproduce

  1. Create a .claude/launch.json with a Python HTTP server:
    {
      "version": "0.0.1",
      "configurations": [
        { "name": "site", "runtimeExecutable": "python", "runtimeArgs": ["-m", "http.server", "3457"], "port": 3457 }
      ]
    }
  2. Call preview_start → succeeds
  3. Call preview_snapshot → succeeds (returns full accessibility tree)
  4. Call preview_console_logs → succeeds (no errors)
  5. Call preview_network → succeeds (images and fonts load fine; JS eval confirms img.naturalWidth > 0)
  6. Call preview_screenshottimes out after 30s

Expected behavior

preview_screenshot should return a JPEG of the rendered page, just like preview_snapshot does.

Actual behavior

preview_screenshot timed out after 30s. The preview window may be stuck (modal dialog, navigation hang, or unresponsive renderer).

No errors in console. No failed network requests (except a GA POST which is expected to fail on localhost). The page renders and is fully interactive.

Environment

  • OS: Windows 11 Pro 10.0.26200
  • Shell: bash (Git Bash)
  • Claude Code version: current
  • Server: python -m http.server 3457 (Python 3.x)
  • Page: Static HTML with Alpine.js, Tailwind CSS (pre-built), inline SVGs — no heavy JS

Impact

Cannot visually verify UI changes via screenshot in the verification workflow. All other preview tools work normally.

Workaround

Use preview_snapshot (accessibility tree) to verify content and structure. preview_eval + DOM queries to check specific elements.

Notes

  • preview_screenshot seems to fail only for this server type. May be related to how Chromium waits for the page to be "ready" before screenshotting, and Python's http.server doesn't set certain response headers that signal completion.
  • Possible fix: add a configurable timeout or a "page idle" heuristic instead of relying on a navigation event.

🤖 Generated with Claude Code

extent analysis

TL;DR

The preview_screenshot timeout issue may be resolved by configuring the server to set appropriate response headers or implementing a "page idle" heuristic to signal page completion.

Guidance

  • Investigate the response headers sent by the Python http.server and compare them with those sent by other servers that do not exhibit this issue.
  • Consider adding a configurable timeout or a "page idle" heuristic to the preview_screenshot function to handle cases where the page takes longer to load.
  • Verify that the page is fully loaded and interactive before attempting to take a screenshot, using tools like preview_snapshot and preview_eval to check the page's state.
  • Test the preview_screenshot function with different server configurations to determine if the issue is specific to the Python http.server.

Example

No code snippet is provided as the issue does not require a specific code change, but rather an investigation into the server configuration and the preview_screenshot function.

Notes

The issue may be related to how Chromium waits for the page to be "ready" before screenshotting, and the Python http.server not setting certain response headers that signal completion. Further investigation is needed to determine the root cause and implement a suitable fix.

Recommendation

Apply a workaround by using preview_snapshot and preview_eval to verify the page's content and structure until a more permanent fix can be implemented, as the root cause of the issue is not yet fully understood.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

FAQ

Expected behavior

preview_screenshot should return a JPEG of the rendered page, just like preview_snapshot does.

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING