Skip to content

Add timeout + error resilience to function retrieve calls#126

Merged
WiggidyW merged 4 commits intomainfrom
remote-github
Mar 7, 2026
Merged

Add timeout + error resilience to function retrieve calls#126
WiggidyW merged 4 commits intomainfrom
remote-github

Conversation

@mayagore
Copy link
Collaborator

@mayagore mayagore commented Mar 6, 2026

Root cause — live site loading skeletons

The API now requires remote as a path segment: /functions/github/{owner}/{repo}/{commit}.

Without it, the owner is interpreted as the remote parameter:

GET /functions/ObjectiveAI-claude-code-1/market-viability-ranker/{commit}
→ 400: unknown variant `ObjectiveAI-claude-code-1`, expected `github` or `filesystem`
GET /functions/github/ObjectiveAI-claude-code-1/market-viability-ranker/{commit}
→ 200

PR #123 (already merged to main) added remote: "github" to all SDK call sites. The live site needs to be redeployed from main to pick up that change. Functions.list() works without remote, so the list loads but every Functions.retrieve() detail fetch returns 400 — causing endless skeletons.

What this PR adds (on top of PR #123)

Two defensive improvements to page.tsx and functions/page.tsx:

  1. 5s AbortController timeout on each Functions.retrieve() call — prevents indefinite hangs if a single call is slow or unresponsive
  2. Individual try/catch inside Promise.all — one failing retrieve no longer crashes the entire page; it's skipped and the rest still render

Files changed

  • objectiveai-web/app/page.tsx — landing page featured functions
  • objectiveai-web/app/functions/page.tsx — functions browse page

🤖 Generated with Claude Code

mayagore and others added 2 commits March 5, 2026 22:06
One failing Functions.retrieve() call (deleted repo, etc.) no longer
crashes the entire functions list or landing page. Each call is wrapped
in try/catch so failing functions are skipped instead of breaking
Promise.all.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Prevents the landing page and functions list from hanging indefinitely
if a single Functions.retrieve() call is slow or unresponsive.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@mayagore
Copy link
Collaborator Author

mayagore commented Mar 6, 2026

@WiggidyW The live site loading skeletons issue is because the deployed code is still calling /functions/{owner}/{repo}/{commit} (pre-PR #123). The API now returns 400 on that path — it expects /functions/github/{owner}/{repo}/{commit}. A redeploy from main will fix it.

@WiggidyW
Copy link
Collaborator

WiggidyW commented Mar 6, 2026

I inspected network traffic and the deployed code already uses the github remote, actually.

This PR should be amended with the following:

  1. When fetching details for listed functions, fetch them all concurrently. Currently, it is fetching them one at a time.
  2. Show function details as soon as they load. So, if fetching 6 details, show each of the 6 instantly after it finishes loading. Don't wait for all to complete prior to displaying.
  3. Do not have any logic, such as scrolling down to list more functions, have any dependency on details already being loaded. This logic should be entirely separate.
  4. Handle the case where some details fail to load. If fetching 12 Functions, and one fails, the other 11 should still show up correctly.

mayagore and others added 2 commits March 6, 2026 17:47
Instead of waiting for all Functions.retrieve() calls to complete
before rendering anything, fire all fetches concurrently and update
state as each resolves. This means:

- First card appears in ~500ms instead of waiting 5s+ for slowest
- 3 functions that timeout at 5s no longer block the other 17
- Skeleton cards shown during initial list fetch
- Landing page slots fill in progressively (skeleton → real card)
- Pagination independent of detail loading state
- Empty state only shown after all fetches have settled

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
… loading

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@mayagore
Copy link
Collaborator Author

mayagore commented Mar 6, 2026

Updated to address all 4 points:

  1. Concurrent fetches — all Functions.retrieve() calls fire simultaneously (unchanged from before, but now each resolves independently instead of being held by Promise.all)
  2. Progressive rendering — each card renders the instant its detail loads via setFunctions(prev => [...prev, item]). No waiting for all to complete.
  3. Pagination independent of loading — "Load more" operates on whatever functions have loaded so far. Skeleton grid shows during the initial list fetch only.
  4. Partial failure handling — failed/timed-out functions are silently skipped, rest still render.

Live API test: 17/20 functions load in ~500-690ms, 3 timeout at 5s. Old behavior showed nothing for 5s+. New behavior shows first card at ~500ms.

Also merged main to resolve conflicts.

@WiggidyW WiggidyW merged commit e22ff91 into main Mar 7, 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