@fuzdev/fuz_app 0.184.0 → 0.186.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 +18 -3
- package/dist/actions/perform_action.d.ts.map +1 -1
- package/dist/actions/perform_action.js +36 -5
- package/dist/actions/register_action_ws.d.ts +14 -7
- package/dist/actions/register_action_ws.d.ts.map +1 -1
- package/dist/actions/ws_socket_session.d.ts +17 -4
- package/dist/actions/ws_socket_session.d.ts.map +1 -1
- package/dist/actions/ws_socket_session.js +41 -7
- package/dist/auth/CLAUDE.md +18 -9
- package/dist/auth/account_queries.d.ts +53 -40
- package/dist/auth/account_queries.d.ts.map +1 -1
- package/dist/auth/account_queries.js +57 -50
- package/dist/auth/account_routes.d.ts.map +1 -1
- package/dist/auth/account_routes.js +59 -25
- package/dist/auth/admin_actions.d.ts.map +1 -1
- package/dist/auth/admin_actions.js +26 -9
- package/dist/auth/audit_emitter.js +2 -2
- package/dist/auth/audit_log_queries.d.ts +11 -3
- package/dist/auth/audit_log_queries.d.ts.map +1 -1
- package/dist/auth/audit_log_queries.js +4 -4
- 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.js +1 -1
- package/dist/auth/auth_ddl.d.ts.map +1 -1
- package/dist/auth/auth_ddl.js +4 -0
- package/dist/auth/cleanup.d.ts +34 -3
- package/dist/auth/cleanup.d.ts.map +1 -1
- package/dist/auth/cleanup.js +12 -4
- package/dist/auth/migrations.d.ts.map +1 -1
- package/dist/auth/migrations.js +35 -0
- package/dist/auth/role_grant_offer_queries.d.ts +13 -13
- package/dist/auth/role_grant_offer_queries.d.ts.map +1 -1
- package/dist/auth/role_grant_offer_queries.js +12 -13
- package/dist/auth/role_grant_queries.d.ts +16 -9
- package/dist/auth/role_grant_queries.d.ts.map +1 -1
- package/dist/auth/role_grant_queries.js +16 -9
- package/dist/auth/self_service_role_actions.d.ts.map +1 -1
- package/dist/auth/self_service_role_actions.js +15 -0
- package/dist/auth/session_queries.d.ts +24 -0
- package/dist/auth/session_queries.d.ts.map +1 -1
- package/dist/auth/session_queries.js +28 -0
- package/dist/db/CLAUDE.md +3 -3
- package/dist/db/cell_ddl.d.ts +8 -3
- package/dist/db/cell_ddl.d.ts.map +1 -1
- package/dist/db/cell_ddl.js +10 -5
- package/dist/http/CLAUDE.md +1 -1
- package/dist/http/body_limit.d.ts +4 -4
- package/dist/http/body_limit.js +4 -4
- package/dist/http/pending_effects.d.ts +8 -4
- package/dist/http/pending_effects.d.ts.map +1 -1
- package/dist/http/route_spec.d.ts +3 -3
- 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 +2 -2
- package/dist/realtime/sse.d.ts.map +1 -1
- package/dist/realtime/sse_constants.d.ts +1 -1
- package/dist/realtime/sse_constants.js +1 -1
- package/dist/server/app_server.d.ts +59 -71
- package/dist/server/app_server.d.ts.map +1 -1
- package/dist/server/app_server.js +52 -60
- 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 +197 -66
- package/dist/testing/admin_integration.d.ts +2 -2
- package/dist/testing/admin_integration.d.ts.map +1 -1
- package/dist/testing/admin_integration.js +36 -20
- package/dist/testing/app_server.d.ts +5 -7
- package/dist/testing/app_server.d.ts.map +1 -1
- package/dist/testing/app_server.js +5 -7
- package/dist/testing/auth_apps.d.ts +3 -1
- package/dist/testing/auth_apps.d.ts.map +1 -1
- package/dist/testing/auth_apps.js +22 -5
- package/dist/testing/cross_backend/backend_config.d.ts +8 -0
- package/dist/testing/cross_backend/backend_config.d.ts.map +1 -1
- package/dist/testing/cross_backend/backend_log.d.ts +71 -0
- package/dist/testing/cross_backend/backend_log.d.ts.map +1 -0
- package/dist/testing/cross_backend/backend_log.js +134 -0
- package/dist/testing/cross_backend/backend_swap.d.ts +41 -0
- package/dist/testing/cross_backend/backend_swap.d.ts.map +1 -0
- package/dist/testing/cross_backend/backend_swap.js +431 -0
- package/dist/testing/cross_backend/body_size_smuggling.js +3 -3
- 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 +9 -5
- package/dist/testing/cross_backend/conformance_case.d.ts +11 -6
- package/dist/testing/cross_backend/conformance_case.d.ts.map +1 -1
- package/dist/testing/cross_backend/conformance_case.js +4 -0
- package/dist/testing/cross_backend/conformance_principal.d.ts +2 -2
- package/dist/testing/cross_backend/conformance_principal.d.ts.map +1 -1
- package/dist/testing/cross_backend/conformance_principal.js +27 -10
- 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 +38 -5
- package/dist/testing/cross_backend/default_backend_configs.d.ts.map +1 -1
- package/dist/testing/cross_backend/default_backend_configs.js +50 -15
- package/dist/testing/cross_backend/in_process_setup.d.ts +1 -1
- package/dist/testing/cross_backend/in_process_setup.d.ts.map +1 -1
- package/dist/testing/cross_backend/in_process_setup.js +53 -31
- package/dist/testing/cross_backend/revocation_drivers.d.ts +14 -2
- package/dist/testing/cross_backend/revocation_drivers.d.ts.map +1 -1
- package/dist/testing/cross_backend/revocation_drivers.js +36 -8
- 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_stub_backend_config.d.ts +7 -0
- package/dist/testing/cross_backend/rust_spine_stub_backend_config.d.ts.map +1 -1
- package/dist/testing/cross_backend/rust_spine_stub_backend_config.js +4 -2
- package/dist/testing/cross_backend/setup.d.ts +44 -43
- package/dist/testing/cross_backend/setup.d.ts.map +1 -1
- package/dist/testing/cross_backend/setup.js +64 -62
- package/dist/testing/cross_backend/spawn_backend.d.ts +19 -1
- package/dist/testing/cross_backend/spawn_backend.d.ts.map +1 -1
- package/dist/testing/cross_backend/spawn_backend.js +138 -11
- package/dist/testing/cross_backend/spine_suites.d.ts +17 -14
- package/dist/testing/cross_backend/spine_suites.d.ts.map +1 -1
- package/dist/testing/cross_backend/spine_suites.js +37 -15
- package/dist/testing/cross_backend/sse_round_trip.d.ts.map +1 -1
- package/dist/testing/cross_backend/sse_round_trip.js +4 -2
- package/dist/testing/cross_backend/standard.d.ts +18 -82
- package/dist/testing/cross_backend/standard.d.ts.map +1 -1
- package/dist/testing/cross_backend/standard.js +6 -21
- 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_reset_actions.d.ts +18 -6
- package/dist/testing/cross_backend/testing_reset_actions.d.ts.map +1 -1
- package/dist/testing/cross_backend/testing_reset_actions.js +23 -8
- package/dist/testing/cross_backend/testing_server_bun.d.ts.map +1 -1
- package/dist/testing/cross_backend/testing_server_bun.js +7 -30
- 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 +20 -4
- 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/cross_backend/ws_round_trip.d.ts.map +1 -1
- package/dist/testing/cross_backend/ws_round_trip.js +4 -3
- package/dist/testing/data_exposure.d.ts +4 -1
- package/dist/testing/data_exposure.d.ts.map +1 -1
- package/dist/testing/data_exposure.js +93 -25
- package/dist/testing/db_invariants.d.ts +5 -5
- package/dist/testing/db_invariants.js +5 -5
- 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 +4 -20
- package/dist/testing/integration.d.ts.map +1 -1
- package/dist/testing/integration.js +49 -79
- 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/logged_errors.d.ts +61 -0
- package/dist/testing/logged_errors.d.ts.map +1 -0
- package/dist/testing/logged_errors.js +285 -0
- 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 +76 -3
- package/dist/testing/rpc_attack_surface.d.ts.map +1 -1
- package/dist/testing/rpc_attack_surface.js +41 -16
- package/dist/testing/stubs.d.ts +5 -1
- package/dist/testing/stubs.d.ts.map +1 -1
- package/dist/testing/stubs.js +6 -3
- package/dist/testing/test_app.d.ts +39 -9
- package/dist/testing/test_app.d.ts.map +1 -1
- package/dist/testing/test_app.js +70 -12
- package/dist/testing/transports/fetch_transport.d.ts +10 -0
- package/dist/testing/transports/fetch_transport.d.ts.map +1 -1
- package/dist/testing/transports/fetch_transport.js +13 -0
- package/package.json +4 -3
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The bounded wait `AppServer.close` makes for the work still in flight, and
|
|
3
|
+
* the report of what it gave up on.
|
|
4
|
+
*
|
|
5
|
+
* Its own module, free of any server framework, so a process that serves the
|
|
6
|
+
* app (`testing/cross_backend/testing_server_core.ts`) reads the report
|
|
7
|
+
* without loading the server. Twin of the Rust spine's shutdown drain
|
|
8
|
+
* (`fuz_http::serve_with_shutdown` and its `ServeShutdown`).
|
|
9
|
+
*
|
|
10
|
+
* @module
|
|
11
|
+
*/
|
|
12
|
+
import type { Logger } from '@fuzdev/fuz_util/log.ts';
|
|
13
|
+
import type { RequestTracker } from '../http/pending_effects.js';
|
|
14
|
+
import type { AuditEmitter } from '../auth/audit_emitter.js';
|
|
15
|
+
/**
|
|
16
|
+
* Default bound on `AppServer.close`'s wait for the effects still in flight
|
|
17
|
+
* (`AppServerOptions.shutdown_drain_timeout_ms`). Twin of the Rust spine's
|
|
18
|
+
* `DEFAULT_DRAIN_TIMEOUT`.
|
|
19
|
+
*/
|
|
20
|
+
export declare const DEFAULT_SHUTDOWN_DRAIN_TIMEOUT_MS = 10000;
|
|
21
|
+
/**
|
|
22
|
+
* What `AppServer.close` gave up on at its drain bound
|
|
23
|
+
* (`drain_effects_on_shutdown`), each counted on its own: a request still
|
|
24
|
+
* waiting on its audit writes has those writes counted in `audit_writes` too,
|
|
25
|
+
* so the counts are not summed. Every count `0` is a shutdown that drained
|
|
26
|
+
* everything. Twin of the Rust spine's `fuz_http::ServeShutdown`.
|
|
27
|
+
*/
|
|
28
|
+
export interface ShutdownDrainGivenUp {
|
|
29
|
+
/**
|
|
30
|
+
* Requests still held — HTTP requests and WS messages alike, each with its
|
|
31
|
+
* handler or its effect flush still running, and WS upgrades still opening.
|
|
32
|
+
*/
|
|
33
|
+
requests: number;
|
|
34
|
+
/** Pool writes of the audit emitter still in flight. */
|
|
35
|
+
audit_writes: number;
|
|
36
|
+
/**
|
|
37
|
+
* Upkeep tasks still running — the auth cleanup pass in progress when
|
|
38
|
+
* `auth_cleanup` scheduled one. Twin of `ServeShutdown`'s
|
|
39
|
+
* `upkeep_given_up`; here the pass is left to finish rather than aborted.
|
|
40
|
+
*/
|
|
41
|
+
upkeep: number;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Whether a shutdown gave up on anything — its drain bound ran out before
|
|
45
|
+
* every wait finished. A process reports it as a failed exit. Twin of the
|
|
46
|
+
* Rust `ServeShutdown::gave_up`.
|
|
47
|
+
*
|
|
48
|
+
* @param report - what `AppServer.close` resolved
|
|
49
|
+
*/
|
|
50
|
+
export declare const shutdown_gave_up: (report: ShutdownDrainGivenUp) => boolean;
|
|
51
|
+
/**
|
|
52
|
+
* Wait for the upkeep stops (the auth cleanup's pass in progress), then the
|
|
53
|
+
* requests held (HTTP requests, WS messages and WS upgrades still opening,
|
|
54
|
+
* one tracker — each until its handler has returned and its flush settled)
|
|
55
|
+
* and then the audit emitter's pool writes, until none is left or
|
|
56
|
+
* `timeout_ms` passes — then log an error naming what was given up on. One
|
|
57
|
+
* bound for all of it. Never rejects. The Rust shutdown joins its upkeep after
|
|
58
|
+
* the request drain; both wait concurrently against one deadline, so only the
|
|
59
|
+
* wait order differs.
|
|
60
|
+
*
|
|
61
|
+
* @param requests - the request tracker
|
|
62
|
+
* @param audit - the audit emitter
|
|
63
|
+
* @param upkeep - each upkeep task's stop, already requested; one still pending at the bound is counted
|
|
64
|
+
* @param timeout_ms - the bound
|
|
65
|
+
* @param log - where a give-up is logged
|
|
66
|
+
* @returns what was given up on, every count `0` when everything settled
|
|
67
|
+
*/
|
|
68
|
+
export declare const drain_effects_on_shutdown: (requests: Pick<RequestTracker, "drain_inflight" | "inflight_count">, audit: Pick<AuditEmitter, "drain_inflight" | "inflight_count">, upkeep: ReadonlyArray<Promise<void>>, timeout_ms: number, log: Logger) => Promise<ShutdownDrainGivenUp>;
|
|
69
|
+
//# sourceMappingURL=shutdown_drain.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shutdown_drain.d.ts","sourceRoot":"","sources":["../../src/lib/server/shutdown_drain.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AAEtD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AACjE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAE7D;;;;GAIG;AACH,eAAO,MAAM,iCAAiC,QAAS,CAAC;AAExD;;;;;;GAMG;AACH,MAAM,WAAW,oBAAoB;IACpC;;;OAGG;IACH,QAAQ,EAAE,MAAM,CAAC;IACjB,wDAAwD;IACxD,YAAY,EAAE,MAAM,CAAC;IACrB;;;;OAIG;IACH,MAAM,EAAE,MAAM,CAAC;CACf;AAED;;;;;;GAMG;AACH,eAAO,MAAM,gBAAgB,GAAI,QAAQ,oBAAoB,KAAG,OACI,CAAC;AAErE;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,yBAAyB,GACrC,UAAU,IAAI,CAAC,cAAc,EAAE,gBAAgB,GAAG,gBAAgB,CAAC,EACnE,OAAO,IAAI,CAAC,YAAY,EAAE,gBAAgB,GAAG,gBAAgB,CAAC,EAC9D,QAAQ,aAAa,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,EACpC,YAAY,MAAM,EAClB,KAAK,MAAM,KACT,OAAO,CAAC,oBAAoB,CAoC9B,CAAC"}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The bounded wait `AppServer.close` makes for the work still in flight, and
|
|
3
|
+
* the report of what it gave up on.
|
|
4
|
+
*
|
|
5
|
+
* Its own module, free of any server framework, so a process that serves the
|
|
6
|
+
* app (`testing/cross_backend/testing_server_core.ts`) reads the report
|
|
7
|
+
* without loading the server. Twin of the Rust spine's shutdown drain
|
|
8
|
+
* (`fuz_http::serve_with_shutdown` and its `ServeShutdown`).
|
|
9
|
+
*
|
|
10
|
+
* @module
|
|
11
|
+
*/
|
|
12
|
+
/**
|
|
13
|
+
* Default bound on `AppServer.close`'s wait for the effects still in flight
|
|
14
|
+
* (`AppServerOptions.shutdown_drain_timeout_ms`). Twin of the Rust spine's
|
|
15
|
+
* `DEFAULT_DRAIN_TIMEOUT`.
|
|
16
|
+
*/
|
|
17
|
+
export const DEFAULT_SHUTDOWN_DRAIN_TIMEOUT_MS = 10_000;
|
|
18
|
+
/**
|
|
19
|
+
* Whether a shutdown gave up on anything — its drain bound ran out before
|
|
20
|
+
* every wait finished. A process reports it as a failed exit. Twin of the
|
|
21
|
+
* Rust `ServeShutdown::gave_up`.
|
|
22
|
+
*
|
|
23
|
+
* @param report - what `AppServer.close` resolved
|
|
24
|
+
*/
|
|
25
|
+
export const shutdown_gave_up = (report) => report.requests > 0 || report.audit_writes > 0 || report.upkeep > 0;
|
|
26
|
+
/**
|
|
27
|
+
* Wait for the upkeep stops (the auth cleanup's pass in progress), then the
|
|
28
|
+
* requests held (HTTP requests, WS messages and WS upgrades still opening,
|
|
29
|
+
* one tracker — each until its handler has returned and its flush settled)
|
|
30
|
+
* and then the audit emitter's pool writes, until none is left or
|
|
31
|
+
* `timeout_ms` passes — then log an error naming what was given up on. One
|
|
32
|
+
* bound for all of it. Never rejects. The Rust shutdown joins its upkeep after
|
|
33
|
+
* the request drain; both wait concurrently against one deadline, so only the
|
|
34
|
+
* wait order differs.
|
|
35
|
+
*
|
|
36
|
+
* @param requests - the request tracker
|
|
37
|
+
* @param audit - the audit emitter
|
|
38
|
+
* @param upkeep - each upkeep task's stop, already requested; one still pending at the bound is counted
|
|
39
|
+
* @param timeout_ms - the bound
|
|
40
|
+
* @param log - where a give-up is logged
|
|
41
|
+
* @returns what was given up on, every count `0` when everything settled
|
|
42
|
+
*/
|
|
43
|
+
export const drain_effects_on_shutdown = async (requests, audit, upkeep, timeout_ms, log) => {
|
|
44
|
+
let upkeep_pending = upkeep.length;
|
|
45
|
+
const drain = async () => {
|
|
46
|
+
// the upkeep first, so a write a pass started is in the loop below
|
|
47
|
+
await Promise.all(upkeep.map(async (stopped) => {
|
|
48
|
+
await stopped;
|
|
49
|
+
upkeep_pending--;
|
|
50
|
+
}));
|
|
51
|
+
// until both are empty: a flush's post-commit thunk can start an audit
|
|
52
|
+
// write, and a request accepted meanwhile is held too
|
|
53
|
+
do {
|
|
54
|
+
await requests.drain_inflight();
|
|
55
|
+
await audit.drain_inflight();
|
|
56
|
+
} while (requests.inflight_count() > 0 || audit.inflight_count() > 0);
|
|
57
|
+
};
|
|
58
|
+
let timer;
|
|
59
|
+
const timed_out = new Promise((resolve) => {
|
|
60
|
+
timer = setTimeout(resolve, timeout_ms);
|
|
61
|
+
});
|
|
62
|
+
try {
|
|
63
|
+
await Promise.race([drain(), timed_out]);
|
|
64
|
+
}
|
|
65
|
+
finally {
|
|
66
|
+
clearTimeout(timer);
|
|
67
|
+
}
|
|
68
|
+
const given_up = {
|
|
69
|
+
requests: requests.inflight_count(),
|
|
70
|
+
audit_writes: audit.inflight_count(),
|
|
71
|
+
upkeep: upkeep_pending
|
|
72
|
+
};
|
|
73
|
+
if (!shutdown_gave_up(given_up))
|
|
74
|
+
return given_up;
|
|
75
|
+
log.error(`create_app_server: shutdown gave up after ${timeout_ms}ms on work still running — ${given_up.requests} request(s) (handler, effect flush, or WS open), ${given_up.audit_writes} audit row write(s), ${given_up.upkeep} upkeep task(s)`);
|
|
76
|
+
return given_up;
|
|
77
|
+
};
|