@molecule/app-http 1.2.0 → 1.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -3,7 +3,7 @@ AUTO-GENERATED — DO NOT EDIT THIS FILE.
3
3
  Generated by `mlcl sync-docs` from the package's src/index.ts JSDoc + mlcl/registry.json.
4
4
  Edits here are overwritten on the next commit (molecule's pre-commit hook regenerates).
5
5
  To change this document, edit the module-level JSDoc in src/index.ts.
6
- Generated: 2026-10-18T09:50:54.298Z
6
+ Generated: 2026-10-18T22:39:03.959Z
7
7
  -->
8
8
 
9
9
  # @molecule/app-http
@@ -219,11 +219,15 @@ interface RequestConfig {
219
219
  /**
220
220
  * Send this request WITHOUT waiting for the session restore (the auth gate).
221
221
  *
222
- * A request the gate itself depends on must set this. A gate registered with
223
- * `setAuthGate` that waits for a session restore whose own request goes through this
224
- * client otherwise waits on itself: the gate holds the restore's request, the restore's
225
- * promise never settles, and every request on the page stalls until the gate times out —
226
- * so pass `skipAuthGate: true` on the restore's own request:
222
+ * A request the gate's restore issues from a LATER continuation must set this. The gate
223
+ * recognizes a request the settle function issues while it runs and never holds it — this
224
+ * package's client awaits the gate before anything else, so a `restoreSession()` that calls
225
+ * it directly does not deadlock. But a restore that awaits something else first
226
+ * (`await storage.get()`), then calls the client, reaches `awaitAuthGate` after that window:
227
+ * the gate then waits on itself, and every request on the page stalls until the gate times
228
+ * out (3 s) — so pass `skipAuthGate: true` on that request. A provider that awaits the gate
229
+ * inside a scheduled interceptor (the Axios bond) also reaches it after the window, so its
230
+ * restore's request needs the opt-out.
227
231
  *
228
232
  * ```typescript
229
233
  * // the request the gate's restore makes, through the same client the gate holds back
@@ -232,7 +236,8 @@ interface RequestConfig {
232
236
  *
233
237
  * `@molecule/app-auth`'s own restore does not need it — it sends its request with
234
238
  * `fetch`, not through this client. An app with its own session store that registers a
235
- * gate with `setAuthGate` does.
239
+ * gate with `setAuthGate` does not need it either when its restore calls the client
240
+ * directly.
236
241
  */
237
242
  skipAuthGate?: boolean
238
243
 
@@ -396,14 +401,38 @@ type HttpMethod = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE' | 'HEAD' | 'OPTION
396
401
 
397
402
  HTTP error with response details.
398
403
 
404
+ **`status` is an HTTP status when the server answered, and `0` when it did not.**
405
+ A `0` means NO response exists: the request was aborted (an `AbortController`, a
406
+ component's effect cleanup, a route change tearing the request down) or the
407
+ network failed before anything came back. It is not an HTTP status at all, so it
408
+ says nothing about the session — an app must never treat `status < 500` as
409
+ "signed out", because every aborted request on a route change would clear the
410
+ session. The correct check is {@link isAuthFailure} (`status === 401 || status === 403`);
411
+ `isNoResponse` (`status === 0`) identifies this case.
412
+
399
413
  ```typescript
400
414
  class HttpError extends Error {
415
+ /**
416
+ * Builds a failed-request error.
417
+ *
418
+ * @param message - Human-readable message (already translated where a key exists).
419
+ * @param status - HTTP status, or `0` when no response was received (aborted / network failure).
420
+ * @param response - Parsed response when the server answered, otherwise undefined.
421
+ * @param config - The request config that failed.
422
+ * @param errorKey - Translation key for the failure (`http.error.aborted` for an
423
+ * aborted request, `http.error.networkError` for a real network failure).
424
+ * @param aborted - Whether the request was aborted before a response: an
425
+ * `AbortController` signal (component cleanup, a cancelled request) or the
426
+ * browser tearing the fetch down during a navigation. Distinguishes an abort
427
+ * from a network outage on the same `status === 0`, without parsing the message.
428
+ */
401
429
  constructor(
402
430
  message: string,
403
431
  public status: number,
404
432
  public response?: HttpResponse,
405
433
  public config?: FullRequestConfig,
406
434
  public errorKey?: string,
435
+ public aborted = false,
407
436
  ) {
408
437
  super(message)
409
438
  this.name = 'HttpError'
@@ -423,10 +452,20 @@ template auth that is `() => authClient.whenRestored()`, which resolves
423
452
  immediately when no restore is in flight, so registering it never makes a
424
453
  request wait longer than the restore it was about to race anyway.
425
454
 
426
- A gate whose restore sends its OWN request through the gated client deadlocks — the
427
- gate holds the request it is waiting for. That request must pass `skipAuthGate: true`
428
- (see `RequestConfig.skipAuthGate`); `@molecule/app-auth`'s own restore does not
429
- need it because it uses `fetch` rather than the bonded client.
455
+ Waiting for the restore does NOT attach its token: a separately created HTTP
456
+ client needs `createDefaultHttpClientWithAuthBearer({ baseURL,
457
+ getToken: () => authClient.getAccessToken(), authScheme })` from
458
+ `@molecule/app-bonds-default-react` (or the auth client built with
459
+ `createDefaultAuthClientWithHttpSync`, which mirrors the token into the
460
+ bonded client) plus `setAuthGate(() => authClient.whenRestored())`.
461
+
462
+ The restore's own requests are never held: a request the settle function issues while it
463
+ runs goes out immediately, so `setAuthGate(() => restoreSession())` cannot deadlock even
464
+ when `restoreSession` calls the gated client. A restore that awaits something else first
465
+ (a storage read, a `Promise.resolve()`) issues its request from a later continuation, which
466
+ the gate cannot recognize — that request needs `skipAuthGate: true` (see
467
+ `RequestConfig.skipAuthGate`). `@molecule/app-auth`'s own restore needs neither because it
468
+ uses `fetch` rather than the bonded client.
430
469
 
431
470
  ```typescript
432
471
  function setAuthGate(next: (() => Promise<void>) | null): void
@@ -453,6 +492,66 @@ function awaitAuthGate(request?: AuthGateRequest): Promise<void>
453
492
 
454
493
  **Returns:** A promise that settles when the gate has released the request.
455
494
 
495
+ #### `isHttpError(err)`
496
+
497
+ Whether `err` is an {@link HttpError} from this package.
498
+
499
+ ```typescript
500
+ function isHttpError(err: unknown): boolean
501
+ ```
502
+
503
+ - `err` — Any thrown value.
504
+
505
+ **Returns:** True for an `HttpError`.
506
+
507
+ #### `isAuthFailure(err)`
508
+
509
+ Whether the server REJECTED the request's credential — the only failure that
510
+ justifies clearing a session.
511
+
512
+ `401` (unauthenticated/expired token) and `403` (authenticated but refused) are
513
+ the two statuses that say "this credential no longer authorizes this session".
514
+ Everything else — `0` (aborted or offline), `404` (wrong endpoint), `5xx` (server
515
+ fault), a rate limit — says nothing about the credential.
516
+
517
+ ```typescript
518
+ function isAuthFailure(err: unknown): boolean
519
+ ```
520
+
521
+ - `err` — Any thrown value.
522
+
523
+ **Returns:** True only when `err` is an `HttpError` with status 401 or 403.
524
+
525
+ #### `isNoResponse(err)`
526
+
527
+ Whether no response was received at all: the request was aborted or the network
528
+ failed. `status === 0` is not an HTTP status — it must never be read as
529
+ "the user is not signed in".
530
+
531
+ ```typescript
532
+ function isNoResponse(err: unknown): boolean
533
+ ```
534
+
535
+ - `err` — Any thrown value.
536
+
537
+ **Returns:** True when `err` is an `HttpError` with status `0`.
538
+
539
+ #### `isAborted(err)`
540
+
541
+ Whether the request was ABORTED (an `AbortController` signal, or the browser
542
+ cancelling the fetch during a navigation) rather than failing on the network.
543
+
544
+ Both arrive as `status === 0`; this distinguishes them, so a UI can stay silent
545
+ for a cancelled request while still reporting a real outage.
546
+
547
+ ```typescript
548
+ function isAborted(err: unknown): boolean
549
+ ```
550
+
551
+ - `err` — Any thrown value.
552
+
553
+ **Returns:** True when `err` is an `HttpError` flagged `aborted`.
554
+
456
555
  #### `createFetchClient(config)`
457
556
 
458
557
  Creates a fetch-based HTTP client using the native Fetch API.
@@ -726,13 +825,26 @@ authScheme })` from `@molecule/app-bonds-default-react` (or an auth client built
726
825
  `createDefaultAuthClientWithHttpSync`, which mirrors the token into the bonded client), because
727
826
  `setAuthGate` alone sends no `Authorization` header.
728
827
 
729
- **A request the gate itself depends on must opt out of it: pass `skipAuthGate: true`.** A gate
730
- that waits for a session restore whose own request goes through this client waits on itself —
731
- that request is held by the gate waiting for it, so the restore never settles and every request
732
- the gate holds stalls until it times out (3 s). The request that restores the session for a gate
733
- you registered yourself is therefore written
734
- `http.get(currentUserEndpoint, { skipAuthGate: true })`; `@molecule/app-auth`'s own restore does
735
- not need it (it calls `fetch`, not this client).
828
+ **The gate never holds its own restore's request.** A request the settle function issues
829
+ while it runs (its call reaches this client before the function awaits anything) is part of
830
+ the restore it is waiting for, so it goes out immediately — `setAuthGate(() =>
831
+ restoreSession())` does not deadlock even when `restoreSession` uses this client. A restore
832
+ that awaits something else first and only then calls the client reaches it after that
833
+ window, and that request must opt out of the gate: `http.get(currentUserEndpoint, {
834
+ skipAuthGate: true })`. Without the opt-out the gate waits on itself, the restore never
835
+ settles, and every request the gate holds stalls until it times out (3 s).
836
+ `@molecule/app-auth`'s own restore does not need it (it calls `fetch`, not this client).
837
+
838
+ **A failed request's `status` is `0` when NO response arrived — never read it as
839
+ "signed out".** An aborted request (an `AbortController` signal, a component's
840
+ effect cleanup, a route change tearing the fetch down) and a network outage both
841
+ throw an `HttpError` with `status === 0`; the aborted ones also carry
842
+ `aborted: true` and the `http.error.aborted` key, the rest `http.error.networkError`.
843
+ Neither says anything about the session. To decide whether a session ended, use
844
+ `isAuthFailure(err)` (401/403 only); `isNoResponse(err)` identifies the no-response
845
+ case so a caller can stay silent instead of reporting an outage. **Do not write
846
+ `err instanceof HttpError && err.status < 500` as a sign-out check** — it clears
847
+ the session on every aborted navigation request.
736
848
 
737
849
  ## Translations
738
850
 
@@ -27,24 +27,28 @@
27
27
  * `setupHttpDefault()`), and a gate installed on the throwaway client the auth
28
28
  * bond saw would be silently lost.
29
29
  *
30
- * ## A request the gate is waiting for must opt out
31
- *
32
- * `awaitAuthGate` holds every request while the gate is pending — including one the gate
33
- * itself depends on. A gate that waits for a session restore whose own request goes through
34
- * the SAME client waits on itself: the restore's `GET /users/me` is held by the gate, the
35
- * restore's promise cannot settle, and nothing but the timeout releases anything (X1
36
- * xr-molecule-flash-m97 lost ~4 min to exactly this — an app registering
37
- * `setAuthGate(() => whenSettled())` over a restore that fetched through its own client, with
38
- * every request stalling the full bound and only a console warning to show for it). So a
39
- * request the gate's restore makes must pass `skipAuthGate: true`
40
- * (`RequestConfig.skipAuthGate`).
41
- *
42
- * Which held request is the gate's own is NOT detectable here: the gate is arbitrary code
43
- * returning a promise, so a request cannot be attributed to the async chain that awaits it —
44
- * and browsers have no async-context API (`AsyncContext` is not shipped) to ask. Releasing
45
- * requests merely because the gate is pending and they carry no token would drop exactly the
46
- * first-paint requests the gate exists to hold. The opt-out is therefore the fix, and a
47
- * timeout with requests held is reported as an error naming it.
30
+ * ## The gate's own restore requests are never held
31
+ *
32
+ * `awaitAuthGate` holds every request while the gate is pending — except the ones the gate's
33
+ * settle function issues itself. Those are part of the restore it is waiting for; holding them
34
+ * makes the gate wait on itself, and nothing but the timeout releases anything (X1
35
+ * xr-molecule-flash-m97 and xr-molecule-flash-m173 both lost minutes to this: an app
36
+ * registering `setAuthGate(() => restoreSession())` over a restore that fetched through the
37
+ * same client, every page held for the full bound, and 917 `GET /api/user` requests named by
38
+ * one console line). So `setAuthGate(() => restoreSession())` works as written when
39
+ * `restoreSession` calls the gated client.
40
+ *
41
+ * "Issued by the gate" means issued while the settle function is running: this package's
42
+ * fetch client awaits the gate before anything else, so a restore's call is made in the settle
43
+ * function's own synchronous execution. A restore that awaits something else first (a storage
44
+ * read, a `Promise.resolve()`) and only then calls the client issues its request from a later
45
+ * continuation, which nothing can attribute to the gate — browsers ship no async-context API
46
+ * (`AsyncContext`/`AsyncLocalStorage`) to ask, and releasing requests merely because the gate is
47
+ * pending would drop exactly the first-paint requests the gate exists to hold (m95). A provider
48
+ * whose request pipeline awaits the gate in a scheduled interceptor (the Axios bond) reaches it
49
+ * a microtask after the settle function returns, outside the window, for the same reason. Such a
50
+ * request must pass `skipAuthGate: true` (`RequestConfig.skipAuthGate`), and a timeout with
51
+ * requests held is reported at error level naming it.
48
52
  *
49
53
  * @module
50
54
  */
@@ -58,10 +62,20 @@ import type { AuthGateRequest } from './types.js';
58
62
  * immediately when no restore is in flight, so registering it never makes a
59
63
  * request wait longer than the restore it was about to race anyway.
60
64
  *
61
- * A gate whose restore sends its OWN request through the gated client deadlocks — the
62
- * gate holds the request it is waiting for. That request must pass `skipAuthGate: true`
63
- * (see `RequestConfig.skipAuthGate`); `@molecule/app-auth`'s own restore does not
64
- * need it because it uses `fetch` rather than the bonded client.
65
+ * Waiting for the restore does NOT attach its token: a separately created HTTP
66
+ * client needs `createDefaultHttpClientWithAuthBearer({ baseURL,
67
+ * getToken: () => authClient.getAccessToken(), authScheme })` from
68
+ * `@molecule/app-bonds-default-react` (or the auth client built with
69
+ * `createDefaultAuthClientWithHttpSync`, which mirrors the token into the
70
+ * bonded client) plus `setAuthGate(() => authClient.whenRestored())`.
71
+ *
72
+ * The restore's own requests are never held: a request the settle function issues while it
73
+ * runs goes out immediately, so `setAuthGate(() => restoreSession())` cannot deadlock even
74
+ * when `restoreSession` calls the gated client. A restore that awaits something else first
75
+ * (a storage read, a `Promise.resolve()`) issues its request from a later continuation, which
76
+ * the gate cannot recognize — that request needs `skipAuthGate: true` (see
77
+ * `RequestConfig.skipAuthGate`). `@molecule/app-auth`'s own restore needs neither because it
78
+ * uses `fetch` rather than the bonded client.
65
79
  *
66
80
  * @param next - The gate, or `null` to clear a previously registered one.
67
81
  *
@@ -1 +1 @@
1
- {"version":3,"file":"auth-gate.d.ts","sourceRoot":"","sources":["../src/auth-gate.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiDG;AAIH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA;AA6CjD;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,eAAO,MAAM,WAAW,GAAI,MAAM,CAAC,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC,GAAG,IAAI,KAAG,IAGhE,CAAA;AA6BD;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,aAAa,GAAU,UAAU,eAAe,KAAG,OAAO,CAAC,IAAI,CAuC3E,CAAA"}
1
+ {"version":3,"file":"auth-gate.d.ts","sourceRoot":"","sources":["../src/auth-gate.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqDG;AAIH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA;AAkEjD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH,eAAO,MAAM,WAAW,GAAI,MAAM,CAAC,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC,GAAG,IAAI,KAAG,IAIhE,CAAA;AA8ED;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,aAAa,GAAU,UAAU,eAAe,KAAG,OAAO,CAAC,IAAI,CAwC3E,CAAA"}
package/dist/auth-gate.js CHANGED
@@ -27,24 +27,28 @@
27
27
  * `setupHttpDefault()`), and a gate installed on the throwaway client the auth
28
28
  * bond saw would be silently lost.
29
29
  *
30
- * ## A request the gate is waiting for must opt out
31
- *
32
- * `awaitAuthGate` holds every request while the gate is pending — including one the gate
33
- * itself depends on. A gate that waits for a session restore whose own request goes through
34
- * the SAME client waits on itself: the restore's `GET /users/me` is held by the gate, the
35
- * restore's promise cannot settle, and nothing but the timeout releases anything (X1
36
- * xr-molecule-flash-m97 lost ~4 min to exactly this — an app registering
37
- * `setAuthGate(() => whenSettled())` over a restore that fetched through its own client, with
38
- * every request stalling the full bound and only a console warning to show for it). So a
39
- * request the gate's restore makes must pass `skipAuthGate: true`
40
- * (`RequestConfig.skipAuthGate`).
41
- *
42
- * Which held request is the gate's own is NOT detectable here: the gate is arbitrary code
43
- * returning a promise, so a request cannot be attributed to the async chain that awaits it —
44
- * and browsers have no async-context API (`AsyncContext` is not shipped) to ask. Releasing
45
- * requests merely because the gate is pending and they carry no token would drop exactly the
46
- * first-paint requests the gate exists to hold. The opt-out is therefore the fix, and a
47
- * timeout with requests held is reported as an error naming it.
30
+ * ## The gate's own restore requests are never held
31
+ *
32
+ * `awaitAuthGate` holds every request while the gate is pending — except the ones the gate's
33
+ * settle function issues itself. Those are part of the restore it is waiting for; holding them
34
+ * makes the gate wait on itself, and nothing but the timeout releases anything (X1
35
+ * xr-molecule-flash-m97 and xr-molecule-flash-m173 both lost minutes to this: an app
36
+ * registering `setAuthGate(() => restoreSession())` over a restore that fetched through the
37
+ * same client, every page held for the full bound, and 917 `GET /api/user` requests named by
38
+ * one console line). So `setAuthGate(() => restoreSession())` works as written when
39
+ * `restoreSession` calls the gated client.
40
+ *
41
+ * "Issued by the gate" means issued while the settle function is running: this package's
42
+ * fetch client awaits the gate before anything else, so a restore's call is made in the settle
43
+ * function's own synchronous execution. A restore that awaits something else first (a storage
44
+ * read, a `Promise.resolve()`) and only then calls the client issues its request from a later
45
+ * continuation, which nothing can attribute to the gate — browsers ship no async-context API
46
+ * (`AsyncContext`/`AsyncLocalStorage`) to ask, and releasing requests merely because the gate is
47
+ * pending would drop exactly the first-paint requests the gate exists to hold (m95). A provider
48
+ * whose request pipeline awaits the gate in a scheduled interceptor (the Axios bond) reaches it
49
+ * a microtask after the settle function returns, outside the window, for the same reason. Such a
50
+ * request must pass `skipAuthGate: true` (`RequestConfig.skipAuthGate`), and a timeout with
51
+ * requests held is reported at error level naming it.
48
52
  *
49
53
  * @module
50
54
  */
@@ -66,6 +70,25 @@ const heldRequests = new Map();
66
70
  * gates. Cleared when the same gate later releases a request normally.
67
71
  */
68
72
  let reportedStall = null;
73
+ /**
74
+ * The settle-function invocation requests are currently waiting on, shared by every request
75
+ * that arrives while the gate is pending.
76
+ *
77
+ * Without it each held request re-invokes the gate, and a gate that issues a request on every
78
+ * call floods the network: the m97 shape measured 855 `fetch` calls for one page (`task-auth-
79
+ * gate-deadlock.report.md`). `null` when no invocation is in flight; `setAuthGate` clears it
80
+ * so a re-registered gate is never shared with the old one's waiters.
81
+ */
82
+ let inFlightGate = null;
83
+ /**
84
+ * True only while the gate's settle function is executing synchronously.
85
+ *
86
+ * A request that reaches `awaitAuthGate` in this window was issued BY the restore — the fetch
87
+ * client's `request()` awaits the gate before anything else, so the call is made in the settle
88
+ * function's own execution. Holding it would make the gate wait on itself (see the module
89
+ * doc); requests issued after the function awaits something else are held as usual.
90
+ */
91
+ let gateSettling = false;
69
92
  /**
70
93
  * How long a request may be held by the gate before it is sent anyway.
71
94
  *
@@ -96,10 +119,20 @@ const GATE_TIMEOUT_MS = 3_000;
96
119
  * immediately when no restore is in flight, so registering it never makes a
97
120
  * request wait longer than the restore it was about to race anyway.
98
121
  *
99
- * A gate whose restore sends its OWN request through the gated client deadlocks — the
100
- * gate holds the request it is waiting for. That request must pass `skipAuthGate: true`
101
- * (see `RequestConfig.skipAuthGate`); `@molecule/app-auth`'s own restore does not
102
- * need it because it uses `fetch` rather than the bonded client.
122
+ * Waiting for the restore does NOT attach its token: a separately created HTTP
123
+ * client needs `createDefaultHttpClientWithAuthBearer({ baseURL,
124
+ * getToken: () => authClient.getAccessToken(), authScheme })` from
125
+ * `@molecule/app-bonds-default-react` (or the auth client built with
126
+ * `createDefaultAuthClientWithHttpSync`, which mirrors the token into the
127
+ * bonded client) plus `setAuthGate(() => authClient.whenRestored())`.
128
+ *
129
+ * The restore's own requests are never held: a request the settle function issues while it
130
+ * runs goes out immediately, so `setAuthGate(() => restoreSession())` cannot deadlock even
131
+ * when `restoreSession` calls the gated client. A restore that awaits something else first
132
+ * (a storage read, a `Promise.resolve()`) issues its request from a later continuation, which
133
+ * the gate cannot recognize — that request needs `skipAuthGate: true` (see
134
+ * `RequestConfig.skipAuthGate`). `@molecule/app-auth`'s own restore needs neither because it
135
+ * uses `fetch` rather than the bonded client.
103
136
  *
104
137
  * @param next - The gate, or `null` to clear a previously registered one.
105
138
  *
@@ -112,6 +145,7 @@ const GATE_TIMEOUT_MS = 3_000;
112
145
  */
113
146
  export const setAuthGate = (next) => {
114
147
  gate = next;
148
+ inFlightGate = null;
115
149
  reportedStall = null;
116
150
  };
117
151
  /**
@@ -121,21 +155,69 @@ export const setAuthGate = (next) => {
121
155
  const describeRequest = (request) => request?.method || request?.url
122
156
  ? `${request?.method ?? 'GET'} ${request?.url ?? ''}`.trim()
123
157
  : 'a request';
158
+ /**
159
+ * How many held request names the stalled-gate report prints before summarizing the rest.
160
+ *
161
+ * The report is console output, and every reader of it truncates: molecule-dev's route walk
162
+ * keeps the first 200 characters of a console error, so the sentence naming the fix has to
163
+ * come first — and the request list is capped so the message stays readable when a deadlocked
164
+ * gate has held hundreds of requests (xr-molecule-flash-m173: 917 `GET /api/user`).
165
+ */
166
+ const MAX_NAMED_HELD_REQUESTS = 5;
124
167
  /**
125
168
  * Reports a gate that timed out while holding requests: once per stuck gate, at error level
126
169
  * so it reaches the page's error console and any error transport — a console warning on a
127
170
  * deployed URL reads as "the site is slow", which is what the gate itself was added for.
171
+ *
172
+ * Leads with the cause and the fix, then names at most `MAX_NAMED_HELD_REQUESTS` distinct
173
+ * requests and counts the rest: an unbounded join buried the fix clause behind 900 names in
174
+ * xr-molecule-flash-m173, and no reader of the line ever reached it.
128
175
  */
129
176
  const reportStalledGate = (stuck) => {
130
177
  if (reportedStall === stuck)
131
178
  return;
132
179
  reportedStall = stuck;
133
- const held = [...heldRequests.values()].join(', ');
134
- logger.error(`The auth gate has not settled after ${GATE_TIMEOUT_MS}ms and ${heldRequests.size} request(s) ` +
135
- `were held by it (${held}); sending them without waiting. If the gate waits for a session ` +
136
- `restore that makes its own request through this HTTP client, that request is being held by ` +
137
- `the gate waiting for it: send it with \`skipAuthGate: true\`, or clear the gate with ` +
138
- `\`setAuthGate(null)\` if nothing restores a session.`);
180
+ const names = [...new Set(heldRequests.values())];
181
+ const shown = names.slice(0, MAX_NAMED_HELD_REQUESTS);
182
+ const more = heldRequests.size - shown.length;
183
+ logger.error(`The auth gate is waiting on itself: its restore's request is held by it. Send that ` +
184
+ `request with \`skipAuthGate: true\`, or clear the gate with \`setAuthGate(null)\` if ` +
185
+ `nothing restores a session. Held ${heldRequests.size} request(s) for ` +
186
+ `${GATE_TIMEOUT_MS}ms${shown.length ? `: ${shown.join(', ')}` : ''}` +
187
+ `${more > 0 ? ` (and ${more} more)` : ''}.`);
188
+ };
189
+ /**
190
+ * Starts the gate's settle function — once, shared by every request that arrives while it is
191
+ * pending — turning a rejection (or a synchronous throw) into a logged warning so a failed
192
+ * restore releases its waiters instead of rejecting them.
193
+ *
194
+ * `gateSettling` is true only for the function's synchronous execution: the IIFE runs
195
+ * `current()` up to its first `await` before this call returns, and any request the restore
196
+ * issues there (the gated client's `request()` awaits the gate before anything else) bypasses
197
+ * the gate instead of waiting on the invocation it belongs to.
198
+ */
199
+ const invokeGate = (current) => {
200
+ if (inFlightGate)
201
+ return inFlightGate;
202
+ let invocation;
203
+ gateSettling = true;
204
+ try {
205
+ invocation = (async () => current())();
206
+ }
207
+ finally {
208
+ gateSettling = false;
209
+ }
210
+ const shared = invocation.catch((error) => {
211
+ logger.warn('The auth gate rejected; sending the request without waiting for it', {
212
+ error,
213
+ });
214
+ });
215
+ inFlightGate = shared;
216
+ void shared.then(() => {
217
+ if (inFlightGate === shared)
218
+ inFlightGate = null;
219
+ });
220
+ return shared;
139
221
  };
