@nuetzliches/croniq-runner 0.3.0 → 0.4.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/CHANGELOG.md +63 -0
- package/README.md +25 -2
- package/dist/client.d.ts +61 -0
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +87 -0
- package/dist/client.js.map +1 -1
- package/dist/dispatcher.d.ts +1 -1
- package/dist/dispatcher.d.ts.map +1 -1
- package/dist/dispatcher.js +34 -7
- package/dist/dispatcher.js.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/dist/log-writer.d.ts +1 -1
- package/dist/log-writer.d.ts.map +1 -1
- package/dist/log-writer.js +17 -3
- package/dist/log-writer.js.map +1 -1
- package/dist/logger.d.ts.map +1 -1
- package/dist/logger.js +10 -2
- package/dist/logger.js.map +1 -1
- package/dist/options.d.ts +42 -1
- package/dist/options.d.ts.map +1 -1
- package/dist/options.js +21 -1
- package/dist/options.js.map +1 -1
- package/dist/runner.d.ts.map +1 -1
- package/dist/runner.js +145 -6
- package/dist/runner.js.map +1 -1
- package/dist/sanitize.d.ts +82 -0
- package/dist/sanitize.d.ts.map +1 -0
- package/dist/sanitize.js +157 -0
- package/dist/sanitize.js.map +1 -0
- package/dist/security.d.ts +19 -0
- package/dist/security.d.ts.map +1 -0
- package/dist/security.js +83 -0
- package/dist/security.js.map +1 -0
- package/dist/trigger.d.ts +21 -1
- package/dist/trigger.d.ts.map +1 -1
- package/dist/trigger.js +4 -0
- package/dist/trigger.js.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,68 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.4.0 - 2026-08-21
|
|
4
|
+
|
|
5
|
+
### Added
|
|
6
|
+
|
|
7
|
+
- **A ceiling on consecutive authentication failures
|
|
8
|
+
([#473](https://github.com/nuetzliches/croniq/issues/473)).** New `maxConsecutiveAuthFailures` option (default `3`, range `[1, 100]`) budgets
|
|
9
|
+
consecutive `401 Unauthorized` responses to `POST /v1/work/poll`. On
|
|
10
|
+
exhaustion the runner stops with the new exported `AuthFailedError`, which carries the streak length and
|
|
11
|
+
names the remedy: restart with the current key. The counter resets on a
|
|
12
|
+
successful poll and on any other failure — a 5xx says nothing about whether
|
|
13
|
+
the credential is valid.
|
|
14
|
+
|
|
15
|
+
**Behaviour change.** A `401` was previously classified as transient, so a
|
|
16
|
+
runner whose key was revoked retried it every poll interval forever. The
|
|
17
|
+
credential is read once, at construction, and never re-read, so retrying
|
|
18
|
+
could not clear it: the process stayed up, looked healthy, did nothing, and
|
|
19
|
+
never exited non-zero — which meant no supervisor ever restarted it, and
|
|
20
|
+
restarting is exactly what would have picked up the new key.
|
|
21
|
+
|
|
22
|
+
Unlike the `403` of #437 the first `401` is *not* fatal. Key rotation hands
|
|
23
|
+
over by installing the new key and giving the old one an expiry
|
|
24
|
+
([#471](https://github.com/nuetzliches/croniq/issues/471)), so dying on a
|
|
25
|
+
single rejection would turn a narrow race around that handover into an
|
|
26
|
+
outage. Conformance case `17-poll-401-auth-ceiling.yaml` pins the contract on
|
|
27
|
+
the wire across all five runner bindings.
|
|
28
|
+
|
|
29
|
+
- **A ceiling on consecutive poll conflicts ([#466](https://github.com/nuetzliches/croniq/issues/466)).** New `maxConsecutivePollConflicts` option (default `3`, range `[1, 100]`) budgets consecutive `409 Conflict` responses to `POST /v1/work/poll`. On exhaustion `run()` rejects with the new exported `PollInstanceConflictError`, which carries `runnerId` and `consecutiveCount` and names the remedy: stop the duplicate process or rotate the `runner_id`. The counter resets on a successful poll or on any non-409 failure (5xx, network, timeout), which say nothing about instance ownership.
|
|
30
|
+
|
|
31
|
+
**Behaviour change.** A sustained `409` previously retried forever. One conflict is still transient — a deposed instance may win its identity back, and conformance case 11 pins that it is retried — but a *streak* of them is a duplicate deployment, two processes started with the same fixed `runnerId`, and retrying that forever left the misconfiguration behind a warning that scrolled past. The runner now exits so the process can fail non-zero and reach monitoring, matching what the Rust and .NET SDKs have done since [#134](https://github.com/nuetzliches/croniq/issues/134) sub-item 1. Set the option to `100` to get close to the old behaviour. The `403` half was already symmetric across the SDKs (#437/#458); this closes the `409` half.
|
|
32
|
+
|
|
33
|
+
Conformance case `16-poll-409-conflict-ceiling.yaml` pins the contract on the wire and now runs green in all five bindings — including .NET, whose implementation had no corpus coverage until now.
|
|
34
|
+
|
|
35
|
+
### Fixed
|
|
36
|
+
|
|
37
|
+
- **A `403` on the work endpoints is fatal ([#437](https://github.com/nuetzliches/croniq/issues/437)).** Since server issue #436 bound a runner's identity to the authenticated caller, `/v1/work/*` answers `403` when the credential does not own the `runner_id` the request names. The poll loop retried that forever on `pollRetryDelayMs`, so a fenced-out runner looked idle rather than misconfigured. A `403` is permanent — no retry can clear it — so `run()` now rejects with the new exported `RunnerOwnershipDeniedError` on the first one. It carries `runnerId` and names both fixes: give the runner its own `runner_id`, or release the existing binding with `DELETE /v1/runners/{id}`. The drain step still runs first, so in-flight handlers get their grace period before the rejection surfaces.
|
|
38
|
+
|
|
39
|
+
- **A `403` on ack, renew or log events is visible ([#437](https://github.com/nuetzliches/croniq/issues/437)).** These paths never inspected the status, so an ownership refusal was indistinguishable from a 5xx: `logger.debug` for renew, `logger.warn` for a dropped log batch. Each now logs at `logger.error` with the remedy, because each has its own consequence — an unacked execution stays claimed until its lease expires, a refused renew means the lease expires mid-handler, and a refused batch means the execution produces no log output. Renew's `404`/`409` — routine when a renew races the runner's own completion, see server issue #438 — stay at `debug`.
|
|
40
|
+
|
|
41
|
+
### Security
|
|
42
|
+
|
|
43
|
+
- **HTTPS is required for a non-loopback `serverUrl` ([#440](https://github.com/nuetzliches/croniq/issues/440)).** `serverUrl` was only checked for parseability, so an operator who kept the documented `http://localhost:4000` shape and swapped in a real host shipped the API key as a cleartext `Authorization` header on every poll — and, because undici honours `HTTP_PROXY` by default, through any configured proxy as well. `resolveOptions` (i.e. `createRunner`) and the `CroniqTriggerClient` constructor now validate the scheme up front, so a misconfiguration fails fast instead of on the first poll. `https://` is always accepted; `http://` only when the host is loopback (`localhost`, `127.0.0.0/8`, `::1`, including `[::1]`), keeping the documented quickstart working; anything else throws a `TypeError` naming the URL and the opt-in. The new `allowInsecureHttp: true` option accepts a cleartext URL deliberately and emits one loud `logger.warn` instead. `CroniqTriggerClientOptions` gained a `logger` option so that warning can be routed; `isLoopbackHostname` is exported for callers that want the same classification.
|
|
44
|
+
|
|
45
|
+
- **`job_key` and `execution_id` no longer reach log messages, and are validated
|
|
46
|
+
on ingest ([#441](https://github.com/nuetzliches/croniq/issues/441)).**
|
|
47
|
+
`dispatcher.ts`, `runner.ts` and `log-writer.ts` interpolated both identifiers
|
|
48
|
+
into their messages via template literals, and `consoleLogger` then wrote the
|
|
49
|
+
message to the console verbatim — so a server-supplied value carrying CRLF
|
|
50
|
+
forged log records and one carrying ANSI escapes reached the operator's
|
|
51
|
+
terminal raw. Both identifiers now travel only in the `fields` map, which is
|
|
52
|
+
rendered with `JSON.stringify` and therefore already escaped, and
|
|
53
|
+
`consoleLogger` escapes control characters (C0 including ESC, DEL, and C1) in
|
|
54
|
+
the message before writing. The runner additionally validates both identifiers
|
|
55
|
+
before dispatching. A `job_key` is refused only for containing a control
|
|
56
|
+
character — C0, DEL or C1 — or exceeding 256 scalar values; every printable
|
|
57
|
+
character in any script is accepted, interior spaces included, because
|
|
58
|
+
`job "billing:monthly invoice" { … }` is legal DSL and `POST /v1/jobs`
|
|
59
|
+
constrains the key not at all. Execution ids keep a narrow
|
|
60
|
+
`a-z A-Z 0-9 - _ . :` charset up to 64 characters, which the server's v4
|
|
61
|
+
UUIDs satisfy strictly. A refused assignment with a *valid* `execution_id` is
|
|
62
|
+
acked as a failure naming the offending field, so it dead-letters rather than
|
|
63
|
+
looping; one whose `execution_id` is itself unsafe is dropped, since nothing
|
|
64
|
+
safely addresses the server.
|
|
65
|
+
|
|
3
66
|
## 0.3.0 - 2026-07-18
|
|
4
67
|
|
|
5
68
|
- **`ExecutionContext.scheduledFor`** exposes the trigger's original logical fire time (`Date | null`), stable across retries and dead-letter replays. Use it for time-relative job logic (e.g. the month a report covers) instead of `new Date()`. `null` when the server predates the field — the SDK never falls back to the queue fire time.
|
package/README.md
CHANGED
|
@@ -147,17 +147,20 @@ The same registered handler serves both its Croniqfile schedule (safety-net / re
|
|
|
147
147
|
|
|
148
148
|
| Option | Default | Description |
|
|
149
149
|
| ------------------ | -------------- | ---------------------------------------------------- |
|
|
150
|
-
| `serverUrl` | _(required)_ | Croniq server base URL.
|
|
150
|
+
| `serverUrl` | _(required)_ | Croniq server base URL. HTTPS required off loopback. |
|
|
151
151
|
| `apiKey` | — | `Authorization: ApiKey {…}`. Precedence over bearer. |
|
|
152
152
|
| `bearerToken` | — | `Authorization: Bearer {…}`. |
|
|
153
153
|
| `requestTimeoutMs` | `30_000` | Per-request timeout. |
|
|
154
154
|
| `fetchImpl` | global `fetch` | Custom `fetch` (testing / proxies). |
|
|
155
|
+
| `allowInsecureHttp`| `false` | Opt in to cleartext `http://` off loopback. |
|
|
156
|
+
| `logger` | console (warn) | Sink for SDK diagnostics. |
|
|
155
157
|
|
|
156
158
|
## Configuration
|
|
157
159
|
|
|
158
160
|
| Option | Default | Description |
|
|
159
161
|
| --------------------- | ---------------------------------------------------- | ------------------------------------------------------------------------ |
|
|
160
|
-
| `serverUrl` | _(required)_ | Croniq server base URL.
|
|
162
|
+
| `serverUrl` | _(required)_ | Croniq server base URL. HTTPS required off loopback — see below. |
|
|
163
|
+
| `allowInsecureHttp` | `false` | Opt in to a cleartext `http://` `serverUrl` on a non-loopback host. |
|
|
161
164
|
| `runnerId` | resolved | Stable id. Falls back to `RUNNER_ID` env var → state file → generated. |
|
|
162
165
|
| `runnerIdPrefix` | `"runner"` | Used when generating an id. |
|
|
163
166
|
| `runnerDataDir` | platform default | Where the persistent `runner-id` file lives. |
|
|
@@ -171,10 +174,30 @@ The same registered handler serves both its Croniqfile schedule (safety-net / re
|
|
|
171
174
|
| `drainTimeoutMs` | `30_000` | Graceful shutdown budget before hard-cancel. |
|
|
172
175
|
| `pollRetryDelayMs` | `5_000` | Back-off after a failed poll. |
|
|
173
176
|
| `capacityBackoffMs` | `500` | Idle wait when at `maxInflight`. |
|
|
177
|
+
| `maxConsecutivePollConflicts` | `3` | Consecutive poll `409`s before `PollInstanceConflictError`. |
|
|
174
178
|
| `logWriter` | see below | Streaming log-writer tunables. |
|
|
175
179
|
|
|
176
180
|
LogWriter sub-options: `channelCapacity` (256), `batchSizeThreshold` (32), `batchTimeThresholdMs` (200), `maxBatchPerPost` (100), `shutdownTimeoutMs` (5_000).
|
|
177
181
|
|
|
182
|
+
### Transport security
|
|
183
|
+
|
|
184
|
+
The credential is attached to every request as an `Authorization` header. Over `http://` it travels in cleartext — and undici honours `HTTP_PROXY` by default, so it can traverse an intermediary in the clear too.
|
|
185
|
+
|
|
186
|
+
Both `createRunner` and `createTriggerClient` therefore refuse a cleartext `serverUrl` at construction time unless the host is loopback:
|
|
187
|
+
|
|
188
|
+
- accepted: any `https://` URL, and `http://` on `localhost`, `127.0.0.0/8` or `::1` — so the `http://localhost:4000` quickstart default keeps working;
|
|
189
|
+
- refused: `http://` on any other host, with a `TypeError` naming the URL and the opt-in.
|
|
190
|
+
|
|
191
|
+
If a deployment genuinely has no TLS terminator (a lab or staging box), opt in explicitly — the SDK then starts, but emits one loud warning through the configured `logger`:
|
|
192
|
+
|
|
193
|
+
```ts
|
|
194
|
+
const runner = createRunner({
|
|
195
|
+
serverUrl: 'http://croniq.internal:4000',
|
|
196
|
+
apiKey: process.env.CRONIQ_API_KEY,
|
|
197
|
+
allowInsecureHttp: true, // the API key travels in cleartext
|
|
198
|
+
});
|
|
199
|
+
```
|
|
200
|
+
|
|
178
201
|
## Wire-protocol conformance
|
|
179
202
|
|
|
180
203
|
Validated against the shared, language-neutral suite at [`sdks/conformance/`](../conformance/) — the runner (consumer) cases in [`cases/`](../conformance/cases), plus the producer (trigger) cases in [`cases-trigger/`](../conformance/cases-trigger) ([#287](https://github.com/nuetzliches/croniq/issues/287)) which the binding's trigger runner picks up automatically once present. The TypeScript binding lives at [`sdks/conformance/bindings/typescript/`](../conformance/bindings/typescript).
|
package/dist/client.d.ts
CHANGED
|
@@ -15,6 +15,67 @@ export declare class HttpError extends Error {
|
|
|
15
15
|
readonly body: string;
|
|
16
16
|
constructor(status: number, statusText: string, path: string, body: string);
|
|
17
17
|
}
|
|
18
|
+
/**
|
|
19
|
+
* A work endpoint answered `403 Forbidden`: the authenticated credential is
|
|
20
|
+
* bound to a different `runner_id` than the one this runner names in its
|
|
21
|
+
* requests (server issue #436).
|
|
22
|
+
*
|
|
23
|
+
* Unlike a `409` — where a duplicate deployment may release the identity on
|
|
24
|
+
* its own — this is **permanent**: retrying cannot clear it. `CroniqRunner.run`
|
|
25
|
+
* rejects with this instead of polling forever, so a misconfigured runner
|
|
26
|
+
* exits rather than looking merely idle (issue #437). The fix is an operator
|
|
27
|
+
* action: give the runner its own `runner_id`, or release the existing
|
|
28
|
+
* binding with `DELETE /v1/runners/{id}`.
|
|
29
|
+
*/
|
|
30
|
+
export declare class RunnerOwnershipDeniedError extends Error {
|
|
31
|
+
readonly runnerId: string;
|
|
32
|
+
constructor(runnerId: string);
|
|
33
|
+
}
|
|
34
|
+
/** True when `err` is a 403 from a work endpoint — the ownership refusal. */
|
|
35
|
+
export declare function isOwnershipDenied(err: unknown): boolean;
|
|
36
|
+
/**
|
|
37
|
+
* `POST /v1/work/poll` answered `409 Conflict` `maxConsecutivePollConflicts`
|
|
38
|
+
* times in a row: another process is already registered under this
|
|
39
|
+
* `runner_id` and keeps winning the identity (fencing, server issue #374).
|
|
40
|
+
*
|
|
41
|
+
* A single 409 is transient — a deposed instance may legitimately take its
|
|
42
|
+
* identity back — so the runner backs off and retries. A streak of them is
|
|
43
|
+
* not: it is a duplicate deployment, two processes started with the same
|
|
44
|
+
* fixed `runnerId`. Retrying forever there leaves the misconfiguration behind
|
|
45
|
+
* a warning that scrolls past, so `CroniqRunner.run` rejects with this
|
|
46
|
+
* instead (issue #134 sub-item 1).
|
|
47
|
+
*
|
|
48
|
+
* Distinct from {@link RunnerOwnershipDeniedError}, which is a 403 and
|
|
49
|
+
* permanent from the first response.
|
|
50
|
+
*/
|
|
51
|
+
export declare class PollInstanceConflictError extends Error {
|
|
52
|
+
readonly runnerId: string;
|
|
53
|
+
readonly consecutiveCount: number;
|
|
54
|
+
constructor(runnerId: string, consecutiveCount: number);
|
|
55
|
+
}
|
|
56
|
+
/** True when `err` is a 409 from the poll endpoint — the fencing refusal. */
|
|
57
|
+
export declare function isInstanceConflict(err: unknown): boolean;
|
|
58
|
+
/**
|
|
59
|
+
* A work endpoint answered `401 Unauthorized` `maxConsecutiveAuthFailures`
|
|
60
|
+
* times in a row: the API key was rejected and keeps being rejected.
|
|
61
|
+
*
|
|
62
|
+
* The credential is read once, when the client is built, and never re-read,
|
|
63
|
+
* so retrying presents the same dead key forever. Before this existed a 401
|
|
64
|
+
* fell into the generic transient bucket and the runner retried on the poll
|
|
65
|
+
* interval indefinitely: the process stayed up, looked healthy, did nothing,
|
|
66
|
+
* and never exited non-zero — so no supervisor restarted it, and restarting
|
|
67
|
+
* is exactly what would have picked up the new key (issue #473).
|
|
68
|
+
*
|
|
69
|
+
* Not thrown on the first 401. Key rotation hands over by installing the new
|
|
70
|
+
* key and giving the old one an expiry (server issue #471), and dying on a
|
|
71
|
+
* single 401 would turn a narrow race around that handover into an outage.
|
|
72
|
+
*/
|
|
73
|
+
export declare class AuthFailedError extends Error {
|
|
74
|
+
readonly consecutiveCount: number;
|
|
75
|
+
constructor(consecutiveCount: number);
|
|
76
|
+
}
|
|
77
|
+
/** True when `err` is a 401 from a work endpoint — the rejected credential. */
|
|
78
|
+
export declare function isUnauthorized(err: unknown): boolean;
|
|
18
79
|
/**
|
|
19
80
|
* HTTP client for the Croniq runner API. Adds `Authorization` per request
|
|
20
81
|
* (ApiKey takes precedence over Bearer when both are set) and serialises
|
package/dist/client.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,UAAU,EACV,WAAW,EACX,YAAY,EACZ,kBAAkB,EAClB,mBAAmB,EACnB,YAAY,EACZ,SAAS,EACV,MAAM,eAAe,CAAC;AAGvB,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAG1C,MAAM,WAAW,mBAAmB;IAClC,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC5B,WAAW,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACjC,qEAAqE;IACrE,SAAS,CAAC,EAAE,OAAO,KAAK,CAAC;IACzB,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CAC7B;AAED,qBAAa,SAAU,SAAQ,KAAK;aAEhB,MAAM,EAAE,MAAM;aACd,UAAU,EAAE,MAAM;aAClB,IAAI,EAAE,MAAM;aACZ,IAAI,EAAE,MAAM;gBAHZ,MAAM,EAAE,MAAM,EACd,UAAU,EAAE,MAAM,EAClB,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM;CAK/B;AAED;;;;GAIG;AACH,qBAAa,YAAY;;gBAOX,IAAI,EAAE,mBAAmB;IAQ/B,IAAI,CAAC,GAAG,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,WAAW,GAAG,OAAO,CAAC,YAAY,CAAC;IAKrF,GAAG,CAAC,GAAG,EAAE,UAAU,EAAE,MAAM,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC;IAIxD,KAAK,CAAC,GAAG,EAAE,YAAY,EAAE,MAAM,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC;IAI5D,UAAU,CAAC,WAAW,EAAE,MAAM,EA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MAAM;aAChB,gBAAgB,EAAE,MAAM;gBADxB,QAAQ,EAAE,MAAM,EAChB,gBAAgB,EAAE,MAAM;CAS3C;AAED,6EAA6E;AAC7E,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,OAAO,GAAG,OAAO,CAExD;AAED;;;;;;;;;;;;;;GAcG;AACH,qBAAa,eAAgB,SAAQ,KAAK;aACZ,gBAAgB,EAAE,MAAM;gBAAxB,gBAAgB,EAAE,MAAM;CAQrD;AAED,+EAA+E;AAC/E,wBAAgB,cAAc,CAAC,GAAG,EAAE,OAAO,GAAG,OAAO,CAEpD;AAED;;;;GAIG;AACH,qBAAa,YAAY;;gBAOX,IAAI,EAAE,mBAAmB;IAQ/B,IAAI,CAAC,GAAG,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,WAAW,GAAG,OAAO,CAAC,YAAY,CAAC;IAKrF,GAAG,CAAC,GAAG,EAAE,UAAU,EAAE,MAAM,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC;IAIxD,KAAK,CAAC,GAAG,EAAE,YAAY,EAAE,MAAM,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC;IAI5D,UAAU,CAAC,WAAW,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,EAAE,MAAM,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC;IAMxF,WAAW,CAAC,GAAG,EAAE,kBAAkB,EAAE,MAAM,EAAE,WAAW,GAAG,OAAO,CAAC,mBAAmB,GAAG,SAAS,CAAC;CAgE1G"}
|
package/dist/client.js
CHANGED
|
@@ -15,6 +15,93 @@ export class HttpError extends Error {
|
|
|
15
15
|
this.name = 'HttpError';
|
|
16
16
|
}
|
|
17
17
|
}
|
|
18
|
+
/**
|
|
19
|
+
* A work endpoint answered `403 Forbidden`: the authenticated credential is
|
|
20
|
+
* bound to a different `runner_id` than the one this runner names in its
|
|
21
|
+
* requests (server issue #436).
|
|
22
|
+
*
|
|
23
|
+
* Unlike a `409` — where a duplicate deployment may release the identity on
|
|
24
|
+
* its own — this is **permanent**: retrying cannot clear it. `CroniqRunner.run`
|
|
25
|
+
* rejects with this instead of polling forever, so a misconfigured runner
|
|
26
|
+
* exits rather than looking merely idle (issue #437). The fix is an operator
|
|
27
|
+
* action: give the runner its own `runner_id`, or release the existing
|
|
28
|
+
* binding with `DELETE /v1/runners/{id}`.
|
|
29
|
+
*/
|
|
30
|
+
export class RunnerOwnershipDeniedError extends Error {
|
|
31
|
+
runnerId;
|
|
32
|
+
constructor(runnerId) {
|
|
33
|
+
super(`work ownership denied — the credential this runner authenticates with does not own ` +
|
|
34
|
+
`runner_id '${runnerId}'. The server answered 403 Forbidden on POST /v1/work/poll ` +
|
|
35
|
+
`and will keep doing so: give this runner its own runner_id, or release the ` +
|
|
36
|
+
`existing binding with DELETE /v1/runners/{id}.`);
|
|
37
|
+
this.runnerId = runnerId;
|
|
38
|
+
this.name = 'RunnerOwnershipDeniedError';
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
/** True when `err` is a 403 from a work endpoint — the ownership refusal. */
|
|
42
|
+
export function isOwnershipDenied(err) {
|
|
43
|
+
return err instanceof HttpError && err.status === 403;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* `POST /v1/work/poll` answered `409 Conflict` `maxConsecutivePollConflicts`
|
|
47
|
+
* times in a row: another process is already registered under this
|
|
48
|
+
* `runner_id` and keeps winning the identity (fencing, server issue #374).
|
|
49
|
+
*
|
|
50
|
+
* A single 409 is transient — a deposed instance may legitimately take its
|
|
51
|
+
* identity back — so the runner backs off and retries. A streak of them is
|
|
52
|
+
* not: it is a duplicate deployment, two processes started with the same
|
|
53
|
+
* fixed `runnerId`. Retrying forever there leaves the misconfiguration behind
|
|
54
|
+
* a warning that scrolls past, so `CroniqRunner.run` rejects with this
|
|
55
|
+
* instead (issue #134 sub-item 1).
|
|
56
|
+
*
|
|
57
|
+
* Distinct from {@link RunnerOwnershipDeniedError}, which is a 403 and
|
|
58
|
+
* permanent from the first response.
|
|
59
|
+
*/
|
|
60
|
+
export class PollInstanceConflictError extends Error {
|
|
61
|
+
runnerId;
|
|
62
|
+
consecutiveCount;
|
|
63
|
+
constructor(runnerId, consecutiveCount) {
|
|
64
|
+
super(`poll instance conflict — another runner is already registered with runner_id ` +
|
|
65
|
+
`'${runnerId}'. Observed ${consecutiveCount} consecutive 409 Conflict responses ` +
|
|
66
|
+
`on POST /v1/work/poll. Stop the duplicate process or rotate the runner_id.`);
|
|
67
|
+
this.runnerId = runnerId;
|
|
68
|
+
this.consecutiveCount = consecutiveCount;
|
|
69
|
+
this.name = 'PollInstanceConflictError';
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
/** True when `err` is a 409 from the poll endpoint — the fencing refusal. */
|
|
73
|
+
export function isInstanceConflict(err) {
|
|
74
|
+
return err instanceof HttpError && err.status === 409;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* A work endpoint answered `401 Unauthorized` `maxConsecutiveAuthFailures`
|
|
78
|
+
* times in a row: the API key was rejected and keeps being rejected.
|
|
79
|
+
*
|
|
80
|
+
* The credential is read once, when the client is built, and never re-read,
|
|
81
|
+
* so retrying presents the same dead key forever. Before this existed a 401
|
|
82
|
+
* fell into the generic transient bucket and the runner retried on the poll
|
|
83
|
+
* interval indefinitely: the process stayed up, looked healthy, did nothing,
|
|
84
|
+
* and never exited non-zero — so no supervisor restarted it, and restarting
|
|
85
|
+
* is exactly what would have picked up the new key (issue #473).
|
|
86
|
+
*
|
|
87
|
+
* Not thrown on the first 401. Key rotation hands over by installing the new
|
|
88
|
+
* key and giving the old one an expiry (server issue #471), and dying on a
|
|
89
|
+
* single 401 would turn a narrow race around that handover into an outage.
|
|
90
|
+
*/
|
|
91
|
+
export class AuthFailedError extends Error {
|
|
92
|
+
consecutiveCount;
|
|
93
|
+
constructor(consecutiveCount) {
|
|
94
|
+
super(`unauthorized — the API key was rejected on ${consecutiveCount} consecutive ` +
|
|
95
|
+
`POST /v1/work/poll attempts. It may have been revoked, or its rotation grace ` +
|
|
96
|
+
`window may have elapsed. Restart the runner with the current key.`);
|
|
97
|
+
this.consecutiveCount = consecutiveCount;
|
|
98
|
+
this.name = 'AuthFailedError';
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
/** True when `err` is a 401 from a work endpoint — the rejected credential. */
|
|
102
|
+
export function isUnauthorized(err) {
|
|
103
|
+
return err instanceof HttpError && err.status === 401;
|
|
104
|
+
}
|
|
18
105
|
/**
|
|
19
106
|
* HTTP client for the Croniq runner API. Adds `Authorization` per request
|
|
20
107
|
* (ApiKey takes precedence over Bearer when both are set) and serialises
|
package/dist/client.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAE7D,OAAO,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAW/C,MAAM,OAAO,SAAU,SAAQ,KAAK;IAEhB;IACA;IACA;IACA;IAJlB,YACkB,MAAc,EACd,UAAkB,EAClB,IAAY,EACZ,IAAY;QAE5B,KAAK,CAAC,GAAG,MAAM,IAAI,UAAU,OAAO,IAAI,EAAE,CAAC,CAAC;QAL5B,WAAM,GAAN,MAAM,CAAQ;QACd,eAAU,GAAV,UAAU,CAAQ;QAClB,SAAI,GAAJ,IAAI,CAAQ;QACZ,SAAI,GAAJ,IAAI,CAAQ;QAG5B,IAAI,CAAC,IAAI,GAAG,WAAW,CAAC;IAC1B,CAAC;CACF;AAED;;;;GAIG;AACH,MAAM,OAAO,YAAY;IACd,QAAQ,CAAS;IACjB,OAAO,CAAqB;IAC5B,YAAY,CAAqB;IACjC,MAAM,CAAe;IACrB,OAAO,CAAqB;IAErC,YAAY,IAAyB;QACnC,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AAS,CAAC;QACnB,CAAC;IACH,CAAC;CACF"}
|
package/dist/dispatcher.d.ts
CHANGED
package/dist/dispatcher.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dispatcher.d.ts","sourceRoot":"","sources":["../src/dispatcher.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"dispatcher.d.ts","sourceRoot":"","sources":["../src/dispatcher.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,YAAY,EAAqB,MAAM,aAAa,CAAC;AAKnE,OAAO,EAAE,KAAK,eAAe,EAA4B,MAAM,cAAc,CAAC;AAC9E,OAAO,EAAgB,KAAK,MAAM,EAAE,MAAM,aAAa,CAAC;AACxD,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,cAAc,CAAC;AAC1D,OAAO,KAAK,EAAyB,cAAc,EAAE,MAAM,eAAe,CAAC;AAE3E,MAAM,WAAW,cAAc;IAC7B,MAAM,EAAE,YAAY,CAAC;IACrB,QAAQ,EAAE,eAAe,CAAC;IAC1B,OAAO,EAAE,qBAAqB,CAAC;IAC/B,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,SAAS,MAAM,EAAE,CAAC;IAC9B,MAAM,EAAE,MAAM,CAAC;CAChB;AAED;;;;;GAKG;AACH,qBAAa,mBAAmB;;gBAGlB,IAAI,EAAE,cAAc;IAIhC;;;;;;;OAOG;IACG,QAAQ,CACZ,UAAU,EAAE,cAAc,EAC1B,WAAW,EAAE,eAAe,EAC5B,WAAW,EAAE,WAAW,GACvB,OAAO,CAAC,IAAI,CAAC;CAkKjB"}
|
package/dist/dispatcher.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { anySignal } from './abort.js';
|
|
2
|
+
import { isOwnershipDenied } from './client.js';
|
|
2
3
|
import { ExecutionContextImpl } from './context.js';
|
|
3
4
|
import { sleep } from './deferred.js';
|
|
4
5
|
import { parseScheduledFor, parseTimeoutMs } from './duration.js';
|
|
@@ -82,7 +83,9 @@ export class ExecutionDispatcher {
|
|
|
82
83
|
}
|
|
83
84
|
else {
|
|
84
85
|
const ex = err instanceof Error ? err : new Error(String(err));
|
|
85
|
-
|
|
86
|
+
// Identifiers travel as fields only, never interpolated into the
|
|
87
|
+
// message — see sanitize.ts. The same applies to every log call below.
|
|
88
|
+
logger.warn('job handler threw', {
|
|
86
89
|
error: ex.message,
|
|
87
90
|
job_key: jobKey,
|
|
88
91
|
execution_id: executionId,
|
|
@@ -107,9 +110,10 @@ export class ExecutionDispatcher {
|
|
|
107
110
|
await writer.dispose();
|
|
108
111
|
}
|
|
109
112
|
catch (err) {
|
|
110
|
-
logger.warn(
|
|
113
|
+
logger.warn('log_writer drain failed', {
|
|
111
114
|
error: String(err),
|
|
112
115
|
execution_id: executionId,
|
|
116
|
+
job_key: jobKey,
|
|
113
117
|
});
|
|
114
118
|
}
|
|
115
119
|
}
|
|
@@ -129,10 +133,20 @@ export class ExecutionDispatcher {
|
|
|
129
133
|
await client.ack(payload, ackAC.signal);
|
|
130
134
|
}
|
|
131
135
|
catch (err) {
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
+
if (isOwnershipDenied(err)) {
|
|
137
|
+
// Permanent (#436/#437) — the execution stays claimed until its
|
|
138
|
+
// lease expires, so name the fix rather than just the failure.
|
|
139
|
+
logger.error('ack refused with 403 Forbidden — this runner\'s credential does not own runner_id, ' +
|
|
140
|
+
'so the execution stays claimed until its lease expires. Give the runner its own ' +
|
|
141
|
+
'runner_id, or release the existing binding with DELETE /v1/runners/{id}', { error: String(err), runner_id: runnerId, execution_id: executionId, job_key: jobKey });
|
|
142
|
+
}
|
|
143
|
+
else {
|
|
144
|
+
logger.error('failed to ack execution', {
|
|
145
|
+
error: String(err),
|
|
146
|
+
execution_id: executionId,
|
|
147
|
+
job_key: jobKey,
|
|
148
|
+
});
|
|
149
|
+
}
|
|
136
150
|
}
|
|
137
151
|
}
|
|
138
152
|
async #renewLoop(executionId, runnerId, signal) {
|
|
@@ -152,7 +166,20 @@ export class ExecutionDispatcher {
|
|
|
152
166
|
catch (err) {
|
|
153
167
|
if (signal.aborted)
|
|
154
168
|
return;
|
|
155
|
-
|
|
169
|
+
if (isOwnershipDenied(err)) {
|
|
170
|
+
// Permanent (#436/#437): every later renew fails the same way and
|
|
171
|
+
// the lease will expire mid-handler.
|
|
172
|
+
logger.error('lease renew refused with 403 Forbidden — this runner\'s credential does not own ' +
|
|
173
|
+
'runner_id, so the lease will expire and the execution be reclaimed. Give the ' +
|
|
174
|
+
'runner its own runner_id, or release the existing binding with ' +
|
|
175
|
+
'DELETE /v1/runners/{id}', { error: String(err), runner_id: runnerId, execution_id: executionId });
|
|
176
|
+
continue;
|
|
177
|
+
}
|
|
178
|
+
// Since #447 renew is a real per-execution lease: 404 (no longer
|
|
179
|
+
// leased here) and 409 (already terminal) are the normal outcome of
|
|
180
|
+
// a renew racing our own completion, so they stay at debug
|
|
181
|
+
// alongside the transient failures.
|
|
182
|
+
logger.debug('lease renew failed', {
|
|
156
183
|
error: String(err),
|
|
157
184
|
execution_id: executionId,
|
|
158
185
|
});
|
package/dist/dispatcher.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dispatcher.js","sourceRoot":"","sources":["../src/dispatcher.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"dispatcher.js","sourceRoot":"","sources":["../src/dispatcher.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AACvC,OAAO,EAAqB,iBAAiB,EAAE,MAAM,aAAa,CAAC;AACnE,OAAO,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AACpD,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AACtC,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAAE,MA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,CAAC,EAAE,CAAC;oBAC3B,kEAAkE;oBAClE,qCAAqC;oBACrC,MAAM,CAAC,KAAK,CACV,kFAAkF;wBAChF,+EAA+E;wBAC/E,iEAAiE;wBACjE,yBAAyB,EAC3B,EAAE,KAAK,EAAE,MAAM,CAAC,GAAG,CAAC,EAAE,SAAS,EAAE,QAAQ,EAAE,YAAY,EAAE,WAAW,EAAE,CACvE,CAAC;oBACF,SAAS;gBACX,CAAC;gBACD,iEAAiE;gBACjE,oEAAoE;gBACpE,2DAA2D;gBAC3D,oCAAoC;gBACpC,MAAM,CAAC,KAAK,CAAC,oBAAoB,EAAE;oBACjC,KAAK,EAAE,MAAM,CAAC,GAAG,CAAC;oBAClB,YAAY,EAAE,WAAW;iBAC1B,CAAC,CAAC;YACL,CAAC;QACH,CAAC;IACH,CAAC;CACF"}
|
package/dist/index.d.ts
CHANGED
|
@@ -7,7 +7,8 @@ export type { Logger, LogLevel } from './logger.js';
|
|
|
7
7
|
export { consoleLogger, noopLogger } from './logger.js';
|
|
8
8
|
export type { LogWriter } from './log-writer.js';
|
|
9
9
|
export type { AckRequest, AckStatus, PollRequest, PollResponse, RegisterJobRequest, RegisterJobResponse, RenewRequest, TriggerRequest, TriggerResponse, WorkAssignment, WorkEvent, WorkEventLevel, } from './protocol.js';
|
|
10
|
-
export { HttpError } from './client.js';
|
|
10
|
+
export { AuthFailedError, HttpError, PollInstanceConflictError, RunnerOwnershipDeniedError } from './client.js';
|
|
11
|
+
export { isLoopbackHostname } from './security.js';
|
|
11
12
|
export { CroniqTriggerClient, createTriggerClient, QueueOverflowError } from './trigger.js';
|
|
12
13
|
export type { CroniqTriggerClientOptions, TriggerParams, TriggerResult, } from './trigger.js';
|
|
13
14
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY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AM,iBAAiB,CAAC;AACjD,YAAY,EACV,UAAU,EACV,SAAS,EACT,WAAW,EACX,YAAY,EACZ,kBAAkB,EAClB,mBAAmB,EACnB,YAAY,EACZ,cAAc,EACd,eAAe,EACf,cAAc,EACd,SAAS,EACT,cAAc,GACf,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,eAAe,EAAE,SAAS,EAAE,yBAAyB,EAAE,0BAA0B,EAAE,MAAM,aAAa,CAAC;AAChH,OAAO,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAGnD,OAAO,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAC5F,YAAY,EACV,0BAA0B,EAC1B,aAAa,EACb,aAAa,GACd,MAAM,cAAc,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
export { CroniqRunner, createRunner } from './runner.js';
|
|
3
3
|
export { NoHandlerRegisteredError } from './handler.js';
|
|
4
4
|
export { consoleLogger, noopLogger } from './logger.js';
|
|
5
|
-
export { HttpError } from './client.js';
|
|
5
|
+
export { AuthFailedError, HttpError, PollInstanceConflictError, RunnerOwnershipDeniedError } from './client.js';
|
|
6
|
+
export { isLoopbackHostname } from './security.js';
|
|
6
7
|
// Producer-side trigger (on-demand) client — parity with the .NET SDK (#277).
|
|
7
8
|
export { CroniqTriggerClient, createTriggerClient, QueueOverflowError } from './trigger.js';
|
|
8
9
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,uDAAuD;AAEvD,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AASzD,OAAO,EAAE,wBAAwB,EAAE,MAAM,cAAc,CAAC;AAExD,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAgBxD,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,uDAAuD;AAEvD,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AASzD,OAAO,EAAE,wBAAwB,EAAE,MAAM,cAAc,CAAC;AAExD,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAgBxD,OAAO,EAAE,eAAe,EAAE,SAAS,EAAE,yBAAyB,EAAE,0BAA0B,EAAE,MAAM,aAAa,CAAC;AAChH,OAAO,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAEnD,8EAA8E;AAC9E,OAAO,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC"}
|
package/dist/log-writer.d.ts
CHANGED
package/dist/log-writer.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"log-writer.d.ts","sourceRoot":"","sources":["../src/log-writer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"log-writer.d.ts","sourceRoot":"","sources":["../src/log-writer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,YAAY,EAAqB,MAAM,aAAa,CAAC;AAEnE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AACrD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,cAAc,CAAC;AAC7D,OAAO,KAAK,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAE/D,MAAM,WAAW,SAAS;IACxB,oEAAoE;IACpE,KAAK,CAAC,KAAK,EAAE,cAAc,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC9F,gCAAgC;IAChC,UAAU,CAAC,KAAK,EAAE,SAAS,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC5C,sDAAsD;IACtD,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IACvB;;;OAGG;IACH,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CAC1B;AAED;;;;;;;;;;GAUG;AACH,qBAAa,kBAAmB,YAAW,SAAS;;gBAkBhD,MAAM,EAAE,YAAY,EACpB,WAAW,EAAE,MAAM,EACnB,UAAU,EAAE,aAAa,EACzB,IAAI,EAAE,wBAAwB,EAC9B,MAAM,EAAE,MAAM;IAUV,KAAK,CAAC,KAAK,EAAE,cAAc,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;IAK7F,UAAU,CAAC,KAAK,EAAE,SAAS,GAAG,OAAO,CAAC,IAAI,CAAC;IAUjD,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAQhB,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;CAyH/B"}
|
package/dist/log-writer.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { isOwnershipDenied } from './client.js';
|
|
1
2
|
import { deferred, sleep } from './deferred.js';
|
|
2
3
|
/**
|
|
3
4
|
* Streaming log writer. Backed by a bounded in-memory buffer and a single
|
|
@@ -69,7 +70,7 @@ export class StreamingLogWriter {
|
|
|
69
70
|
await Promise.race([this.#flusherTask, timeout]);
|
|
70
71
|
timeoutController.abort();
|
|
71
72
|
if (timedOut) {
|
|
72
|
-
this.#logger.warn(
|
|
73
|
+
this.#logger.warn('log_writer drain timed out', { execution_id: this.#executionId, timeout_ms: this.#opts.shutdownTimeoutMs });
|
|
73
74
|
}
|
|
74
75
|
}
|
|
75
76
|
#wake() {
|
|
@@ -124,7 +125,10 @@ export class StreamingLogWriter {
|
|
|
124
125
|
}
|
|
125
126
|
}
|
|
126
127
|
catch (err) {
|
|
127
|
-
this.#logger.error(
|
|
128
|
+
this.#logger.error('log_writer flusher crashed', {
|
|
129
|
+
error: String(err),
|
|
130
|
+
execution_id: this.#executionId,
|
|
131
|
+
});
|
|
128
132
|
}
|
|
129
133
|
finally {
|
|
130
134
|
// Reject any remaining flushers so callers don't hang.
|
|
@@ -145,7 +149,17 @@ export class StreamingLogWriter {
|
|
|
145
149
|
await this.#client.pushEvents(this.#executionId, chunk, ac.signal);
|
|
146
150
|
}
|
|
147
151
|
catch (err) {
|
|
148
|
-
|
|
152
|
+
if (isOwnershipDenied(err)) {
|
|
153
|
+
// Permanent (#436/#437) — every later batch is lost too, so the
|
|
154
|
+
// operator must see this rather than wonder why the execution
|
|
155
|
+
// produced no output.
|
|
156
|
+
this.#logger.error('log_writer: batch POST refused with 403 Forbidden — this runner\'s credential ' +
|
|
157
|
+
'does not own its runner_id, so no log event will reach the server. Give the ' +
|
|
158
|
+
'runner its own runner_id, or release the existing binding with ' +
|
|
159
|
+
'DELETE /v1/runners/{id}', { error: String(err), execution_id: this.#executionId, dropped: chunk.length });
|
|
160
|
+
continue;
|
|
161
|
+
}
|
|
162
|
+
this.#logger.warn('log_writer: batch POST failed — events dropped', { error: String(err), execution_id: this.#executionId, dropped: chunk.length });
|
|
149
163
|
}
|
|
150
164
|
}
|
|
151
165
|
}
|
package/dist/log-writer.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"log-writer.js","sourceRoot":"","sources":["../src/log-writer.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"log-writer.js","sourceRoot":"","sources":["../src/log-writer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAqB,iBAAiB,EAAE,MAAM,aAAa,CAAC;AACnE,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAiB,MAAM,eAAe,CAAC;AAoB/D;;;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BACD,IAAI,CAAC,OAAO,CAAC,IAAI,CACf,gDAAgD,EAChD,EAAE,KAAK,EAAE,MAAM,CAAC,GAAG,CAAC,EAAE,YAAY,EAAE,IAAI,CAAC,YAAY,EAAE,OAAO,EAAE,KAAK,CAAC,MAAM,EAAE,CAC/E,CAAC;YACJ,CAAC;QACH,CAAC;IACH,CAAC;CACF"}
|
package/dist/logger.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../src/logger.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../src/logger.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAGpD,MAAM,MAAM,QAAQ,GAAG,cAAc,CAAC;AAEtC,MAAM,WAAW,MAAM;IACrB,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC;IAC/D,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC;IAC/D,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC;IAC9D,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC;IAC9D,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC;CAChE;AAUD;;;;;;;GAOG;AACH,wBAAgB,aAAa,CAAC,QAAQ,GAAE,QAAiB,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,CA+BlF;AAED,0DAA0D;AAC1D,eAAO,MAAM,UAAU,EAAE,MAMxB,CAAC;AAEF;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CASjF"}
|
package/dist/logger.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { escapeControlChars } from './sanitize.js';
|
|
1
2
|
const ORDER = {
|
|
2
3
|
trace: 0,
|
|
3
4
|
debug: 1,
|
|
@@ -19,9 +20,16 @@ export function consoleLogger(minLevel = 'warn', prefix) {
|
|
|
19
20
|
const emit = (level, message, fields) => {
|
|
20
21
|
if (ORDER[level] < threshold)
|
|
21
22
|
return;
|
|
23
|
+
// The message is escaped before it reaches the console: it is the one part
|
|
24
|
+
// of a record that is plain text, and a handler's exception message — or,
|
|
25
|
+
// before #441, a server-supplied identifier — can carry CRLF or ANSI
|
|
26
|
+
// escapes. `fields` needs no such treatment because JSON.stringify already
|
|
27
|
+
// escapes the C0 range, ESC included. This mirrors Go, whose slog handlers
|
|
28
|
+
// escape control characters in every rendered value.
|
|
29
|
+
const safe = escapeControlChars(message);
|
|
22
30
|
const line = fields && Object.keys(fields).length > 0
|
|
23
|
-
? `${tag}${level}: ${
|
|
24
|
-
: `${tag}${level}: ${
|
|
31
|
+
? `${tag}${level}: ${safe} ${JSON.stringify(fields)}`
|
|
32
|
+
: `${tag}${level}: ${safe}`;
|
|
25
33
|
// Map to console method, but funnel everything to stderr for warn/error
|
|
26
34
|
// so application stdout stays clean for actual job output.
|
|
27
35
|
// eslint-disable-next-line no-console
|
package/dist/logger.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logger.js","sourceRoot":"","sources":["../src/logger.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"logger.js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