Skip to content

Add request timeout to pagination#27

Draft
shengwu wants to merge 7 commits intomainfrom
claude/add-busy-loop-detector-DbtAr
Draft

Add request timeout to pagination#27
shengwu wants to merge 7 commits intomainfrom
claude/add-busy-loop-detector-DbtAr

Conversation

@shengwu
Copy link

@shengwu shengwu commented Mar 13, 2026

This matches the typescript interview question. It's a little different

Testing

Added

while True:
    a = []

to part 2 of api/pagination.ts

image

Introduces a BusyLoopDetector class that monitors call frequency within
a time window and raises an error if a threshold is exceeded. Integrated
into ProjectDatabase.get_items(). Also updated README to point
candidates to api/pagination.py.

https://claude.ai/code/session_01MMKGE3aKehnxGfV8H6uvNt
shengwu and others added 6 commits March 13, 2026 16:30
…r reset

- Move detector from per-instance to module-level so it persists across
  ProjectDatabase instantiations. Previously, get_page() creating a new
  ProjectDatabase each call meant candidates looping over get_page() would
  get a fresh detector every iteration, defeating the protection.
- Reset counter to 1 (not 0) in _reset_timer so the call that triggers
  the window reset is properly counted in the new window.

https://claude.ai/code/session_01MMKGE3aKehnxGfV8H6uvNt
…tAr' into claude/add-busy-loop-detector-DbtAr
Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.


try {
const response = await fetch(url, { signal: controller.signal });
return response.json();
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing await makes timeout not cover body reading

Medium Severity

return response.json() without await inside the try/catch/finally causes the finally block to run (clearing the timeout via clearTimeout) immediately after headers arrive, before the response body is fully read. This means the abort timeout only protects the initial fetch, not the body reading phase. Additionally, if response.json() rejects, the catch block is bypassed entirely, so an AbortError during body reading would never be converted to a ProjectsRequestTimeoutError. Using return await response.json() would fix both issues.

Additional Locations (1)
Fix in Cursor Fix in Web

@shengwu shengwu changed the title Add busy loop detection to pagination Add request timeout to pagination Mar 20, 2026
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