@fjall/util 10.1.1 → 10.1.2

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.
@@ -9,7 +9,7 @@
9
9
  "package.json",
10
10
  "tsconfig.json"
11
11
  ],
12
- "hash": "22380d353b56a1c1a3921a98da8b6ddf55ad74d713ca984cb2f9e7c59c15414b",
12
+ "hash": "bbdbacc3ff24fe60e8b272d2fae3be6b34b377dccd72015787d69025246230ff",
13
13
  "files": {
14
14
  "src/async/concurrency.ts": "3c7ebe0222a720f9",
15
15
  "src/async/singleton.ts": "7bcc21b0fb920561",
@@ -63,6 +63,7 @@
63
63
  "src/failure/extractErrorWindow.ts": "ca41f90946fa939c",
64
64
  "src/fsHelpers.ts": "0869d9739d523572",
65
65
  "src/fsScan.ts": "feb187758481443f",
66
+ "src/httpKeepAlive.ts": "c8fe4b118ef4c79f",
66
67
  "src/index.ts": "78390afd568e517a",
67
68
  "src/infra/backupVault.ts": "661678a6dfb0b648",
68
69
  "src/infra/connectionsWire.ts": "125c099da0e17ac1",
@@ -106,9 +107,9 @@
106
107
  "src/securityHelpers.ts": "ee2ab9ffd53119fb",
107
108
  "src/targets.ts": "126280f0a5762e21",
108
109
  "../scripts/minify-dist.mjs": "6b2e4b0df8aec601",
109
- "package.json": "e1032fb657942835",
110
+ "package.json": "a2c0e36325985f2e",
110
111
  "tsconfig.json": "db759831ad95f396"
111
112
  },
112
- "outputHash": "05e1db6e55226f186807b0354c7706834fe6b612131bc241901af1d9b0a28826",
113
- "outputFileCount": 195
113
+ "outputHash": "2fbb62c936263ba0fed951492d8236364fa5cf422dd6afad9df45dec7746c16c",
114
+ "outputFileCount": 197
114
115
  }
package/dist/.minified CHANGED
@@ -1 +1 @@
1
- 97 files minified at 2026-08-11T22:31:58.152Z
1
+ 98 files minified at 2026-08-12T11:24:47.744Z
@@ -0,0 +1,49 @@
1
+ /**
2
+ * ALB ↔ Node HTTP keep-alive contract.
3
+ *
4
+ * An ALB holds idle keep-alive connections to its targets open for up to its
5
+ * idle timeout and freely reuses them. Node's default `server.keepAliveTimeout`
6
+ * is 5 seconds — far below the ALB's 60 — so the ALB routinely reuses a
7
+ * connection at the instant Node closes it, surfacing as intermittent
8
+ * ALB-generated 502s that never reach the application. The fix is server-side:
9
+ * the target's keep-alive timeout must exceed the ALB idle timeout, and
10
+ * `headersTimeout` must exceed `keepAliveTimeout` so a request that starts
11
+ * arriving just before the keep-alive deadline is not truncated mid-headers.
12
+ *
13
+ * The Fjall ECS construct pins the ALB idle timeout to
14
+ * `DEFAULT_ALB_IDLE_TIMEOUT_SECONDS` and injects that value into ALB-fronted
15
+ * containers as `FJALL_ALB_IDLE_TIMEOUT_SECONDS` (see
16
+ * `components/infrastructure/lib/resources/aws/compute/applicationLoadBalancer.ts`).
17
+ * This module is the consuming half of the contract: call
18
+ * `applyAlbKeepAliveTimeouts(server)` after `listen()`. When the env var is
19
+ * absent (local dev, containers deployed before the construct injected it) the
20
+ * AWS default of 60 seconds is assumed, which yields the same timeouts.
21
+ */
22
+ export declare const FJALL_ALB_IDLE_TIMEOUT_ENV_VAR = "FJALL_ALB_IDLE_TIMEOUT_SECONDS";
23
+ /**
24
+ * The ALB idle timeout every Fjall ALB is pinned to (also the AWS default,
25
+ * assumed when the env var is absent). The construct imports this constant so
26
+ * the ALB attribute, the injected env var, and this fallback cannot drift.
27
+ */
28
+ export declare const DEFAULT_ALB_IDLE_TIMEOUT_SECONDS = 60;
29
+ export interface AlbKeepAliveTimeouts {
30
+ albIdleTimeoutSeconds: number;
31
+ keepAliveTimeoutMs: number;
32
+ headersTimeoutMs: number;
33
+ }
34
+ /** Structural subset of `node:http.Server` this module tunes. */
35
+ export interface KeepAliveTunableServer {
36
+ keepAliveTimeout: number;
37
+ headersTimeout: number;
38
+ }
39
+ /**
40
+ * Resolves the keep-alive timeouts for a server behind a Fjall ALB from
41
+ * `FJALL_ALB_IDLE_TIMEOUT_SECONDS`. Throws on a malformed value — a
42
+ * misconfigured contract must fail the boot loudly, not race the ALB.
43
+ */
44
+ export declare function resolveAlbKeepAliveTimeouts(env?: Record<string, string | undefined>): AlbKeepAliveTimeouts;
45
+ /**
46
+ * Applies the resolved timeouts to a Node HTTP(S) server and returns them so
47
+ * the caller can log what was applied.
48
+ */
49
+ export declare function applyAlbKeepAliveTimeouts(server: KeepAliveTunableServer, env?: Record<string, string | undefined>): AlbKeepAliveTimeouts;
@@ -0,0 +1 @@
1
+ var i=Object.defineProperty;var _=(o,e)=>i(o,"name",{value:e,configurable:!0});const E="FJALL_ALB_IDLE_TIMEOUT_SECONDS",T=60,r=5,u=1e3;function n(o=process.env){const e=o[E];let t=60;if(e!==void 0){if(!/^[0-9]+$/.test(e)||Number.parseInt(e,10)<=0)throw new Error(`${E} must be a positive integer number of seconds, got ${JSON.stringify(e)} \u2014 unset it to assume the AWS default of ${String(60)}`);t=Number.parseInt(e,10)}const s=(t+5)*1e3;return{albIdleTimeoutSeconds:t,keepAliveTimeoutMs:s,headersTimeoutMs:s+1e3}}_(n,"resolveAlbKeepAliveTimeouts");function I(o,e=process.env){const t=n(e);return o.keepAliveTimeout=t.keepAliveTimeoutMs,o.headersTimeout=t.headersTimeoutMs,t}_(I,"applyAlbKeepAliveTimeouts");export{T as DEFAULT_ALB_IDLE_TIMEOUT_SECONDS,E as FJALL_ALB_IDLE_TIMEOUT_ENV_VAR,I as applyAlbKeepAliveTimeouts,n as resolveAlbKeepAliveTimeouts};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fjall/util",
3
- "version": "10.1.1",
3
+ "version": "10.1.2",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/fjall-tech/fjall.git",
@@ -55,6 +55,10 @@
55
55
  "types": "./dist/fsHelpers.d.ts",
56
56
  "default": "./dist/fsHelpers.js"
57
57
  },
58
+ "./httpKeepAlive": {
59
+ "types": "./dist/httpKeepAlive.d.ts",
60
+ "default": "./dist/httpKeepAlive.js"
61
+ },
58
62
  "./cdkTmpdirCleanup": {
59
63
  "types": "./dist/cdkTmpdirCleanup.d.ts",
60
64
  "default": "./dist/cdkTmpdirCleanup.js"