Request lifecycle
- Validate inputs and encode path identifiers.
- Append the resource route and serialize query values.
- Create an internal AbortController and total deadline.
- Send bearer-authenticated JSON through Fetch.
- Retry eligible GET responses while time remains.
- Parse success data or map failure metadata to a typed error.
- Clear timers and abort listeners.
Wire format
http
GET /v1/projects?limit=20 HTTP/1.1
Host: api.pbjspace.dev
Authorization: Bearer pbj_••••••••
Accept: application/json- Query values are strings, numbers, or booleans; undefined values are omitted.
- Requests with bodies also send
Content-Type: application/json. - Fetch uses
redirect: "error"andcredentials: "omit". - Successful empty responses return
undefined.
Retry policy
| Outcome | Retry? |
|---|---|
| GET → 429, 500, 502, 503, 504 | Yes, while attempts and deadline remain |
| POST, PATCH, DELETE failure | No |
| Authentication or validation failure | No |
| Fetch/network failure | No |
| Malformed success JSON | No |
| Caller cancellation | No |
text
jitter = 0.5 + random() × 0.5
fallback_ms = retryDelay × 2^retryIndex × jitter
wait_ms = min(maxRetryDelay, selected_delay)Total deadline
The timeout covers every attempt, response-body read, and retry wait. A timed-out mutation may still have completed on the server, so read the current state before submitting it again.