140
222
  /**
141
223
  * Awaits the registered gate, if any. Every HTTP provider calls this before it
@@ -160,19 +242,20 @@ export const awaitAuthGate = async (request) => {
160
242
  const current = gate;
161
243
  if (!current)
162
244
  return;
245
+ // Issued while the gate's settle function is running: part of the restore it is settling,
246
+ // never held by it. See `invokeGate` and the module doc.
247
+ if (gateSettling)
248
+ return;
163
249
  const token = Symbol('held-request');
164
250
  heldRequests.set(token, describeRequest(request));
165
251
  let timer;
166
252
  let timedOut = false;
167
253
  try {
168
254
  await Promise.race([
169
- // `(async () => current())()` also turns a gate that throws SYNCHRONOUSLY into a rejection:
170
- // a gate is someone else's code, and no shape of it may reject the request it was holding.
171
- (async () => current())().catch((error) => {
172
- logger.warn('The auth gate rejected; sending the request without waiting for it', {
173
- error,
174
- });
175
- }),
255
+ // One invocation, shared: `invokeGate` also turns a gate that throws SYNCHRONOUSLY into
256
+ // a rejection — a gate is someone else's code, and no shape of it may reject the
257
+ // request it was holding.
258
+ invokeGate(current),
176
259
  new Promise((resolve) => {
177
260
  timer = setTimeout(() => {
178
261
  timedOut = true;
@@ -1 +1 @@
1
- {"version":3,"file":"auth-gate.js","sourceRoot":"","sources":["../src/auth-gate.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiDG;AAEH,OAAO,EAAE,SAA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AO;QAAE,aAAa,GAAG,IAAI,CAAA;AAClE,CAAC,CAAA"}
@@ -0,0 +1,67 @@
1
+ /**
2
+ * Classify a failed request instead of reading its `status` by hand.
3
+ *
4
+ * A failure from this package is an {@link HttpError} whose `status` is either an
5
+ * HTTP status (the server answered) or `0` (it did not — the request was aborted or
6
+ * the network failed). Code that clears a session must ask "did the server REJECT
7
+ * the credential?", which is `status === 401 || status === 403` and nothing else:
8
+ *
9
+ * ```typescript
10
+ * try {
11
+ * await http.get('/projects')
12
+ * } catch (err) {
13
+ * if (isAuthFailure(err)) clearSession()
14
+ * else if (isNoResponse(err)) return // aborted / offline — keep the session
15
+ * else showError(err)
16
+ * }
17
+ * ```
18
+ *
19
+ * `err instanceof HttpError && err.status < 500` is the trap these helpers exist to
20
+ * replace: an aborted request (a component unmounting, a route change cancelling an
21
+ * in-flight fetch) and a network outage both arrive with `status === 0`, so that
22
+ * check signs the user out on every navigation that cancels a request.
23
+ *
24
+ * @module
25
+ */
26
+ import { HttpError } from './types.js';
27
+ /**
28
+ * Whether `err` is an {@link HttpError} from this package.
29
+ *
30
+ * @param err - Any thrown value.
31
+ * @returns True for an `HttpError`.
32
+ */
33
+ export declare function isHttpError(err: unknown): err is HttpError;
34
+ /**
35
+ * Whether the server REJECTED the request's credential — the only failure that
36
+ * justifies clearing a session.
37
+ *
38
+ * `401` (unauthenticated/expired token) and `403` (authenticated but refused) are
39
+ * the two statuses that say "this credential no longer authorizes this session".
40
+ * Everything else — `0` (aborted or offline), `404` (wrong endpoint), `5xx` (server
41
+ * fault), a rate limit — says nothing about the credential.
42
+ *
43
+ * @param err - Any thrown value.
44
+ * @returns True only when `err` is an `HttpError` with status 401 or 403.
45
+ */
46
+ export declare function isAuthFailure(err: unknown): boolean;
47
+ /**
48
+ * Whether no response was received at all: the request was aborted or the network
49
+ * failed. `status === 0` is not an HTTP status — it must never be read as
50
+ * "the user is not signed in".
51
+ *
52
+ * @param err - Any thrown value.
53
+ * @returns True when `err` is an `HttpError` with status `0`.
54
+ */
55
+ export declare function isNoResponse(err: unknown): boolean;
56
+ /**
57
+ * Whether the request was ABORTED (an `AbortController` signal, or the browser
58
+ * cancelling the fetch during a navigation) rather than failing on the network.
59
+ *
60
+ * Both arrive as `status === 0`; this distinguishes them, so a UI can stay silent
61
+ * for a cancelled request while still reporting a real outage.
62
+ *
63
+ * @param err - Any thrown value.
64
+ * @returns True when `err` is an `HttpError` flagged `aborted`.
65
+ */
66
+ export declare function isAborted(err: unknown): boolean;
67
+ //# sourceMappingURL=errors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAA;AAEtC;;;;;GAKG;AACH,wBAAgB,WAAW,CAAC,GAAG,EAAE,OAAO,GAAG,GAAG,IAAI,SAAS,CAE1D;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,aAAa,CAAC,GAAG,EAAE,OAAO,GAAG,OAAO,CAEnD;AAED;;;;;;;GAOG;AACH,wBAAgB,YAAY,CAAC,GAAG,EAAE,OAAO,GAAG,OAAO,CAElD;AAED;;;;;;;;;GASG;AACH,wBAAgB,SAAS,CAAC,GAAG,EAAE,OAAO,GAAG,OAAO,CAE/C"}
package/dist/errors.js ADDED
@@ -0,0 +1,75 @@
1
+ /**
2
+ * Classify a failed request instead of reading its `status` by hand.
3
+ *
4
+ * A failure from this package is an {@link HttpError} whose `status` is either an
5
+ * HTTP status (the server answered) or `0` (it did not — the request was aborted or
6
+ * the network failed). Code that clears a session must ask "did the server REJECT
7
+ * the credential?", which is `status === 401 || status === 403` and nothing else:
8
+ *
9
+ * ```typescript
10
+ * try {
11
+ * await http.get('/projects')
12
+ * } catch (err) {
13
+ * if (isAuthFailure(err)) clearSession()
14
+ * else if (isNoResponse(err)) return // aborted / offline — keep the session
15
+ * else showError(err)
16
+ * }
17
+ * ```
18
+ *
19
+ * `err instanceof HttpError && err.status < 500` is the trap these helpers exist to
20
+ * replace: an aborted request (a component unmounting, a route change cancelling an
21
+ * in-flight fetch) and a network outage both arrive with `status === 0`, so that
22
+ * check signs the user out on every navigation that cancels a request.
23
+ *
24
+ * @module
25
+ */
26
+ import { HttpError } from './types.js';
27
+ /**
28
+ * Whether `err` is an {@link HttpError} from this package.
29
+ *
30
+ * @param err - Any thrown value.
31
+ * @returns True for an `HttpError`.
32
+ */
33
+ export function isHttpError(err) {
34
+ return err instanceof HttpError;
35
+ }
36
+ /**
37
+ * Whether the server REJECTED the request's credential — the only failure that
38
+ * justifies clearing a session.
39
+ *
40
+ * `401` (unauthenticated/expired token) and `403` (authenticated but refused) are
41
+ * the two statuses that say "this credential no longer authorizes this session".
42
+ * Everything else — `0` (aborted or offline), `404` (wrong endpoint), `5xx` (server
43
+ * fault), a rate limit — says nothing about the credential.
44
+ *
45
+ * @param err - Any thrown value.
46
+ * @returns True only when `err` is an `HttpError` with status 401 or 403.
47
+ */
48
+ export function isAuthFailure(err) {
49
+ return isHttpError(err) && (err.status === 401 || err.status === 403);
50
+ }
51
+ /**
52
+ * Whether no response was received at all: the request was aborted or the network
53
+ * failed. `status === 0` is not an HTTP status — it must never be read as
54
+ * "the user is not signed in".
55
+ *
56
+ * @param err - Any thrown value.
57
+ * @returns True when `err` is an `HttpError` with status `0`.
58
+ */
59
+ export function isNoResponse(err) {
60
+ return isHttpError(err) && err.status === 0;
61
+ }
62
+ /**
63
+ * Whether the request was ABORTED (an `AbortController` signal, or the browser
64
+ * cancelling the fetch during a navigation) rather than failing on the network.
65
+ *
66
+ * Both arrive as `status === 0`; this distinguishes them, so a UI can stay silent
67
+ * for a cancelled request while still reporting a real outage.
68
+ *
69
+ * @param err - Any thrown value.
70
+ * @returns True when `err` is an `HttpError` flagged `aborted`.
71
+ */
72
+ export function isAborted(err) {
73
+ return isHttpError(err) && err.aborted;
74
+ }
75
+ //# sourceMappingURL=errors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAA;AAEtC;;;;;GAKG;AACH,MAAM,UAAU,WAAW,CAAC,GAAY;IACtC,OAAO,GAAG,YAAY,SAAS,CAAA;AACjC,CAAC;AAED;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,aAAa,CAAC,GAAY;IACxC,OAAO,WAAW,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,MAAM,KAAK,GAAG,IAAI,GAAG,CAAC,MAAM,KAAK,GAAG,CAAC,CAAA;AACvE,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,YAAY,CAAC,GAAY;IACvC,OAAO,WAAW,CAAC,GAAG,CAAC,IAAI,GAAG,CAAC,MAAM,KAAK,CAAC,CAAA;AAC7C,CAAC;AAED;;;;;;;;;GASG;AACH,MAAM,UAAU,SAAS,CAAC,GAAY;IACpC,OAAO,WAAW,CAAC,GAAG,CAAC,IAAI,GAAG,CAAC,OAAO,CAAA;AACxC,CAAC"}
package/dist/index.d.ts CHANGED
@@ -78,18 +78,32 @@
78
78
  * `createDefaultAuthClientWithHttpSync`, which mirrors the token into the bonded client), because
