Skip to content

fix(36kr): replace waitForCapture with DOM polling for search/hot#779

Merged
jackwener merged 2 commits intojackwener:mainfrom
gucasbrg:fix/36kr-intercept-timeout
Apr 4, 2026
Merged

fix(36kr): replace waitForCapture with DOM polling for search/hot#779
jackwener merged 2 commits intojackwener:mainfrom
gucasbrg:fix/36kr-intercept-timeout

Conversation

@gucasbrg
Copy link
Copy Markdown
Contributor

@gucasbrg gucasbrg commented Apr 4, 2026

Summary

  • 36kr search and 36kr hot always fail with No network capture within 6s because waitForCapture(6) never intercepts a matching API request
  • The DOM is already fully rendered with results by the time the timeout fires
  • Replace 6-second intercept wait with DOM polling: check for a[href*="/p/"] every 300ms, return immediately once content is available

Before

$ time opencli 36kr search "AI" --limit 3 -f json
💥 Unexpected error: Error: No network capture within 6s
7.450s total (always fails)

After

$ time opencli 36kr search "AI" --limit 3 -f json
[{"rank":1,"title":"我教AI"学做人"...","url":"https://36kr.com/p/..."},...]
1.290s total (succeeds)

Test plan

  • opencli 36kr search "AI" --limit 3 -f json returns results in ~1.3s
  • opencli 36kr hot --limit 3 -f json returns results in ~1.8s
  • Tested with both CDP mode and Browser Bridge mode on opencli 1.6.2

buruguo and others added 2 commits April 5, 2026 03:01
waitForCapture(6) always times out on 36kr because the API intercept
never captures a matching request. However, the DOM is already fully
rendered with search/hot results by the time the timeout fires.

Replace the 6-second intercept wait with a DOM polling loop that checks
for article links (a[href*="/p/"]) every 300ms, returning immediately
once content is available (typically ~1s vs 6s timeout + error).

Tested on opencli 1.6.2 with both CDP and Browser Bridge modes.
- Rebase onto main after clis/ move (PR jackwener#782)
- Remove installInterceptor calls (no longer used after waitForCapture removal)
- Change strategy from INTERCEPT to PUBLIC (browser: true) to match actual behavior
- Improve polling loop readability
@jackwener jackwener force-pushed the fix/36kr-intercept-timeout branch from fa1c04c to 6825c3d Compare April 4, 2026 19:03
@jackwener jackwener merged commit a0a4dd6 into jackwener:main Apr 4, 2026
9 checks passed
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.

2 participants