@fuzdev/fuz_app 0.183.0 → 0.185.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/dist/actions/CLAUDE.md +538 -1223
- package/dist/actions/action_codegen.d.ts +1 -1
- package/dist/actions/action_codegen.d.ts.map +1 -1
- package/dist/actions/action_codegen.js +3 -2
- package/dist/actions/connection_closer.d.ts +11 -9
- package/dist/actions/connection_closer.d.ts.map +1 -1
- package/dist/actions/connection_closer.js +11 -9
- package/dist/actions/frontend_rpc_client.d.ts +1 -1
- package/dist/actions/register_action_ws.d.ts +21 -1
- package/dist/actions/register_action_ws.d.ts.map +1 -1
- package/dist/actions/register_action_ws.js +2 -1
- package/dist/actions/ws_socket_session.d.ts +25 -4
- package/dist/actions/ws_socket_session.d.ts.map +1 -1
- package/dist/actions/ws_socket_session.js +81 -25
- package/dist/auth/CLAUDE.md +433 -1048
- package/dist/auth/account_queries.d.ts +1 -1
- package/dist/auth/account_queries.js +1 -1
- package/dist/auth/account_routes.d.ts +4 -5
- package/dist/auth/account_routes.d.ts.map +1 -1
- package/dist/auth/account_routes.js +8 -10
- package/dist/auth/admin_actions.d.ts.map +1 -1
- package/dist/auth/admin_actions.js +10 -11
- package/dist/auth/api_token.d.ts +20 -3
- package/dist/auth/api_token.d.ts.map +1 -1
- package/dist/auth/api_token.js +28 -9
- package/dist/auth/api_token_queries.d.ts +2 -2
- package/dist/auth/api_token_queries.js +2 -2
- package/dist/auth/audit_log_routes.d.ts +1 -1
- package/dist/auth/audit_log_routes.d.ts.map +1 -1
- package/dist/auth/audit_log_routes.js +3 -2
- package/dist/auth/audit_log_schema.d.ts +15 -9
- package/dist/auth/audit_log_schema.d.ts.map +1 -1
- package/dist/auth/audit_log_schema.js +1 -2
- package/dist/auth/auth_guard_resolver.d.ts +1 -1
- package/dist/auth/auth_guard_resolver.js +1 -1
- package/dist/auth/bearer_auth.d.ts +2 -5
- package/dist/auth/bearer_auth.d.ts.map +1 -1
- package/dist/auth/bearer_auth.js +4 -13
- package/dist/auth/bootstrap_account.d.ts +13 -15
- package/dist/auth/bootstrap_account.d.ts.map +1 -1
- package/dist/auth/bootstrap_account.js +9 -11
- package/dist/auth/bootstrap_routes.d.ts +20 -21
- package/dist/auth/bootstrap_routes.d.ts.map +1 -1
- package/dist/auth/bootstrap_routes.js +21 -19
- package/dist/auth/bootstrap_token_store.d.ts +3 -4
- package/dist/auth/bootstrap_token_store.d.ts.map +1 -1
- package/dist/auth/bootstrap_token_store.js +1 -1
- package/dist/auth/cleanup.d.ts +34 -3
- package/dist/auth/cleanup.d.ts.map +1 -1
- package/dist/auth/cleanup.js +11 -3
- package/dist/auth/daemon_token.d.ts +5 -1
- package/dist/auth/daemon_token.d.ts.map +1 -1
- package/dist/auth/daemon_token_middleware.d.ts +12 -8
- package/dist/auth/daemon_token_middleware.d.ts.map +1 -1
- package/dist/auth/daemon_token_middleware.js +15 -21
- package/dist/auth/deps.d.ts +11 -0
- package/dist/auth/deps.d.ts.map +1 -1
- package/dist/auth/invite_queries.d.ts +51 -3
- package/dist/auth/invite_queries.d.ts.map +1 -1
- package/dist/auth/invite_queries.js +81 -6
- package/dist/auth/invite_schema.d.ts +2 -1
- package/dist/auth/invite_schema.d.ts.map +1 -1
- package/dist/auth/middleware.d.ts +2 -3
- package/dist/auth/middleware.d.ts.map +1 -1
- package/dist/auth/middleware.js +3 -3
- package/dist/auth/request_context.d.ts +3 -3
- package/dist/auth/request_context.js +3 -3
- package/dist/auth/role_grant_offer_actions.d.ts +2 -2
- package/dist/auth/role_grant_offer_actions.js +2 -2
- package/dist/auth/session_cookie.d.ts +82 -174
- package/dist/auth/session_cookie.d.ts.map +1 -1
- package/dist/auth/session_cookie.js +80 -130
- package/dist/auth/session_middleware.d.ts +8 -17
- package/dist/auth/session_middleware.d.ts.map +1 -1
- package/dist/auth/session_middleware.js +14 -23
- package/dist/auth/session_queries.d.ts +9 -14
- package/dist/auth/session_queries.d.ts.map +1 -1
- package/dist/auth/session_queries.js +8 -9
- package/dist/auth/signup_routes.d.ts.map +1 -1
- package/dist/auth/signup_routes.js +4 -6
- package/dist/db/CLAUDE.md +5 -3
- package/dist/dev/setup.d.ts +3 -1
- package/dist/dev/setup.d.ts.map +1 -1
- package/dist/dev/setup.js +3 -1
- package/dist/http/CLAUDE.md +315 -768
- package/dist/http/db_routes.d.ts +1 -1
- package/dist/http/db_routes.js +1 -1
- package/dist/http/origin.d.ts +7 -8
- package/dist/http/origin.d.ts.map +1 -1
- package/dist/http/origin.js +7 -8
- package/dist/http/pending_effects.d.ts +82 -4
- package/dist/http/pending_effects.d.ts.map +1 -1
- package/dist/http/pending_effects.js +82 -4
- package/dist/http/route_result.d.ts +1 -1
- package/dist/http/route_spec.d.ts +17 -14
- package/dist/http/route_spec.d.ts.map +1 -1
- package/dist/realtime/audit_log_sse.d.ts +1 -1
- package/dist/realtime/sse.d.ts +6 -25
- package/dist/realtime/sse.d.ts.map +1 -1
- package/dist/realtime/sse.js +4 -25
- package/dist/realtime/sse_constants.d.ts +1 -1
- package/dist/realtime/sse_constants.js +1 -1
- package/dist/server/app_backend.d.ts +4 -5
- package/dist/server/app_backend.d.ts.map +1 -1
- package/dist/server/app_backend.js +3 -1
- package/dist/server/app_server.d.ts +87 -76
- package/dist/server/app_server.d.ts.map +1 -1
- package/dist/server/app_server.js +111 -91
- package/dist/server/app_server_context.d.ts +1 -2
- package/dist/server/app_server_context.d.ts.map +1 -1
- package/dist/server/env.js +2 -2
- package/dist/server/shutdown_drain.d.ts +69 -0
- package/dist/server/shutdown_drain.d.ts.map +1 -0
- package/dist/server/shutdown_drain.js +77 -0
- package/dist/testing/CLAUDE.md +89 -57
- package/dist/testing/admin_integration.d.ts +4 -5
- package/dist/testing/admin_integration.d.ts.map +1 -1
- package/dist/testing/admin_integration.js +39 -23
- package/dist/testing/app_server.d.ts +3 -8
- package/dist/testing/app_server.d.ts.map +1 -1
- package/dist/testing/app_server.js +10 -9
- package/dist/testing/attack_surface.d.ts +1 -1
- package/dist/testing/attack_surface.d.ts.map +1 -1
- package/dist/testing/audit_completeness.d.ts +2 -3
- package/dist/testing/audit_completeness.d.ts.map +1 -1
- package/dist/testing/audit_completeness.js +1 -1
- package/dist/testing/cross_backend/bootstrap_backend.d.ts +3 -1
- package/dist/testing/cross_backend/bootstrap_backend.d.ts.map +1 -1
- package/dist/testing/cross_backend/bootstrap_backend.js +5 -1
- package/dist/testing/cross_backend/capability_mounts.d.ts.map +1 -1
- package/dist/testing/cross_backend/capability_mounts.js +16 -11
- package/dist/testing/cross_backend/conformance_table.d.ts +5 -6
- package/dist/testing/cross_backend/conformance_table.d.ts.map +1 -1
- package/dist/testing/cross_backend/conformance_table.js +4 -4
- package/dist/testing/cross_backend/cookie_attributes.js +1 -1
- package/dist/testing/cross_backend/create_dual_spawn_global_setup.d.ts +10 -1
- package/dist/testing/cross_backend/create_dual_spawn_global_setup.d.ts.map +1 -1
- package/dist/testing/cross_backend/create_dual_spawn_global_setup.js +33 -7
- package/dist/testing/cross_backend/default_backend_configs.d.ts +3 -3
- package/dist/testing/cross_backend/default_spine_surface.d.ts +0 -6
- package/dist/testing/cross_backend/default_spine_surface.d.ts.map +1 -1
- package/dist/testing/cross_backend/default_spine_surface.js +4 -9
- package/dist/testing/cross_backend/differential.d.ts +2 -3
- package/dist/testing/cross_backend/differential.d.ts.map +1 -1
- package/dist/testing/cross_backend/differential.js +1 -1
- package/dist/testing/cross_backend/full_spine_mount.d.ts +1 -42
- package/dist/testing/cross_backend/full_spine_mount.d.ts.map +1 -1
- package/dist/testing/cross_backend/full_spine_mount.js +45 -4
- package/dist/testing/cross_backend/in_process_setup.d.ts +7 -8
- package/dist/testing/cross_backend/in_process_setup.d.ts.map +1 -1
- package/dist/testing/cross_backend/in_process_setup.js +10 -13
- package/dist/testing/cross_backend/rpc_success_fixtures.d.ts.map +1 -1
- package/dist/testing/cross_backend/rpc_success_fixtures.js +2 -1
- package/dist/testing/cross_backend/rust_spine_consumer_surface.d.ts +3 -4
- package/dist/testing/cross_backend/rust_spine_consumer_surface.d.ts.map +1 -1
- package/dist/testing/cross_backend/rust_spine_consumer_surface.js +2 -2
- package/dist/testing/cross_backend/setup.d.ts +1 -1
- package/dist/testing/cross_backend/spawn_backend.d.ts +14 -0
- package/dist/testing/cross_backend/spawn_backend.d.ts.map +1 -1
- package/dist/testing/cross_backend/spawn_backend.js +56 -8
- package/dist/testing/cross_backend/spine_suites.d.ts +18 -16
- package/dist/testing/cross_backend/spine_suites.d.ts.map +1 -1
- package/dist/testing/cross_backend/spine_suites.js +38 -18
- package/dist/testing/cross_backend/standard.d.ts +19 -84
- package/dist/testing/cross_backend/standard.d.ts.map +1 -1
- package/dist/testing/cross_backend/standard.js +8 -23
- package/dist/testing/cross_backend/standard_auth.d.ts +74 -0
- package/dist/testing/cross_backend/standard_auth.d.ts.map +1 -0
- package/dist/testing/cross_backend/standard_auth.js +28 -0
- package/dist/testing/cross_backend/standard_bundle.d.ts +48 -0
- package/dist/testing/cross_backend/standard_bundle.d.ts.map +1 -0
- package/dist/testing/cross_backend/standard_bundle.js +43 -0
- package/dist/testing/cross_backend/testing_credential_read.d.ts +10 -11
- package/dist/testing/cross_backend/testing_credential_read.d.ts.map +1 -1
- package/dist/testing/cross_backend/testing_credential_read.js +12 -12
- package/dist/testing/cross_backend/testing_reset_actions.d.ts +46 -30
- package/dist/testing/cross_backend/testing_reset_actions.d.ts.map +1 -1
- package/dist/testing/cross_backend/testing_reset_actions.js +52 -31
- package/dist/testing/cross_backend/testing_server_bun.d.ts.map +1 -1
- package/dist/testing/cross_backend/testing_server_bun.js +5 -4
- package/dist/testing/cross_backend/testing_server_core.d.ts +16 -3
- package/dist/testing/cross_backend/testing_server_core.d.ts.map +1 -1
- package/dist/testing/cross_backend/testing_server_core.js +22 -7
- package/dist/testing/cross_backend/ts_spine_backend_config.d.ts +6 -2
- package/dist/testing/cross_backend/ts_spine_backend_config.d.ts.map +1 -1
- package/dist/testing/cross_backend/ts_spine_backend_config.js +7 -3
- package/dist/testing/daemon_token_rotation.d.ts.map +1 -1
- package/dist/testing/daemon_token_rotation.js +2 -3
- package/dist/testing/error_coverage.d.ts +5 -0
- package/dist/testing/error_coverage.d.ts.map +1 -1
- package/dist/testing/error_coverage.js +2 -1
- package/dist/testing/integration.d.ts +6 -23
- package/dist/testing/integration.d.ts.map +1 -1
- package/dist/testing/integration.js +53 -83
- package/dist/testing/integration_helpers.d.ts +16 -0
- package/dist/testing/integration_helpers.d.ts.map +1 -1
- package/dist/testing/integration_helpers.js +29 -1
- package/dist/testing/middleware_gate_probes.d.ts +55 -1
- package/dist/testing/middleware_gate_probes.d.ts.map +1 -1
- package/dist/testing/middleware_gate_probes.js +69 -3
- package/dist/testing/rate_limiting.d.ts +2 -3
- package/dist/testing/rate_limiting.d.ts.map +1 -1
- package/dist/testing/rate_limiting.js +3 -3
- package/dist/testing/rpc_helpers.d.ts +1 -2
- package/dist/testing/rpc_helpers.d.ts.map +1 -1
- package/dist/testing/rpc_helpers.js +3 -3
- package/dist/testing/rpc_round_trip.d.ts +2 -3
- package/dist/testing/rpc_round_trip.d.ts.map +1 -1
- package/dist/testing/rpc_round_trip.js +1 -1
- package/dist/testing/sse_round_trip.d.ts +2 -3
- package/dist/testing/sse_round_trip.d.ts.map +1 -1
- package/dist/testing/sse_round_trip.js +2 -2
- package/dist/testing/stubs.d.ts +5 -6
- package/dist/testing/stubs.d.ts.map +1 -1
- package/dist/testing/stubs.js +10 -8
- package/dist/testing/test_app.d.ts +8 -5
- package/dist/testing/test_app.d.ts.map +1 -1
- package/dist/testing/test_app.js +7 -7
- package/dist/testing/ws_round_trip.d.ts.map +1 -1
- package/dist/testing/ws_round_trip.js +3 -0
- package/dist/ui/ui_format.d.ts.map +1 -1
- package/dist/ui/ui_format.js +1 -2
- package/package.json +1 -1
|
@@ -18,6 +18,7 @@ import { run_migrations } from '../db/migrate.js';
|
|
|
18
18
|
import { AUTH_MIGRATION_NS } from '../auth/migrations.js';
|
|
19
19
|
import { create_db, is_pg_database_url } from '../db/create_db.js';
|
|
20
20
|
import { DEFAULT_DB_AUDIT_CHECKOUT_TIMEOUT_MS } from '../db/db_pg.js';
|
|
21
|
+
import { create_request_tracker } from '../http/pending_effects.js';
|
|
21
22
|
/**
|
|
22
23
|
* Trivial `AuditFactory` for consumers that don't compose `on_audit_event`
|
|
23
24
|
* or `audit_log_config`. Equivalent to
|
|
@@ -82,7 +83,8 @@ export const create_app_backend = async (options) => {
|
|
|
82
83
|
log,
|
|
83
84
|
audit,
|
|
84
85
|
connection_closer: options.connection_closer ?? create_realtime_closer(),
|
|
85
|
-
notification_sender: create_realtime_notification_sender()
|
|
86
|
+
notification_sender: create_realtime_notification_sender(),
|
|
87
|
+
request_tracker: create_request_tracker()
|
|
86
88
|
}
|
|
87
89
|
};
|
|
88
90
|
}
|
|
@@ -10,8 +10,6 @@
|
|
|
10
10
|
import { Hono, type Context } from 'hono';
|
|
11
11
|
import type { UpgradeWebSocket } from 'hono/ws';
|
|
12
12
|
import type { AnySchema } from '@fuzdev/fuz_schema/schema.ts';
|
|
13
|
-
import type { Logger } from '@fuzdev/fuz_util/log.ts';
|
|
14
|
-
import { type SessionOptions } from '../auth/session_cookie.js';
|
|
15
13
|
import type { BootstrapTokenStore } from '../auth/bootstrap_token_store.js';
|
|
16
14
|
import { type EventSpec } from '../realtime/sse.js';
|
|
17
15
|
import { type AuditLogSse } from '../realtime/audit_log_sse.js';
|
|
@@ -25,12 +23,12 @@ import { type ServeStaticFactory } from './static.js';
|
|
|
25
23
|
import { type AppSurfaceSpec, type AppSurfaceDiagnostic, type RpcEndpointSpec } from '../http/surface.js';
|
|
26
24
|
import { type RouteSpec } from '../http/route_spec.js';
|
|
27
25
|
import type { MiddlewareCarveOut, MiddlewareSpec } from '../http/middleware_spec.js';
|
|
28
|
-
import { type BootstrapStatus
|
|
26
|
+
import { type BootstrapStatus } from '../auth/bootstrap_routes.js';
|
|
29
27
|
import { type EffectErrorContext } from '../http/pending_effects.js';
|
|
30
28
|
import { type WsEndpointSpec } from '../actions/ws_endpoint_spec.js';
|
|
31
29
|
import type { ConnectionRegistry } from '../actions/connection_registry.js';
|
|
32
|
-
import { type
|
|
33
|
-
import type
|
|
30
|
+
import { type AuthCleanupSchedule } from '../auth/cleanup.js';
|
|
31
|
+
import { type ShutdownDrainGivenUp } from './shutdown_drain.js';
|
|
34
32
|
/**
|
|
35
33
|
* Bootstrap configuration for `AppServerOptions.bootstrap`.
|
|
36
34
|
*
|
|
@@ -46,7 +44,7 @@ import type { AuditEmitter } from '../auth/audit_emitter.js';
|
|
|
46
44
|
* Equivalent to omitting `bootstrap` entirely; the explicit mode is
|
|
47
45
|
* for documentation and reviewable intent at the wiring layer.
|
|
48
46
|
* - `surface_only` — route present, permanent 403 via
|
|
49
|
-
* `
|
|
47
|
+
* `is_bootstrap_available`. For tests asserting on the
|
|
50
48
|
* disabled-but-present wire shape.
|
|
51
49
|
* - `live` — route mounted, real token verification. Success path
|
|
52
50
|
* reachable. `token_store` is required.
|
|
@@ -70,8 +68,6 @@ export interface BootstrapLiveOptions {
|
|
|
70
68
|
token_store: BootstrapTokenStore;
|
|
71
69
|
/** Route prefix for bootstrap routes. Default `'/api/account'`; must sit under `/api/`. */
|
|
72
70
|
route_prefix?: string;
|
|
73
|
-
/** Called after a successful bootstrap commits (see `OnBootstrap`). */
|
|
74
|
-
on_bootstrap?: OnBootstrap;
|
|
75
71
|
}
|
|
76
72
|
/**
|
|
77
73
|
* Configuration for `create_app_server()`.
|
|
@@ -83,12 +79,11 @@ export interface AppServerOptions {
|
|
|
83
79
|
/** Pre-initialized backend from `create_app_backend()`. */
|
|
84
80
|
backend: AppBackend;
|
|
85
81
|
/**
|
|
86
|
-
*
|
|
87
|
-
*
|
|
88
|
-
*
|
|
89
|
-
* the `Set-Cookie` grammar cannot carry.
|
|
82
|
+
* The session cookie's name (`SESSION_COOKIE_NAME` is the spine default).
|
|
83
|
+
* Assembly throws on a name that is no RFC 6265 cookie-name, which the
|
|
84
|
+
* `Set-Cookie` grammar cannot carry.
|
|
90
85
|
*/
|
|
91
|
-
|
|
86
|
+
session_cookie_name: string;
|
|
92
87
|
/**
|
|
93
88
|
* Parsed allowed origin patterns, as `parse_allowed_origins` returns them
|
|
94
89
|
* (`validate_server_env`'s `allowed_origins`); assembly throws on a matcher
|
|
@@ -224,7 +219,14 @@ export interface AppServerOptions {
|
|
|
224
219
|
* error map declares its `413` and `400`; with `null` it is absent.
|
|
225
220
|
*/
|
|
226
221
|
max_body_size?: number | null;
|
|
227
|
-
/**
|
|
222
|
+
/**
|
|
223
|
+
* Daemon token state for keeper auth. Omit to disable. A null
|
|
224
|
+
* `keeper_account_id` is resolved from the database at assembly (an
|
|
225
|
+
* already-bootstrapped server), and a live bootstrap sets it once its
|
|
226
|
+
* account commits; the daemon leg never re-reads it per request, so a
|
|
227
|
+
* keeper seeded by another process (`seed_dev_account`) needs a restart,
|
|
228
|
+
* as on the Rust spine.
|
|
229
|
+
*/
|
|
228
230
|
daemon_token_state?: DaemonTokenState;
|
|
229
231
|
/** Bootstrap options. Omit to skip bootstrap status check and routes. */
|
|
230
232
|
bootstrap?: BootstrapServerOptions;
|
|
@@ -288,27 +290,34 @@ export interface AppServerOptions {
|
|
|
288
290
|
keep_alive_ms?: number | null;
|
|
289
291
|
};
|
|
290
292
|
/**
|
|
291
|
-
*
|
|
292
|
-
*
|
|
293
|
-
*
|
|
294
|
-
*
|
|
295
|
-
*
|
|
296
|
-
*
|
|
293
|
+
* Whether the auth cleanup runs beside the server — required, with no
|
|
294
|
+
* default, so a server neither gets nor loses the sweeps without writing
|
|
295
|
+
* it out. `{every_ms}` runs `start_auth_cleanup` over `backend.deps` — a
|
|
296
|
+
* pass as assembly finishes, then one per `every_ms` — stopped by
|
|
297
|
+
* `AppServer.close` within its drain bound. Each pass deletes expired
|
|
298
|
+
* sessions and closes the connections they opened through
|
|
299
|
+
* `deps.connection_closer` (every WebSocket connection registry and audit
|
|
300
|
+
* stream this server mounts), and audits each newly expired role_grant
|
|
301
|
+
* offer once.
|
|
297
302
|
*
|
|
298
|
-
* **
|
|
299
|
-
*
|
|
300
|
-
*
|
|
303
|
+
* **A production server passes
|
|
304
|
+
* `{every_ms: DEFAULT_AUTH_CLEANUP_INTERVAL_MS}`.** With `'off'` nothing
|
|
305
|
+
* sweeps: expired session rows accumulate and an offer's expiry is never
|
|
306
|
+
* audited. Connections do not depend on it — each closes at its
|
|
301
307
|
* credential's deadline (`auth/credential_deadline.ts`), and the sweep's
|
|
302
|
-
* close repeats that one.
|
|
303
|
-
*
|
|
308
|
+
* close repeats that one. Twin of the Rust spine's
|
|
309
|
+
* `AuthCleanupSchedule::Every`, which a server's backend options carry and
|
|
310
|
+
* its backend attaches as a `fuz_auth::AuthCleanup`.
|
|
304
311
|
*
|
|
305
|
-
*
|
|
306
|
-
*
|
|
307
|
-
* Leave it off in an in-process test harness — a background pass deletes
|
|
308
|
-
* rows and writes audit rows mid-test — and in a process that runs
|
|
312
|
+
* `'off'` in an in-process test harness — a background pass deletes rows
|
|
313
|
+
* and writes audit rows mid-test — and in a process that runs
|
|
309
314
|
* `run_auth_cleanup` on a schedule of its own.
|
|
315
|
+
*
|
|
316
|
+
* Checked with the other options, before assembly acquires anything:
|
|
317
|
+
* `every_ms` must be a positive finite number of ms no greater than
|
|
318
|
+
* `PERIODIC_INTERVAL_MS_MAX`.
|
|
310
319
|
*/
|
|
311
|
-
auth_cleanup
|
|
320
|
+
auth_cleanup: AuthCleanupSchedule;
|
|
312
321
|
/** SSE event specs for surface generation. Defaults to `[]` (no SSE events). */
|
|
313
322
|
event_specs?: Array<EventSpec>;
|
|
314
323
|
/**
|
|
@@ -426,12 +435,13 @@ export interface AppServerOptions {
|
|
|
426
435
|
*/
|
|
427
436
|
await_pending_effects?: boolean;
|
|
428
437
|
/**
|
|
429
|
-
* How long `AppServer.close` waits for the
|
|
430
|
-
*
|
|
431
|
-
*
|
|
432
|
-
*
|
|
433
|
-
*
|
|
434
|
-
*
|
|
438
|
+
* How long `AppServer.close` waits for the work still in flight — an auth
|
|
439
|
+
* cleanup pass in progress, each HTTP request and WS message accepted,
|
|
440
|
+
* until its handler has returned and its effect queues (failure audit
|
|
441
|
+
* rows, API token usage, post-commit thunks) have flushed, and every pool
|
|
442
|
+
* write of `deps.audit` — before it closes the database. What is still
|
|
443
|
+
* running then is given up on and logged. Default
|
|
444
|
+
* `DEFAULT_SHUTDOWN_DRAIN_TIMEOUT_MS`; must be a positive number of ms.
|
|
435
445
|
*/
|
|
436
446
|
shutdown_drain_timeout_ms?: number;
|
|
437
447
|
/**
|
|
@@ -473,9 +483,8 @@ export interface AppServer {
|
|
|
473
483
|
/**
|
|
474
484
|
* Shut the server's resources down, in order:
|
|
475
485
|
*
|
|
476
|
-
* 1. stop the auth cleanup schedule when
|
|
477
|
-
*
|
|
478
|
-
* own, so a shutdown with a deadline races it
|
|
486
|
+
* 1. stop the auth cleanup schedule when `auth_cleanup` started one: no
|
|
487
|
+
* pass starts from here, and a pass in progress is waited for in step 3
|
|
479
488
|
* 2. close every live connection on `deps.connection_closer`
|
|
480
489
|
* (`close_all_connections`) — each WebSocket with `WS_CLOSE_GOING_AWAY`, each
|
|
481
490
|
* audit stream — including registries supplied through
|
|
@@ -485,11 +494,28 @@ export interface AppServer {
|
|
|
485
494
|
* is left closing, so an upgrade or stream that registers afterward is
|
|
486
495
|
* born closed — refused at once rather than outliving the server — and
|
|
487
496
|
* a closed registry hosts no other server
|
|
488
|
-
* 3. wait for the
|
|
489
|
-
*
|
|
490
|
-
*
|
|
491
|
-
* for
|
|
492
|
-
* `
|
|
497
|
+
* 3. wait for the auth cleanup pass in progress, if any — JS cannot abort
|
|
498
|
+
* one, so at the bound it is given up on and left to finish against the
|
|
499
|
+
* closing database, where the Rust shutdown aborts its upkeep task —
|
|
500
|
+
* and for the work still in flight on `deps.request_tracker` and
|
|
501
|
+
* `deps.audit`: every HTTP request and WS message accepted, until its
|
|
502
|
+
* handler has returned and its effect queues have flushed (failure
|
|
503
|
+
* audit rows, API token usage, post-commit thunks; production holds no
|
|
504
|
+
* HTTP response for them, and a WS reply is sent before its flush),
|
|
505
|
+
* every WebSocket still opening — its admission re-read, which step 2's
|
|
506
|
+
* close turns into a going-away refusal, and `on_socket_open` — and
|
|
507
|
+
* every pool write of the emitter — a handler still running when the
|
|
508
|
+
* close starts is waited for, then its flush. A WS handler's socket is
|
|
509
|
+
* closed in step 2, which aborts its `signal`; one that runs on is still
|
|
510
|
+
* waited for. One bound for all of it, `shutdown_drain_timeout_ms`,
|
|
511
|
+
* logging what it gives up on. From here a request that arrives is refused — HTTP with
|
|
512
|
+
* 503 `service_unavailable`, and a WS message, on a socket step 2
|
|
513
|
+
* didn't end (a hand mount), with the `service_unavailable` JSON-RPC
|
|
514
|
+
* error — never run against the closing database. The Rust
|
|
515
|
+
* spine waits the same way for an HTTP request already dispatched, but
|
|
516
|
+
* drops a WS message's dispatch still in its handler with its socket
|
|
517
|
+
* loop, which rolls back; one whose commit has started finishes, its
|
|
518
|
+
* post-commit effects included
|
|
493
519
|
* 4. release what assembly acquired, last acquired first: remove the
|
|
494
520
|
* audit listeners `create_app_server` registered on `deps.audit` (the
|
|
495
521
|
* revocation guard, the audit-log SSE listener), the members it added
|
|
@@ -504,14 +530,23 @@ export interface AppServer {
|
|
|
504
530
|
* host another server
|
|
505
531
|
* 5. close the database connection (`AppBackend.close`)
|
|
506
532
|
*
|
|
507
|
-
*
|
|
508
|
-
*
|
|
533
|
+
* Resolves what step 3 gave up on at its bound, every count `0` when it
|
|
534
|
+
* drained everything; `shutdown_gave_up` reads it. A process that serves
|
|
535
|
+
* the app reports a give-up as a failed exit, as the Rust spine's
|
|
536
|
+
* `StartupError::ShutdownGivenUp` does.
|
|
537
|
+
*
|
|
538
|
+
* Idempotent: a second call settles with the first one's outcome — the
|
|
539
|
+
* same report, or the same rejection (a failed close is not retried) — and
|
|
540
|
+
* concurrent calls share one shutdown. Never await it from a handler: its
|
|
541
|
+
* own request is held, so the drain waits on it until
|
|
542
|
+
* `shutdown_drain_timeout_ms`.
|
|
509
543
|
*
|
|
510
544
|
* Stop accepting new HTTP connections first — without awaiting the
|
|
511
545
|
* listener's full drain, since live WebSockets hold it open until `close`
|
|
512
|
-
* ends them — so no new request reaches a closed database.
|
|
546
|
+
* ends them — so no new request reaches a closed database. A request the
|
|
547
|
+
* app already accepted is waited for in step 3.
|
|
513
548
|
*/
|
|
514
|
-
close: () => Promise<
|
|
549
|
+
close: () => Promise<ShutdownDrainGivenUp>;
|
|
515
550
|
}
|
|
516
551
|
/**
|
|
517
552
|
* Assert that `audit_sse` was wired by `create_app_server` and return it
|
|
@@ -538,12 +573,6 @@ export declare const require_audit_sse: (source: {
|
|
|
538
573
|
* `fuz_http` `DEFAULT_BODY_LIMIT_BYTES`.
|
|
539
574
|
*/
|
|
540
575
|
export declare const DEFAULT_BODY_LIMIT_BYTES: number;
|
|
541
|
-
/**
|
|
542
|
-
* Default bound on `AppServer.close`'s wait for the effects still in flight
|
|
543
|
-
* (`AppServerOptions.shutdown_drain_timeout_ms`). Twin of the Rust spine's
|
|
544
|
-
* `DEFAULT_DRAIN_TIMEOUT`.
|
|
545
|
-
*/
|
|
546
|
-
export declare const DEFAULT_SHUTDOWN_DRAIN_TIMEOUT_MS = 10000;
|
|
547
576
|
/**
|
|
548
577
|
* Each `AppServerOptions` rate-limiter field, with the defaults an omitted one
|
|
549
578
|
* is built from under `rate_limiters: 'enforced'` and the name its
|
|
@@ -684,37 +713,19 @@ export declare const collect_config_diagnostics: (input: ConfigDiagnosticsInput)
|
|
|
684
713
|
* so far runs, last acquired first (one that throws is logged and the rest
|
|
685
714
|
* still run), and the original error is rethrown: a failed assembly leaves
|
|
686
715
|
* the backend's emitter, closer and notification sender as it found them and
|
|
687
|
-
* no limiter timer running. When `auth_cleanup` is
|
|
716
|
+
* no limiter timer running. When `auth_cleanup` is `{every_ms}`, the
|
|
688
717
|
* auth cleanup schedule starts as the last step of assembly — nothing after
|
|
689
718
|
* it can throw, so an assembly that throws leaves no schedule running.
|
|
690
719
|
*
|
|
691
720
|
* The returned `close` owns shutdown: it stops that schedule, closes every
|
|
692
|
-
* live connection on the backend's closer,
|
|
693
|
-
* closes the database
|
|
721
|
+
* live connection on the backend's closer, waits for the work in flight
|
|
722
|
+
* within its bound, runs the same releases, closes the database, and
|
|
723
|
+
* resolves what the wait gave up on (`AppServer.close`).
|
|
694
724
|
*
|
|
695
725
|
* @returns the assembled Hono app with its surface, bootstrap status, migration results,
|
|
696
726
|
* audit SSE, mounted WS registries, and `close`
|
|
697
727
|
* @throws Error from any assembly step, after releasing what assembly acquired
|
|
698
728
|
*/
|
|
699
729
|
export declare const create_app_server: (options: AppServerOptions) => Promise<AppServer>;
|
|
700
|
-
/**
|
|
701
|
-
* What `drain_effects_on_shutdown` gave up on at its bound, each counted on
|
|
702
|
-
* its own: a request flush still waiting on its audit writes has those
|
|
703
|
-
* writes counted in `audit_writes` too, so the two are not summed.
|
|
704
|
-
*/
|
|
705
|
-
export interface ShutdownDrainGivenUp {
|
|
706
|
-
/** Request flushes still running. */
|
|
707
|
-
request_flushes: number;
|
|
708
|
-
/** Pool writes of the audit emitter still in flight. */
|
|
709
|
-
audit_writes: number;
|
|
710
|
-
}
|
|
711
|
-
/**
|
|
712
|
-
* Wait for the request flushes in flight and then the audit emitter's pool
|
|
713
|
-
* writes, until none is left or `timeout_ms` passes — then log an error naming
|
|
714
|
-
* what was given up on. Never rejects.
|
|
715
|
-
*
|
|
716
|
-
* @returns what was given up on, both counts `0` when everything settled
|
|
717
|
-
*/
|
|
718
|
-
export declare const drain_effects_on_shutdown: (inflight_flushes: ReadonlySet<Promise<void>>, audit: Pick<AuditEmitter, "drain_inflight" | "inflight_count">, timeout_ms: number, log: Logger) => Promise<ShutdownDrainGivenUp>;
|
|
719
730
|
export {};
|
|
720
731
|
//# sourceMappingURL=app_server.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"app_server.d.ts","sourceRoot":"","sources":["../../src/lib/server/app_server.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,IAAI,EAAE,KAAK,OAAO,EAAE,MAAM,MAAM,CAAC;AAE1C,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAChD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;
|
|
1
|
+
{"version":3,"file":"app_server.d.ts","sourceRoot":"","sources":["../../src/lib/server/app_server.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,IAAI,EAAE,KAAK,OAAO,EAAE,MAAM,MAAM,CAAC;AAE1C,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAChD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AAI9D,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,kCAAkC,CAAC;AAC5E,OAAO,EAAqB,KAAK,SAAS,EAAE,MAAM,oBAAoB,CAAC;AACvE,OAAO,EAIN,KAAK,WAAW,EAChB,MAAM,8BAA8B,CAAC;AAEtC,OAAO,EACN,WAAW,EAMX,KAAK,eAAe,EACpB,KAAK,kBAAkB,EACvB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAEhE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACxD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAGhE,OAAO,oBAAoB,CAAC;AAE5B,OAAO,EAA4B,KAAK,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAKhF,OAAO,EAEN,KAAK,cAAc,EACnB,KAAK,oBAAoB,EACzB,KAAK,eAAe,EACpB,MAAM,oBAAoB,CAAC;AAG5B,OAAO,EAIN,KAA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