79
79
  * `setAuthGate` alone sends no `Authorization` header.
80
80
  *
81
- * **A request the gate itself depends on must opt out of it: pass `skipAuthGate: true`.** A gate
82
- * that waits for a session restore whose own request goes through this client waits on itself —
83
- * that request is held by the gate waiting for it, so the restore never settles and every request
84
- * the gate holds stalls until it times out (3 s). The request that restores the session for a gate
85
- * you registered yourself is therefore written
86
- * `http.get(currentUserEndpoint, { skipAuthGate: true })`; `@molecule/app-auth`'s own restore does
87
- * not need it (it calls `fetch`, not this client).
81
+ * **The gate never holds its own restore's request.** A request the settle function issues
82
+ * while it runs (its call reaches this client before the function awaits anything) is part of
83
+ * the restore it is waiting for, so it goes out immediately — `setAuthGate(() =>
84
+ * restoreSession())` does not deadlock even when `restoreSession` uses this client. A restore
85
+ * that awaits something else first and only then calls the client reaches it after that
86
+ * window, and that request must opt out of the gate: `http.get(currentUserEndpoint, {
87
+ * skipAuthGate: true })`. Without the opt-out the gate waits on itself, the restore never
88
+ * settles, and every request the gate holds stalls until it times out (3 s).
89
+ * `@molecule/app-auth`'s own restore does not need it (it calls `fetch`, not this client).
90
+ *
91
+ * **A failed request's `status` is `0` when NO response arrived — never read it as
92
+ * "signed out".** An aborted request (an `AbortController` signal, a component's
93
+ * effect cleanup, a route change tearing the fetch down) and a network outage both
94
+ * throw an `HttpError` with `status === 0`; the aborted ones also carry
95
+ * `aborted: true` and the `http.error.aborted` key, the rest `http.error.networkError`.
96
+ * Neither says anything about the session. To decide whether a session ended, use
97
+ * `isAuthFailure(err)` (401/403 only); `isNoResponse(err)` identifies the no-response
98
+ * case so a caller can stay silent instead of reporting an outage. **Do not write
99
+ * `err instanceof HttpError && err.status < 500` as a sign-out check** — it clears
100
+ * the session on every aborted navigation request.
88
101
  *
