Skip to content

feat(browser-pools): typed acquire helper distinguishing got / timed-out#113

Draft
Jayko001 wants to merge 2 commits into
mainfrom
hypeship/cus-261-typed-acquire-result
Draft

feat(browser-pools): typed acquire helper distinguishing got / timed-out#113
Jayko001 wants to merge 2 commits into
mainfrom
hypeship/cus-261-typed-acquire-result

Conversation

@Jayko001
Copy link
Copy Markdown

@Jayko001 Jayko001 commented Jun 2, 2026

Summary

Adds a typed wrapper around client.browserPools.acquire so callers can distinguish a successful lease from a long-poll timeout without inspecting raw HTTP status codes.

import Kernel, { acquireBrowserFromPool } from '@onkernel/sdk';

const result = await acquireBrowserFromPool(client, 'my-pool');
if (result.status === 'acquired') {
  useBrowser(result.browser);
} else {
  // status === 'timed_out' — retry to keep waiting
}
  • { status: 'acquired', browser } — 200, browser leased from pool
  • { status: 'timed_out' } — 204, long poll expired, retry
  • NotFoundError — 404, pool does not exist (existing exception, propagated)

The generated client.browserPools.acquire() method is unchanged for backwards compatibility.

Test plan

  • Unit tests cover 200 / 204 / 404 paths
  • Lint + typecheck clean
  • Manual smoke test against staging once published

Jayko001 and others added 2 commits June 2, 2026 00:19
Add `acquireBrowserFromPool` returning a discriminated union — `{ status:
'acquired', browser }` on 200 or `{ status: 'timed_out' }` on 204 — so
callers can disambiguate the long-poll timeout from a successful lease
without inspecting the raw HTTP status. 404 continues to reject with the
existing `NotFoundError`.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Adds `{ status: 'not_found' }` to AcquireOutcome and wraps NotFoundError
internally so all three documented outcomes — acquired, timed_out,
not_found — are reachable via the same `result.status` switch.

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