89
102
  * @module
90
103
  */
91
104
  export * from './auth-gate.js';
92
105
  export * from './client.js';
106
+ export * from './errors.js';
93
107
  export * from './interceptors.js';
94
108
  export * from './provider.js';
95
109
  export * from './types.js';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyFG;AAEH,cAAc,gBAAgB,CAAA;AAC9B,cAAc,aAAa,CAAA;AAC3B,cAAc,mBAAmB,CAAA;AACjC,cAAc,eAAe,CAAA;AAC7B,cAAc,YAAY,CAAA;AAC1B,cAAc,aAAa,CAAA;AAC3B,cAAc,gBAAgB,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsGG;AAEH,cAAc,gBAAgB,CAAA;AAC9B,cAAc,aAAa,CAAA;AAC3B,cAAc,aAAa,CAAA;AAC3B,cAAc,mBAAmB,CAAA;AACjC,cAAc,eAAe,CAAA;AAC7B,cAAc,YAAY,CAAA;AAC1B,cAAc,aAAa,CAAA;AAC3B,cAAc,gBAAgB,CAAA"}
package/dist/index.js CHANGED
@@ -78,18 +78,32 @@
78
78
  * `createDefaultAuthClientWithHttpSync`, which mirrors the token into the bonded client), because
79
79
  * `setAuthGate` alone sends no `Authorization` header.
80
80
  *
81
- * **A request the gate itself depends on must opt out of it: pass `skipAuthGate: true`.** A gate
82
- * that waits for a session restore whose own request goes through this client waits on itself —
83
- * that request is held by the gate waiting for it, so the restore never settles and every request
84
- * the gate holds stalls until it times out (3 s). The request that restores the session for a gate
85
- * you registered yourself is therefore written
86
- * `http.get(currentUserEndpoint, { skipAuthGate: true })`; `@molecule/app-auth`'s own restore does
87
- * not need it (it calls `fetch`, not this client).
81
+ * **The gate never holds its own restore's request.** A request the settle function issues
82
+ * while it runs (its call reaches this client before the function awaits anything) is part of
83
+ * the restore it is waiting for, so it goes out immediately — `setAuthGate(() =>
84
+ * restoreSession())` does not deadlock even when `restoreSession` uses this client. A restore
85
+ * that awaits something else first and only then calls the client reaches it after that
86
+ * window, and that request must opt out of the gate: `http.get(currentUserEndpoint, {
87
+ * skipAuthGate: true })`. Without the opt-out the gate waits on itself, the restore never
88
+ * settles, and every request the gate holds stalls until it times out (3 s).
89
+ * `@molecule/app-auth`'s own restore does not need it (it calls `fetch`, not this client).
90
+ *
91
+ * **A failed request's `status` is `0` when NO response arrived — never read it as
92
+ * "signed out".** An aborted request (an `AbortController` signal, a component's
93
+ * effect cleanup, a route change tearing the fetch down) and a network outage both
94
+ * throw an `HttpError` with `status === 0`; the aborted ones also carry
95
+ * `aborted: true` and the `http.error.aborted` key, the rest `http.error.networkError`.
96
+ * Neither says anything about the session. To decide whether a session ended, use
97
+ * `isAuthFailure(err)` (401/403 only); `isNoResponse(err)` identifies the no-response
98
+ * case so a caller can stay silent instead of reporting an outage. **Do not write
99
+ * `err instanceof HttpError && err.status < 500` as a sign-out check** — it clears
100
+ * the session on every aborted navigation request.
88
101
  *
89
102
  * @module
90
103
  */
91
104
  export * from './auth-gate.js';
92
105
  export * from './client.js';
106
+ export * from './errors.js';
93
107
  export * from './interceptors.js';
94
108
  export * from './provider.js';
95
109
  export * from './types.js';
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyFG;AAEH,cAAc,gBAAgB,CAAA;AAC9B,cAAc,aAAa,CAAA;AAC3B,cAAc,mBAAmB,CAAA;AACjC,cAAc,eAAe,CAAA;AAC7B,cAAc,YAAY,CAAA;AAC1B,cAAc,aAAa,CAAA;AAC3B,cAAc,gBAAgB,CAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsGG;AAEH,cAAc,gBAAgB,CAAA;AAC9B,cAAc,aAAa,CAAA;AAC3B,cAAc,aAAa,CAAA;AAC3B,cAAc,mBAAmB,CAAA;AACjC,cAAc,eAAe,CAAA;AAC7B,cAAc,YAAY,CAAA;AAC1B,cAAc,aAAa,CAAA;AAC3B,cAAc,gBAAgB,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../src/provider.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAMH,OAAO,KAAK,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAA;AAQ/D;;;;;;;;;GASG;AACH,eAAO,MAAM,iBAAiB,GAAI,SAAQ,gBAAqB,KAAG,UAwXjE,CAAA"}
1
+ {"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../src/provider.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAMH,OAAO,KAAK,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAA;AAQ/D;;;;;;;;;GASG;AACH,eAAO,MAAM,iBAAiB,GAAI,SAAQ,gBAAqB,KAAG,UAiYjE,CAAA"}
package/dist/provider.js CHANGED
@@ -257,9 +257,17 @@ export const createFetchClient = (config = {}) => {
257
257
  else {
258
258
  logger.error('Network error', finalConfig.method, url, err);
259
259
  }
260
+ // An abort and a navigation cancellation are the SAME fact to a caller —
261
+ // the request was cancelled before any response — and neither is a network
262
+ // outage. Flag it (`aborted`) and give it its own errorKey so app code does
263
+ // not have to parse the message, and so a session-clearing check can tell
264
+ // it apart from a real failure without treating `status === 0` as a 4xx.
265
+ const aborted = isAbort || isNavCancel;
260
266
  const error = new HttpError(err instanceof Error
261
267
  ? err.message
262
- : t('http.error.networkError', undefined, { defaultValue: 'Network error' }), 0, undefined, finalConfig, 'http.error.networkError');
268
+ : t(aborted ? 'http.error.aborted' : 'http.error.networkError', undefined, {
269
+ defaultValue: aborted ? 'Request aborted' : 'Network error',
270
+ }), 0, undefined, finalConfig, aborted ? 'http.error.aborted' : 'http.error.networkError', aborted);
263
271
  // Apply error interceptors
264
272
  let finalError = error;
265
273
  for (const interceptor of errorInterceptors) {
@@ -1 +1 @@
1
- {"version":3,"file":"provider.js","sourceRoot":"","sources":["../src/provider.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,C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ACnB,CAAC;QAED,YAAY;YACV,OAAO,SAAS,CAAA;QAClB,CAAC;QAED,WAAW,CAAC,OAAmB;YAC7B,iBAAiB,CAAC,GAAG,CAAC,OAAO,CAAC,CAAA;YAC9B,OAAO,GAAG,EAAE,CAAC,iBAAiB,CAAC,MAAM,CAAC,OAAO,CAAC,CAAA;QAChD,CAAC;KACF,CAAA;IAED,OAAO,MAAM,CAAA;AACf,CAAC,CAAA"}
package/dist/types.d.ts CHANGED
@@ -30,11 +30,15 @@ export interface RequestConfig {
30
30
  /**
31
31
  * Send this request WITHOUT waiting for the session restore (the auth gate).
32
32
  *
33
- * A request the gate itself depends on must set this. A gate registered with
34
- * `setAuthGate` that waits for a session restore whose own request goes through this
35
- * client otherwise waits on itself: the gate holds the restore's request, the restore's
36
- * promise never settles, and every request on the page stalls until the gate times out —
37
- * so pass `skipAuthGate: true` on the restore's own request:
33
+ * A request the gate's restore issues from a LATER continuation must set this. The gate
34
+ * recognizes a request the settle function issues while it runs and never holds it — this
35
+ * package's client awaits the gate before anything else, so a `restoreSession()` that calls
36
+ * it directly does not deadlock. But a restore that awaits something else first
37
+ * (`await storage.get()`), then calls the client, reaches `awaitAuthGate` after that window:
38
+ * the gate then waits on itself, and every request on the page stalls until the gate times
39
+ * out (3 s) — so pass `skipAuthGate: true` on that request. A provider that awaits the gate
40
+ * inside a scheduled interceptor (the Axios bond) also reaches it after the window, so its
41
+ * restore's request needs the opt-out.
38
42
  *
39
43
  * ```typescript
40
44
  * // the request the gate's restore makes, through the same client the gate holds back
@@ -43,7 +47,8 @@ export interface RequestConfig {
43
47
  *
44
48
  * `@molecule/app-auth`'s own restore does not need it — it sends its request with
45
49
  * `fetch`, not through this client. An app with its own session store that registers a
46
- * gate with `setAuthGate` does.
50
+ * gate with `setAuthGate` does not need it either when its restore calls the client
51
+ * directly.
47
52
  */
48
53
  skipAuthGate?: boolean;
49
54
  /**
@@ -134,12 +139,47 @@ export interface HttpResponse<T = unknown> {
134
139
  }
135
140
  /**
136
141
  * HTTP error with response details.
142
+ *
143
+ * **`status` is an HTTP status when the server answered, and `0` when it did not.**
144
+ * A `0` means NO response exists: the request was aborted (an `AbortController`, a
145
+ * component's effect cleanup, a route change tearing the request down) or the
146
+ * network failed before anything came back. It is not an HTTP status at all, so it
147
+ * says nothing about the session — an app must never treat `status < 500` as
148
+ * "signed out", because every aborted request on a route change would clear the
149
+ * session. The correct check is {@link isAuthFailure} (`status === 401 || status === 403`);
150
+ * `isNoResponse` (`status === 0`) identifies this case.
151
+ *
152
+ * @example
153
+ * ```typescript
154
+ * try {
155
+ * await http.get('/projects')
156
+ * } catch (err) {
157
+ * if (isAuthFailure(err)) clearSession() // 401/403: the server rejected the credential
158
+ * else if (isNoResponse(err)) return // aborted or offline — not a session decision
159
+ * else showError(err)
160
+ * }
161
+ * ```
137
162
  */
138
163
  export declare class HttpError extends Error {
139
164
  status: number;
140
165
  response?: HttpResponse | undefined;
141
166
  config?: FullRequestConfig | undefined;
142
167
  errorKey?: string | undefined;
143
- constructor(message: string, status: number, response?: HttpResponse | undefined, config?: FullRequestConfig | undefined, errorKey?: string | undefined);
168
+ aborted: boolean;
169
+ /**
170
+ * Builds a failed-request error.
171
+ *
172
+ * @param message - Human-readable message (already translated where a key exists).
173
+ * @param status - HTTP status, or `0` when no response was received (aborted / network failure).
174
+ * @param response - Parsed response when the server answered, otherwise undefined.
175
+ * @param config - The request config that failed.
176
+ * @param errorKey - Translation key for the failure (`http.error.aborted` for an
177
+ * aborted request, `http.error.networkError` for a real network failure).
178
+ * @param aborted - Whether the request was aborted before a response: an
179
+ * `AbortController` signal (component cleanup, a cancelled request) or the
180
+ * browser tearing the fetch down during a navigation. Distinguishes an abort
181
+ * from a network outage on the same `status === 0`, without parsing the message.
182
+ */
183
+ constructor(message: string, status: number, response?: HttpResponse | undefined, config?: FullRequestConfig | undefined, errorKey?: string | undefined, aborted?: boolean);
144
184
  }
145
185
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version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;;;;;OAaG;gBAED,OAAO,EAAE,MAAM,EACR,MAAM,EAAE,MAAM,EACd,QAAQ,CAAC,EAAE,YAAY,YAAA,EACvB,MAAM,CAAC,EAAE,iBAAiB,YAAA,EAC1B,QAAQ,CAAC,EAAE,MAAM,YAAA,EACjB,OAAO,UAAQ;CAKzB"}
package/dist/types.js CHANGED
@@ -5,18 +5,54 @@
5
5
  */
6
6
  /**
7
7
  * HTTP error with response details.
8
+ *
9
+ * **`status` is an HTTP status when the server answered, and `0` when it did not.**
10
+ * A `0` means NO response exists: the request was aborted (an `AbortController`, a
11
+ * component's effect cleanup, a route change tearing the request down) or the
12
+ * network failed before anything came back. It is not an HTTP status at all, so it
13
+ * says nothing about the session — an app must never treat `status < 500` as
14
+ * "signed out", because every aborted request on a route change would clear the
15
+ * session. The correct check is {@link isAuthFailure} (`status === 401 || status === 403`);
16
+ * `isNoResponse` (`status === 0`) identifies this case.
17
+ *
18
+ * @example
19
+ * ```typescript
20
+ * try {
21
+ * await http.get('/projects')
22
+ * } catch (err) {
23
+ * if (isAuthFailure(err)) clearSession() // 401/403: the server rejected the credential
24
+ * else if (isNoResponse(err)) return // aborted or offline — not a session decision
25
+ * else showError(err)
26
+ * }
27
+ * ```
8
28
  */
9
29
  export class HttpError extends Error {
10
30
  status;
11
31
  response;
12
32
  config;
13
33
  errorKey;
14
- constructor(message, status, response, config, errorKey) {
34
+ aborted;
35
+ /**
36
+ * Builds a failed-request error.
37
+ *
38
+ * @param message - Human-readable message (already translated where a key exists).
39
+ * @param status - HTTP status, or `0` when no response was received (aborted / network failure).
40
+ * @param response - Parsed response when the server answered, otherwise undefined.
41
+ * @param config - The request config that failed.
42
+ * @param errorKey - Translation key for the failure (`http.error.aborted` for an
43
+ * aborted request, `http.error.networkError` for a real network failure).
44
+ * @param aborted - Whether the request was aborted before a response: an
45
+ * `AbortController` signal (component cleanup, a cancelled request) or the
46
+ * browser tearing the fetch down during a navigation. Distinguishes an abort
47
+ * from a network outage on the same `status === 0`, without parsing the message.
48
+ */
49
+ constructor(message, status, response, config, errorKey, aborted = false) {
15
50
  super(message);
16
51
  this.status = status;
17
52
  this.response = response;
18
53
  this.config = config;
19
54
  this.errorKey = errorKey;
55
+ this.aborted = aborted;
20
56
  this.name = 'HttpError';
21
57
  }
22
58
  }
package/dist/types.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAwJH;;GAEG;AACH,MAAM,OAAO,SAAU,SAAQ,KAAK;IAGzB;IACA;IACA;IACA;IALT,YACE,OAAe,EACR,MAAc,EACd,QAAuB,EACvB,MAA0B,EAC1B,QAAiB;QAExB,KAAK,CAAC,OAAO,CAAC,CAAA;QALP,WAAM,GAAN,MAAM,CAAQ;QACd,aAAQ,GAAR,QAAQ,CAAe;QACvB,WAAM,GAAN,MAAM,CAAoB;QAC1B,aAAQ,GAAR,QAAQ,CAAS;QAGxB,IAAI,CAAC,IAAI,GAAG,WAAW,CAAA;IACzB,CAAC;CACF"}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AA6JH;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,MAAM,OAAO,SAAU,SAAQ,KAAK;IAiBzB;IACA;IACA;IACA;IACA;IApBT;;;;;;;;;;;;;OAaG;IACH,YACE,OAAe,EACR,MAAc,EACd,QAAuB,EACvB,MAA0B,EAC1B,QAAiB,EACjB,UAAU,KAAK;QAEtB,KAAK,CAAC,OAAO,CAAC,CAAA;QANP,WAAM,GAAN,MAAM,CAAQ;QACd,aAAQ,GAAR,QAAQ,CAAe;QACvB,WAAM,GAAN,MAAM,CAAoB;QAC1B,aAAQ,GAAR,QAAQ,CAAS;QACjB,YAAO,GAAP,OAAO,CAAQ;QAGtB,IAAI,CAAC,IAAI,GAAG,WAAW,CAAA;IACzB,CAAC;CACF"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@molecule/app-http",
3
- "version": "1.2.0",
3
+ "version": "1.3.0",
4
4
  "description": "Client HTTP interface for molecule.dev",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",