@procedures/client 0.42.0 → 0.44.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 +22 -0
- package/dist/.tsbuildinfo +1 -1
- package/dist/adapters/http/server/transport.d.ts +2 -0
- package/dist/adapters/http/server/transport.d.ts.map +1 -1
- package/dist/adapters/http/server/transport.js +8 -3
- package/dist/adapters/http/server/transport.js.map +1 -1
- package/dist/adapters/http/server/types.d.ts +6 -0
- package/dist/adapters/http/server/types.d.ts.map +1 -1
- package/dist/adapters/sequence.d.ts +4 -0
- package/dist/adapters/sequence.d.ts.map +1 -1
- package/dist/adapters/sequence.js +7 -1
- package/dist/adapters/sequence.js.map +1 -1
- package/dist/adapters/websocket/server/transport.d.ts +2 -0
- package/dist/adapters/websocket/server/transport.d.ts.map +1 -1
- package/dist/adapters/websocket/server/transport.js +13 -8
- package/dist/adapters/websocket/server/transport.js.map +1 -1
- package/dist/adapters/websocket/server/types.d.ts +6 -0
- package/dist/adapters/websocket/server/types.d.ts.map +1 -1
- package/dist/adapters/websocket/shared/rpc.d.ts +3 -0
- package/dist/adapters/websocket/shared/rpc.d.ts.map +1 -1
- package/dist/adapters/websocket/shared/rpc.js +1 -1
- package/dist/adapters/websocket/shared/rpc.js.map +1 -1
- package/dist/browser.d.ts +3 -1
- package/dist/browser.d.ts.map +1 -1
- package/dist/browser.js +2 -0
- package/dist/browser.js.map +1 -1
- package/dist/logger.d.ts +36 -0
- package/dist/logger.d.ts.map +1 -0
- package/dist/logger.js +40 -0
- package/dist/logger.js.map +1 -0
- package/dist/server/error-policy.d.ts +3 -3
- package/dist/server/error-policy.d.ts.map +1 -1
- package/dist/server/procedure-server.d.ts +4 -3
- package/dist/server/procedure-server.d.ts.map +1 -1
- package/dist/server/procedure-server.js +5 -2
- package/dist/server/procedure-server.js.map +1 -1
- package/dist/server/server.d.ts +24 -4
- package/dist/server/server.d.ts.map +1 -1
- package/dist/server/server.js +39 -9
- package/dist/server/server.js.map +1 -1
- package/dist/server/types.d.ts +6 -0
- package/dist/server/types.d.ts.map +1 -1
- package/dist/server/types.js.map +1 -1
- package/package.json +2 -2
- package/src/adapters/http/server/transport.ts +8 -5
- package/src/adapters/http/server/types.ts +7 -0
- package/src/adapters/sequence.ts +6 -1
- package/src/adapters/websocket/server/transport.ts +14 -9
- package/src/adapters/websocket/server/types.ts +6 -0
- package/src/adapters/websocket/shared/rpc.ts +4 -1
- package/src/browser.ts +4 -1
- package/src/logger.ts +52 -0
- package/src/server/error-policy.ts +3 -3
- package/src/server/procedure-server.ts +15 -5
- package/src/server/server.ts +54 -12
- package/src/server/types.ts +6 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.js","sourceRoot":"","sources":["../../src/server/server.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAYH,OAAO,EAAE,oBAAoB,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAC/D,OAAO,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AACjD,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,eAAe,EAAE,UAAU,EAAE,UAAU,EAAkE,MAAM,mBAAmB,CAAC;AACjK,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"server.js","sourceRoot":"","sources":["../../src/server/server.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAYH,OAAO,EAAE,oBAAoB,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAC/D,OAAO,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AACjD,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,eAAe,EAAE,UAAU,EAAE,UAAU,EAAkE,MAAM,mBAAmB,CAAC;AACjK,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,cAAc,EAA+B,MAAM,cAAc,CAAC;AAC3E,OAAO,EAAE,UAAU,EAAE,MAAM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AAE,CAAC;YACjC,OAAO;gBACL,EAAE;gBACF,MAAM,EAAE;oBACN,IAAI,EAAE,OAAO;oBACb,IAAI,EAAE,KAAK,CAAC,IAAI;oBAChB,OAAO,EAAE,KAAK,CAAC,OAAO;oBACtB,SAAS,EAAE,KAAK,CAAC,SAAS;iBAC3B;gBACD,QAAQ,EAAE,EAAE;aACb,CAAC;QACJ,CAAC;QAED,6FAA6F;QAC7F,kDAAkD;QAClD,OAAO;YACL,EAAE;YACF,MAAM,EAAE;gBACN,IAAI,EAAE,OAAO;gBACb,IAAI,EAAE,gBAAgB;gBACtB,OAAO,EAAE,KAAK,CAAC,OAAO,IAAI,uBAAuB;gBACjD,SAAS,EAAE,KAAK;aACjB;YACD,QAAQ,EAAE,EAAE;SACb,CAAC;IACJ,CAAC;CACF"}
|
package/dist/server/types.d.ts
CHANGED
|
@@ -9,6 +9,7 @@ import type { ReportProgress } from "../procedures/progress.js";
|
|
|
9
9
|
import type { Metadata, Status, Method } from "../client/types.js";
|
|
10
10
|
import type { CapabilityRequest } from "../procedures/types.js";
|
|
11
11
|
import type { ExposedError } from "./error-policy.js";
|
|
12
|
+
import type { Logger } from "../logger.js";
|
|
12
13
|
export type { Method };
|
|
13
14
|
/**
|
|
14
15
|
* Server request in unified RPC format.
|
|
@@ -221,6 +222,11 @@ export interface RequestHandler {
|
|
|
221
222
|
* it. Absent: the handler examines each call, and the face refuses no request before its calls.
|
|
222
223
|
*/
|
|
223
224
|
admission?(credentials: Credentials): Promise<Admission>;
|
|
225
|
+
/**
|
|
226
|
+
* The logger of the handler (CLI-87). A face writes its log lines to it, unless the options of the
|
|
227
|
+
* face give a logger. `Server` has it. Absent: the face writes to the console.
|
|
228
|
+
*/
|
|
229
|
+
readonly logger?: Logger | undefined;
|
|
224
230
|
}
|
|
225
231
|
/**
|
|
226
232
|
* The result of `admission()` of a request handler (CLI-2b). A request that passes gets its
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/server/types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AACtD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAChE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AACnE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAChE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/server/types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AACtD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAChE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AACnE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAChE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACtD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAI3C,YAAY,EAAE,MAAM,EAAE,CAAC;AAEvB;;;GAGG;AACH,MAAM,WAAW,aAAa,CAAC,IAAI,GAAG,OAAO;IAC3C,mDAAmD;IACnD,EAAE,EAAE,MAAM,CAAC;IAEX,+CAA+C;IAC/C,MAAM,EAAE,MAAM,CAAC;IAEf,sBAAsB;IACtB,OAAO,EAAE,IAAI,CAAC;IAEd,qDAAqD;IACrD,QAAQ,EAAE,QAAQ,CAAC;IAEnB;;;;OAIG;IACH,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAE5B;;;OAGG;IACH,QAAQ,CAAC,EAAE,cAAc,GAAG,SAAS,CAAC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AGG;IACH,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IAEtB;;OAEG;IACH,SAAS,IAAI,OAAO,CAAC;CACtB;AAED;;GAEG;AACH,qBAAa,oBAAqB,SAAQ,KAAK;IAC7C,YAAY,MAAM,EAAE,MAAM,EAOzB;CACF;AAED;;;GAGG;AACH,qBAAa,WAAY,SAAQ,KAAK;aAGlB,IAAI,EAAE,MAAM;aACZ,SAAS,EAAE,OAAO;IAHpC,YACE,OAAO,EAAE,MAAM,EACC,IAAI,GAAE,MAAyB,EAC/B,SAAS,GAAE,OAAe,EAI3C;CACF"}
|
package/dist/server/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/server/types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/server/types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAQH,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAmEzC;;;;GAIG;AACH,MAAM,CAAC,MAAM,YAAY,GAAkB,MAAM,CAAC,GAAG,CAAC,sCAAsC,CAAC,CAAC;AAsR9F;;GAEG;AACH,MAAM,OAAO,oBAAqB,SAAQ,KAAK;IAC7C,YAAY,MAAc;QACxB,KAAK,CACH,wBAAwB,UAAU,CAAC,MAAM,CAAC,GACxC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,MAAM,CAAC,OAAO,GAAG,CAAC,CAAC,CAAC,EAC7C,EAAE,CACH,CAAC;QACF,IAAI,CAAC,IAAI,GAAG,sBAAsB,CAAC;IACrC,CAAC;CACF;AAED;;;GAGG;AACH,MAAM,OAAO,WAAY,SAAQ,KAAK;IAGlB,IAAI;IACJ,SAAS;IAH3B,YACE,OAAe,EACC,IAAI,GAAW,gBAAgB,EAC/B,SAAS,GAAY,KAAK;QAE1C,KAAK,CAAC,OAAO,CAAC,CAAC;oBAHC,IAAI;yBACJ,SAAS;QAGzB,IAAI,CAAC,IAAI,GAAG,aAAa,CAAC;IAC5B,CAAC;CACF"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://json.schemastore.org/package",
|
|
3
3
|
"name": "@procedures/client",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.44.0",
|
|
5
5
|
"description": "Procedures as data for TypeScript: define typed procedures once and call them in process, over HTTP, WebSocket, the CLI or MCP. Streaming, middleware, retries, caching and a JSON program format.",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"rpc",
|
|
@@ -112,7 +112,7 @@
|
|
|
112
112
|
},
|
|
113
113
|
"dependencies": {
|
|
114
114
|
"@mark1russell7/algebra": "^0.8.0",
|
|
115
|
-
"@mark1russell7/coeval": "^0.
|
|
115
|
+
"@mark1russell7/coeval": "^0.9.0",
|
|
116
116
|
"@mark1russell7/quantity": "^0.2.0",
|
|
117
117
|
"@mark1russell7/service": "^0.6.0",
|
|
118
118
|
"@types/ws": "^8.18.1",
|
|
@@ -18,6 +18,7 @@ import { createPatternServerUrlStrategy } from "./strategies.js";
|
|
|
18
18
|
import { applyCors, corsOrigins, corsPolicy, type CorsPolicy } from "./cors.js";
|
|
19
19
|
import { createProcedureHandler, type NodeProcedureHandler } from "./handler.js";
|
|
20
20
|
import { isBatchRequest } from "./batch.js";
|
|
21
|
+
import { writeLog, type Logger } from "../../../logger.js";
|
|
21
22
|
|
|
22
23
|
/**
|
|
23
24
|
* This function gives the route of the procedure handler: each path under the base path. With
|
|
@@ -61,9 +62,12 @@ export class HttpServerTransport implements ServerTransport {
|
|
|
61
62
|
/** The CORS of the app, or undefined when it is off */
|
|
62
63
|
private readonly cors: CorsPolicy | undefined;
|
|
63
64
|
private stopped = false;
|
|
65
|
+
/** The logger of the start and the stop: the option, or the logger of the server (CLI-87) */
|
|
66
|
+
private readonly logger: Logger | undefined;
|
|
64
67
|
|
|
65
68
|
constructor(server: RequestHandler, options: HttpServerTransportOptions = {}) {
|
|
66
69
|
const basePath = options.basePath ?? "/api";
|
|
70
|
+
this.logger = options.logger ?? server.logger;
|
|
67
71
|
this.options = {
|
|
68
72
|
port: options.port ?? 3000,
|
|
69
73
|
// Loopback by default (see BUGS-2026-07 H19)
|
|
@@ -159,7 +163,7 @@ export class HttpServerTransport implements ServerTransport {
|
|
|
159
163
|
// If an HTTP server was provided, use it (don't create or listen)
|
|
160
164
|
if (this.options.httpServer) {
|
|
161
165
|
this.httpServer = this.options.httpServer;
|
|
162
|
-
|
|
166
|
+
writeLog(this.logger, "info", "Using existing HTTP server", { transport: this.name }, `[${this.name}] Using existing HTTP server`);
|
|
163
167
|
return Promise.resolve();
|
|
164
168
|
}
|
|
165
169
|
|
|
@@ -170,9 +174,8 @@ export class HttpServerTransport implements ServerTransport {
|
|
|
170
174
|
this.httpServer = server;
|
|
171
175
|
|
|
172
176
|
server.listen(this.options.port, this.options.host, () => {
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
);
|
|
177
|
+
const url = `http://${this.options.host}:${this.port() ?? this.options.port}`;
|
|
178
|
+
writeLog(this.logger, "info", "Server listening", { transport: this.name, url }, `[${this.name}] Server listening on ${url}`);
|
|
176
179
|
resolve();
|
|
177
180
|
});
|
|
178
181
|
|
|
@@ -203,7 +206,7 @@ export class HttpServerTransport implements ServerTransport {
|
|
|
203
206
|
if (err) {
|
|
204
207
|
reject(err);
|
|
205
208
|
} else {
|
|
206
|
-
|
|
209
|
+
writeLog(this.logger, "info", "Server stopped", { transport: this.name }, `[${this.name}] Server stopped`);
|
|
207
210
|
resolve();
|
|
208
211
|
}
|
|
209
212
|
});
|
|
@@ -10,6 +10,7 @@ import type { Method } from "../../../client/types.js";
|
|
|
10
10
|
import type { BrowserGuardOptions } from "../../../server/browser-guard.js";
|
|
11
11
|
import type { Clock } from "../../../clock.js";
|
|
12
12
|
import type { Duration } from "../../../duration.js";
|
|
13
|
+
import type { Logger } from "../../../logger.js";
|
|
13
14
|
import type { Addressing } from "./addressing.js";
|
|
14
15
|
import type { HandlerBatchOptions } from "./batch.js";
|
|
15
16
|
import type { UrlStrategyRequest } from "./strategies.js";
|
|
@@ -131,4 +132,10 @@ export interface HttpServerTransportOptions extends BrowserGuardOptions {
|
|
|
131
132
|
allowedHeaders?: string[];
|
|
132
133
|
credentials?: boolean;
|
|
133
134
|
};
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* The logger of the transport (CLI-87): the lines of its start and its stop go to it. The default
|
|
138
|
+
* is the logger of the server. Without both, each line goes to `console.log` as before.
|
|
139
|
+
*/
|
|
140
|
+
logger?: Logger | undefined;
|
|
134
141
|
}
|
package/src/adapters/sequence.ts
CHANGED
|
@@ -14,6 +14,8 @@
|
|
|
14
14
|
* so the reader skips it before the check.
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
|
+
import { writeLog, type Logger } from "../logger.js";
|
|
18
|
+
|
|
17
19
|
/**
|
|
18
20
|
* The metadata key of a stream item after a gap: the number of frames that did not arrive
|
|
19
21
|
* immediately before this item. The receiver sets it. It does not cross the wire.
|
|
@@ -32,6 +34,9 @@ export const STREAM_ITEM_METADATA_KEY = "stream";
|
|
|
32
34
|
export class StreamSequence {
|
|
33
35
|
private last = 0;
|
|
34
36
|
|
|
37
|
+
/** The logger of the warning of a gap (CLI-87). Without it, the warning goes to `console.warn`. */
|
|
38
|
+
constructor(private readonly logger?: Logger | undefined) {}
|
|
39
|
+
|
|
35
40
|
/**
|
|
36
41
|
* This function examines the `seq` of a frame. It gives -1 for a frame to drop: its `seq` is
|
|
37
42
|
* not above the last one. Else it gives the number of frames that did not arrive before this
|
|
@@ -42,7 +47,7 @@ export class StreamSequence {
|
|
|
42
47
|
if (seq <= this.last) return -1;
|
|
43
48
|
const gap = seq - this.last - 1;
|
|
44
49
|
this.last = seq;
|
|
45
|
-
if (gap > 0)
|
|
50
|
+
if (gap > 0) writeLog(this.logger, "warn", "Frames lost", { requestId: id, seq, lost: gap }, `[stream] Frames lost before seq ${seq} of the call ${id}: ${gap}`);
|
|
46
51
|
return gap;
|
|
47
52
|
}
|
|
48
53
|
}
|
|
@@ -33,6 +33,7 @@ import { attachUpgradeTarget, refuseUpgrade } from "./upgrade-router.js";
|
|
|
33
33
|
import { realClock, type Cancel } from "../../../clock.js";
|
|
34
34
|
import { PROTOCOL_VERSION, protocolVersionOf } from "../../../protocol.js";
|
|
35
35
|
import { TIMER_DEFAULTS } from "../../../timers.js";
|
|
36
|
+
import { writeLog, type Logger } from "../../../logger.js";
|
|
36
37
|
import {
|
|
37
38
|
remoteEvents,
|
|
38
39
|
subscribeRemote,
|
|
@@ -75,7 +76,7 @@ export class WebSocketServerTransport implements ServerTransport {
|
|
|
75
76
|
private options: Required<
|
|
76
77
|
Omit<
|
|
77
78
|
WebSocketServerTransportOptions,
|
|
78
|
-
"server" | "authenticate" | "onConnection" | "allowedOrigins" | "allowedHosts" | "heartbeat" | "reverseRequestTimeout" | "secretHeaders"
|
|
79
|
+
"server" | "authenticate" | "onConnection" | "allowedOrigins" | "allowedHosts" | "heartbeat" | "reverseRequestTimeout" | "secretHeaders" | "logger"
|
|
79
80
|
>
|
|
80
81
|
> & {
|
|
81
82
|
server: WebSocketServerTransportOptions["server"];
|
|
@@ -93,6 +94,8 @@ export class WebSocketServerTransport implements ServerTransport {
|
|
|
93
94
|
/** True: a cookie of an upgrade is trusted only from a named origin, with or without an auth path */
|
|
94
95
|
private cookiesNamed = false;
|
|
95
96
|
private server: RequestHandler;
|
|
97
|
+
/** The logger of the lines of the transport: the option, or the logger of the server (CLI-87) */
|
|
98
|
+
private readonly logger: Logger | undefined;
|
|
96
99
|
private connections: Set<WebSocket> = new Set();
|
|
97
100
|
|
|
98
101
|
/** The time until the first frame of a call to a client, in milliseconds (R24) */
|
|
@@ -128,6 +131,7 @@ export class WebSocketServerTransport implements ServerTransport {
|
|
|
128
131
|
|
|
129
132
|
constructor(server: RequestHandler, options: WebSocketServerTransportOptions = {}) {
|
|
130
133
|
this.server = server;
|
|
134
|
+
this.logger = options.logger ?? server.logger;
|
|
131
135
|
this.options = {
|
|
132
136
|
server: options.server,
|
|
133
137
|
path: options.path ?? "/ws",
|
|
@@ -161,7 +165,7 @@ export class WebSocketServerTransport implements ServerTransport {
|
|
|
161
165
|
for (const ws of this.connections) {
|
|
162
166
|
const missed = this.missedPongs.get(ws) ?? 0;
|
|
163
167
|
if (missed >= this.heartbeat.misses) {
|
|
164
|
-
|
|
168
|
+
writeLog(this.logger, "error", "A connection missed its pongs: closing it", { transport: this.name, missed }, `[${this.name}] A connection missed ${missed} pongs: closing it`);
|
|
165
169
|
ws.terminate();
|
|
166
170
|
continue;
|
|
167
171
|
}
|
|
@@ -217,7 +221,7 @@ export class WebSocketServerTransport implements ServerTransport {
|
|
|
217
221
|
try {
|
|
218
222
|
callback(await this.options.authenticate(req));
|
|
219
223
|
} catch (error) {
|
|
220
|
-
|
|
224
|
+
writeLog(this.logger, "error", "Authentication error", { transport: this.name, path: this.options.path, error }, "[WebSocket] Authentication error:", error);
|
|
221
225
|
callback(false);
|
|
222
226
|
}
|
|
223
227
|
},
|
|
@@ -235,7 +239,7 @@ export class WebSocketServerTransport implements ServerTransport {
|
|
|
235
239
|
this.heartbeatTimer.unref?.();
|
|
236
240
|
}
|
|
237
241
|
|
|
238
|
-
|
|
242
|
+
writeLog(this.logger, "info", "WebSocket server listening", { transport: this.name, path: this.options.path }, `[${this.name}] WebSocket server listening on ${this.options.path}`);
|
|
239
243
|
}
|
|
240
244
|
|
|
241
245
|
async stop(): Promise<void> {
|
|
@@ -267,7 +271,7 @@ export class WebSocketServerTransport implements ServerTransport {
|
|
|
267
271
|
if (err) {
|
|
268
272
|
reject(err);
|
|
269
273
|
} else {
|
|
270
|
-
|
|
274
|
+
writeLog(this.logger, "info", "WebSocket server stopped", { transport: this.name, path: this.options.path }, `[${this.name}] WebSocket server stopped`);
|
|
271
275
|
this.wss = null;
|
|
272
276
|
resolve();
|
|
273
277
|
}
|
|
@@ -409,6 +413,7 @@ export class WebSocketServerTransport implements ServerTransport {
|
|
|
409
413
|
requestTimeoutMs: this.reverseRequestTimeoutMs,
|
|
410
414
|
streamWindow: 64,
|
|
411
415
|
idPrefix: "r:",
|
|
416
|
+
logger: this.logger,
|
|
412
417
|
}),
|
|
413
418
|
});
|
|
414
419
|
|
|
@@ -422,7 +427,7 @@ export class WebSocketServerTransport implements ServerTransport {
|
|
|
422
427
|
try {
|
|
423
428
|
handler(trackedConnection);
|
|
424
429
|
} catch (error) {
|
|
425
|
-
|
|
430
|
+
writeLog(this.logger, "error", "Connect handler error", { transport: this.name, connectionId, error }, "[WebSocket] Connect handler error:", error);
|
|
426
431
|
}
|
|
427
432
|
}
|
|
428
433
|
|
|
@@ -434,7 +439,7 @@ export class WebSocketServerTransport implements ServerTransport {
|
|
|
434
439
|
try {
|
|
435
440
|
await this.handleMessage(ws, data, req, connectionId);
|
|
436
441
|
} catch (error) {
|
|
437
|
-
|
|
442
|
+
writeLog(this.logger, "error", "Message handling error", { transport: this.name, connectionId, error }, "[WebSocket] Message handling error:", error);
|
|
438
443
|
this.sendError(ws, "unknown", "Internal server error");
|
|
439
444
|
}
|
|
440
445
|
});
|
|
@@ -457,7 +462,7 @@ export class WebSocketServerTransport implements ServerTransport {
|
|
|
457
462
|
try {
|
|
458
463
|
handler(conn);
|
|
459
464
|
} catch (error) {
|
|
460
|
-
|
|
465
|
+
writeLog(this.logger, "error", "Disconnect handler error", { transport: this.name, connectionId, error }, "[WebSocket] Disconnect handler error:", error);
|
|
461
466
|
}
|
|
462
467
|
}
|
|
463
468
|
}
|
|
@@ -467,7 +472,7 @@ export class WebSocketServerTransport implements ServerTransport {
|
|
|
467
472
|
// cleanup and the disconnect event (deep dive TRN-16: before, this handler removed the
|
|
468
473
|
// connection first, so the close handler found nothing and sent no disconnect event).
|
|
469
474
|
ws.on("error", (error: Error) => {
|
|
470
|
-
|
|
475
|
+
writeLog(this.logger, "error", "Connection error", { transport: this.name, connectionId, error }, "[WebSocket] Connection error:", error);
|
|
471
476
|
});
|
|
472
477
|
}
|
|
473
478
|
|
|
@@ -9,6 +9,7 @@ import type { Server as HttpServer } from "http";
|
|
|
9
9
|
import type { WebSocket } from "ws";
|
|
10
10
|
import type { BrowserGuardOptions } from "../../../server/browser-guard.js";
|
|
11
11
|
import type { Duration } from "../../../duration.js";
|
|
12
|
+
import type { Logger } from "../../../logger.js";
|
|
12
13
|
|
|
13
14
|
/**
|
|
14
15
|
* WebSocket authentication handler.
|
|
@@ -99,6 +100,11 @@ export interface WebSocketServerTransportOptions extends Omit<BrowserGuardOption
|
|
|
99
100
|
* `Proxy-Authorization`, `Cookie` and `X-Api-Key` are always secret.
|
|
100
101
|
*/
|
|
101
102
|
secretHeaders?: readonly string[] | undefined;
|
|
103
|
+
/**
|
|
104
|
+
* The logger of the transport (CLI-87): the lines of its start, its stop, its heartbeat and its
|
|
105
|
+
* errors go to it. The default is the logger of the server. Without both, each line goes to the console as before.
|
|
106
|
+
*/
|
|
107
|
+
logger?: Logger | undefined;
|
|
102
108
|
}
|
|
103
109
|
|
|
104
110
|
/**
|
|
@@ -19,6 +19,7 @@ import { StreamSequence, gapOf, itemMetadata } from "../../sequence.js";
|
|
|
19
19
|
import { DELIVERY_METADATA_KEY } from "../../../client/middleware/items.js";
|
|
20
20
|
import { errorCodeOf, foldedErrorCode, retryableOf } from "../../../protocol.js";
|
|
21
21
|
import { lastResortError } from "../../../server/last-resort.js";
|
|
22
|
+
import type { Logger } from "../../../logger.js";
|
|
22
23
|
|
|
23
24
|
/**
|
|
24
25
|
* A queue of response items that one reader takes in order: push, then end or fail. The reader
|
|
@@ -168,6 +169,8 @@ export interface OutgoingCallsOptions {
|
|
|
168
169
|
streamWindow: number;
|
|
169
170
|
/** The start of the wire id of each call: the two sides use different ones. */
|
|
170
171
|
idPrefix: string;
|
|
172
|
+
/** The logger of the warning of a stream gap (CLI-87). Without it, the warning goes to the console. */
|
|
173
|
+
logger?: Logger | undefined;
|
|
171
174
|
}
|
|
172
175
|
|
|
173
176
|
/** The calls that this side sends on one socket. */
|
|
@@ -201,7 +204,7 @@ export class OutgoingCalls {
|
|
|
201
204
|
const wireId = `${this.options.idPrefix}${message.id}~${++this.seq}`;
|
|
202
205
|
const window = this.options.streamWindow;
|
|
203
206
|
const queue = new ItemQueue<ResponseItem<unknown>>();
|
|
204
|
-
const pending: PendingCall = { messageId: message.id, queue, order: new StreamSequence() };
|
|
207
|
+
const pending: PendingCall = { messageId: message.id, queue, order: new StreamSequence(this.options.logger) };
|
|
205
208
|
const limited = Number.isFinite(this.options.requestTimeoutMs) && this.options.requestTimeoutMs > 0;
|
|
206
209
|
if (limited) pending.timeout = setTimeout(() => {
|
|
207
210
|
if (this.pending.get(wireId) !== pending) return;
|
package/src/browser.ts
CHANGED
|
@@ -77,11 +77,14 @@ export {
|
|
|
77
77
|
// The server transports are Node only: the root entry point exports them.
|
|
78
78
|
// ============================================================================
|
|
79
79
|
export { Server } from "./server/server.js";
|
|
80
|
-
export type { ServerOptions } from "./server/server.js";
|
|
80
|
+
export type { ServerOptions, ServerErrorContext } from "./server/server.js";
|
|
81
81
|
// The error policy of a server: what an error tells the caller (roadmap CLI-80)
|
|
82
82
|
export type { ServerErrorPolicy, ExposedError, ErrorCall } from "./server/error-policy.js";
|
|
83
83
|
export { exposeError, lastResortError, HIDDEN_ERROR_MESSAGE, DEFAULT_KEPT_METADATA } from "./server/error-policy.js";
|
|
84
84
|
export { ProcedureServer, createProcedureServer, tokenMatches } from "./server/procedure-server.js";
|
|
85
|
+
// The logger port of the server side, in the shape of the Logger of the runner (CLI-87)
|
|
86
|
+
export { CONSOLE_LOGGER, writeLog } from "./logger.js";
|
|
87
|
+
export type { Logger, LogLevel, LogFields } from "./logger.js";
|
|
85
88
|
export { STREAM_METADATA_KEY, isUnboundedStream } from "./server/stream-metadata.js";
|
|
86
89
|
// The credentials of a network request (roadmap R18), and the parts that a request hook reads (CLI-2a)
|
|
87
90
|
export { credentialsOf, bearerOf, withoutSecretHeaders, cookiesOf, requestCredentials, LOCAL_CREDENTIALS, isLocalCredentials } from "./server/request-auth.js";
|
package/src/logger.ts
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The logger port of the server side (CLI-87): the server, the host and each server transport
|
|
3
|
+
* write their log lines to it.
|
|
4
|
+
*
|
|
5
|
+
* The port has the shape of the `Logger` of `@mark1russell7/service`: one method `log(level,
|
|
6
|
+
* message, fields)`. The type is structural, so the engine imports no code of the runner (CLI-5).
|
|
7
|
+
* Thus one object goes to `run({ logger })` of the runner and to `createProcedureHost({ logger })`.
|
|
8
|
+
*
|
|
9
|
+
* - The message tells what occurred. The fields hold the context: the transport, the path, the
|
|
10
|
+
* request id and the error.
|
|
11
|
+
* - Without a logger, each line goes to the console, with the same method and the same arguments
|
|
12
|
+
* as before. `CONSOLE_LOGGER` is the console adapter of the port, for the hooks that get a logger.
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
/** The levels of a log line, from the least to the most severe. They are the levels of the runner. */
|
|
16
|
+
export type LogLevel = "debug" | "info" | "warn" | "error";
|
|
17
|
+
|
|
18
|
+
/** The context of a log line: the transport, the path, the request id, the error. */
|
|
19
|
+
export type LogFields = Readonly<Record<string, unknown>>;
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* The logger of a server, a host or a server transport. An adapter to another logger is a few
|
|
23
|
+
* lines, for example `{ log: (level, message, fields) => app[level](fields, message) }`.
|
|
24
|
+
*/
|
|
25
|
+
export interface Logger {
|
|
26
|
+
log(level: LogLevel, message: string, fields: LogFields): void;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/** The method of the console for each level: `info` writes with `console.log`. */
|
|
30
|
+
const CONSOLE_METHODS = Object.freeze({ debug: "debug", info: "log", warn: "warn", error: "error" } as const);
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* The console adapter of the port. It writes the message and then the fields with the console method
|
|
34
|
+
* of the level: `console.debug`, `console.log`, `console.warn` or `console.error`. It leaves out empty fields.
|
|
35
|
+
*/
|
|
36
|
+
export const CONSOLE_LOGGER: Logger = Object.freeze({
|
|
37
|
+
log(level: LogLevel, message: string, fields: LogFields): void {
|
|
38
|
+
const method = console[CONSOLE_METHODS[level]];
|
|
39
|
+
if (Object.keys(fields).length > 0) method(message, fields);
|
|
40
|
+
else method(message);
|
|
41
|
+
},
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* This function writes one log line. With a logger, the logger gets the level, the message and the
|
|
46
|
+
* fields. Without a logger, the console method of the level gets `consoleArgs`: the line as before.
|
|
47
|
+
* A face of another package uses it too, so its default output stays the same.
|
|
48
|
+
*/
|
|
49
|
+
export function writeLog(logger: Logger | undefined, level: LogLevel, message: string, fields: LogFields, ...consoleArgs: unknown[]): void {
|
|
50
|
+
if (logger) logger.log(level, message, fields);
|
|
51
|
+
else console[CONSOLE_METHODS[level]](...consoleArgs);
|
|
52
|
+
}
|
|
@@ -64,8 +64,8 @@ export interface ServerErrorPolicy {
|
|
|
64
64
|
* `INTERNAL_ERROR` with the message `"internal error"` and its real retryable flag, with
|
|
65
65
|
* only the metadata keys of `keepMetadata`. The codes `INTERNAL_ERROR`, `HANDLER_ERROR`, `UNKNOWN`,
|
|
66
66
|
* `OUTPUT_VALIDATION_ERROR` and `NO_OUTPUT` tell of a failure of the server, not of a
|
|
67
|
-
* refusal, so their message is hidden too. The server gives the real error to its `onError`
|
|
68
|
-
*
|
|
67
|
+
* refusal, so their message is hidden too. The server gives the real error one time to its `onError`
|
|
68
|
+
* and its `logger`, or to `console.error` without them.
|
|
69
69
|
*/
|
|
70
70
|
readonly expose?: "all" | "coded" | undefined;
|
|
71
71
|
/**
|
|
@@ -108,7 +108,7 @@ export function markLogged(error: unknown): void {
|
|
|
108
108
|
if (typeof error === "object" && error !== null) LOGGED.add(error);
|
|
109
109
|
}
|
|
110
110
|
|
|
111
|
-
/** The logger of the hidden errors: the hook `onError` of the server, or `console.error`. */
|
|
111
|
+
/** The logger of the hidden errors: the hook `onError` and the `logger` of the server, or `console.error`. */
|
|
112
112
|
export type HiddenErrorLog = (error: unknown, request: ServerRequest<unknown> | undefined) => void;
|
|
113
113
|
|
|
114
114
|
/** This function gives an error to the logger, when the logger did not get it before. */
|
|
@@ -10,7 +10,7 @@ import { errorResponse } from "./error-response.js";
|
|
|
10
10
|
|
|
11
11
|
export { errorResponse };
|
|
12
12
|
import type { Admission, AmbientCredentials, Credentials, Method, Principal, PrincipalOf, RequestIdentity, ServerHandler, ServerRequest, ServerResponse } from "./types.js";
|
|
13
|
-
import { methodToPath, pathToMethod } from "./method.js";
|
|
13
|
+
import { methodName, methodToPath, pathToMethod } from "./method.js";
|
|
14
14
|
import { isLocalCredentials } from "./request-auth.js";
|
|
15
15
|
import { STREAM_METADATA_KEY } from "./stream-metadata.js";
|
|
16
16
|
import type {
|
|
@@ -39,6 +39,7 @@ import type { NarrowingNote } from "../procedures/narrowing.js";
|
|
|
39
39
|
import type { ServerDebugReport } from "./types.js";
|
|
40
40
|
import type { KeyedLimiter, LimiterStore } from "@mark1russell7/service/limiter";
|
|
41
41
|
import { callLimiter, limitedCall, rateLimitedResponse, type CallLimit, type CallLimiter } from "./limits.js";
|
|
42
|
+
import { writeLog } from "../logger.js";
|
|
42
43
|
|
|
43
44
|
// =============================================================================
|
|
44
45
|
// Types
|
|
@@ -195,9 +196,10 @@ export interface ProcedureServerOptions extends ServerOptions {
|
|
|
195
196
|
events?: EventPublisherOptions | EventPublisher | undefined;
|
|
196
197
|
|
|
197
198
|
/**
|
|
198
|
-
* The debug reports of the server. `true` writes each report
|
|
199
|
-
*
|
|
200
|
-
*
|
|
199
|
+
* The debug reports of the server. `true` writes each report to the `logger` at the level `debug`,
|
|
200
|
+
* or with `console.debug` without a logger (CLI-87). A function gets each report.
|
|
201
|
+
*
|
|
202
|
+
* The server reports each part of the narrowing of a call that has no effect (CLI-30). Such a part asks for more than the call holds, or it is not valid. The
|
|
201
203
|
* call goes on without that part. The server also reports a source that refuses the call.
|
|
202
204
|
* @default false
|
|
203
205
|
*/
|
|
@@ -492,7 +494,15 @@ export class ProcedureServer extends Server implements RepositoryProvider, StopP
|
|
|
492
494
|
typeof options.debug === "function"
|
|
493
495
|
? options.debug
|
|
494
496
|
: options.debug === true
|
|
495
|
-
? (report) =>
|
|
497
|
+
? (report) =>
|
|
498
|
+
// The logger of the server gets the report at the level debug (CLI-87)
|
|
499
|
+
writeLog(
|
|
500
|
+
options.logger,
|
|
501
|
+
"debug",
|
|
502
|
+
report.message,
|
|
503
|
+
{ topic: report.topic, requestId: report.requestId, procedure: methodName(report.method), ...(report.detail ? { detail: report.detail } : {}) },
|
|
504
|
+
`[ProcedureServer] ${report.topic} of ${report.requestId}: ${report.message}`,
|
|
505
|
+
)
|
|
496
506
|
: undefined;
|
|
497
507
|
// The limits of the calls: one keyed limiter for each limit, on the clock of the server (CLI-40)
|
|
498
508
|
this.callLimits = options.limits && options.limits.length > 0 ? callLimiter(options.limits, { clock: this.clock, stores: options.limitStores }) : undefined;
|
package/src/server/server.ts
CHANGED
|
@@ -19,6 +19,8 @@ import { HandlerNotFoundError, ServerError } from "./types.js";
|
|
|
19
19
|
import { compose } from "../middleware/index.js";
|
|
20
20
|
import { callOf, exposeError, exposedResponse, markLogged, policyActs, type ExposedError, type HiddenErrorLog, type ServerErrorPolicy } from "./error-policy.js";
|
|
21
21
|
import { withRealError } from "./error-response.js";
|
|
22
|
+
import { CONSOLE_LOGGER, type LogFields, type Logger } from "../logger.js";
|
|
23
|
+
import { methodName } from "./method.js";
|
|
22
24
|
|
|
23
25
|
/**
|
|
24
26
|
* Server configuration options.
|
|
@@ -34,9 +36,17 @@ export interface ServerOptions {
|
|
|
34
36
|
* Global error handler.
|
|
35
37
|
* Called when a handler throws an error. The error policy (`errors`) also gives it each hidden
|
|
36
38
|
* error one time. A last-resort error of a face that failed before it knew the call comes with
|
|
37
|
-
* `UNKNOWN_REQUEST`: a request with the id `"unknown"`.
|
|
39
|
+
* `UNKNOWN_REQUEST`: a request with the id `"unknown"`. The third argument gives the logger of
|
|
40
|
+
* the server: the option `logger`, or `CONSOLE_LOGGER` without it (CLI-87).
|
|
38
41
|
*/
|
|
39
|
-
onError?: (error: Error, request: ServerRequest) => void;
|
|
42
|
+
onError?: (error: Error, request: ServerRequest, context: ServerErrorContext) => void;
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* The logger of the server and of its faces (CLI-87). The server writes its log lines and its
|
|
46
|
+
* errors to it, also when `onError` gets them. A face that has no logger of its own uses this
|
|
47
|
+
* logger. Without it, each line goes to the console as before.
|
|
48
|
+
*/
|
|
49
|
+
logger?: Logger | undefined;
|
|
40
50
|
|
|
41
51
|
/**
|
|
42
52
|
* Request logger.
|
|
@@ -57,7 +67,7 @@ export interface ServerOptions {
|
|
|
57
67
|
* - `expose: "coded"`: an error with a known code (`isKnownErrorCode`) goes to the caller as it
|
|
58
68
|
* is, and so does an error with a code of `codes`. Each other error goes as `INTERNAL_ERROR`
|
|
59
69
|
* with the message `"internal error"` and its real retryable flag. The server gives the real
|
|
60
|
-
* error to `onError`
|
|
70
|
+
* error one time to `onError` and to the `logger`, or to `console.error` without them.
|
|
61
71
|
* - `map` runs first, with the real error of its own class. Its result goes to the caller as it
|
|
62
72
|
* is, with its `retryAfterMs`. `undefined` gives the error to `expose`.
|
|
63
73
|
* - The last-resort catch of each face applies the same policy (`exposeError`).
|
|
@@ -76,6 +86,12 @@ export interface ServerOptions {
|
|
|
76
86
|
errors?: ServerErrorPolicy | undefined;
|
|
77
87
|
}
|
|
78
88
|
|
|
89
|
+
/** The third argument of the hook `onError` of a server (CLI-87). */
|
|
90
|
+
export interface ServerErrorContext {
|
|
91
|
+
/** The logger of the server: the option `logger`, or `CONSOLE_LOGGER` without it. */
|
|
92
|
+
readonly logger: Logger;
|
|
93
|
+
}
|
|
94
|
+
|
|
79
95
|
/**
|
|
80
96
|
* Method matcher for handler registration.
|
|
81
97
|
* Can match exact methods or patterns.
|
|
@@ -97,6 +113,17 @@ interface HandlerEntry {
|
|
|
97
113
|
/** The request that `onError` gets for an error of a face that failed before it knew the call (CLI-80). */
|
|
98
114
|
const UNKNOWN_REQUEST: ServerRequest = { id: "unknown", method: { service: "", operation: "" }, payload: undefined, metadata: {} };
|
|
99
115
|
|
|
116
|
+
/** The fields of the log line of an error: the request id, the procedure, the transport and the error (CLI-87). */
|
|
117
|
+
function errorFields(request: ServerRequest | undefined, error: unknown): LogFields {
|
|
118
|
+
if (!request) return { error };
|
|
119
|
+
return {
|
|
120
|
+
requestId: request.id,
|
|
121
|
+
procedure: methodName(request.method),
|
|
122
|
+
...(request.transport !== undefined ? { transport: request.transport } : {}),
|
|
123
|
+
error,
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
|
|
100
127
|
/**
|
|
101
128
|
* Universal RPC server.
|
|
102
129
|
*
|
|
@@ -247,13 +274,28 @@ export class Server {
|
|
|
247
274
|
return exposeError(this.options.errors, error, callOf(request), (real) => this.hiddenErrorLog(real, request), raw);
|
|
248
275
|
}
|
|
249
276
|
|
|
250
|
-
/**
|
|
277
|
+
/**
|
|
278
|
+
* The logger of the server and of its faces: the option `logger`, or undefined without it. A face
|
|
279
|
+
* writes to the console when it is undefined (CLI-87).
|
|
280
|
+
*/
|
|
281
|
+
get logger(): Logger | undefined {
|
|
282
|
+
return this.options.logger;
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
/** The third argument of `onError`: the logger of the server, or the console adapter without it. */
|
|
286
|
+
private errorContext(): ServerErrorContext {
|
|
287
|
+
return { logger: this.options.logger ?? CONSOLE_LOGGER };
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
/** The logger of the errors that the error policy hides: `onError` and the logger, or `console.error` without them. */
|
|
251
291
|
private readonly hiddenErrorLog: HiddenErrorLog = (error, request) => {
|
|
252
292
|
const real = error instanceof Error ? error : new Error(String(error));
|
|
293
|
+
const { onError, logger } = this.options;
|
|
253
294
|
// A face that failed before it knew the call gives no request: onError gets a request of no call
|
|
254
|
-
if (
|
|
295
|
+
if (onError) onError(real, request ?? UNKNOWN_REQUEST, this.errorContext());
|
|
296
|
+
if (logger) logger.log("error", "The error policy hid an error", errorFields(request, real));
|
|
255
297
|
// A constant format: the request id comes from the caller (CodeQL js/tainted-format-string)
|
|
256
|
-
else console.error("[Server] hidden error of %s: %o", request?.id ?? "a request", real);
|
|
298
|
+
else if (!onError) console.error("[Server] hidden error of %s: %o", request?.id ?? "a request", real);
|
|
257
299
|
};
|
|
258
300
|
|
|
259
301
|
/** The response of a request, before the error policy. */
|
|
@@ -295,12 +337,12 @@ export class Server {
|
|
|
295
337
|
|
|
296
338
|
return response;
|
|
297
339
|
} catch (error) {
|
|
298
|
-
// Log error
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
340
|
+
// Log error: to onError and to the logger (CLI-87)
|
|
341
|
+
const { onError, logger } = this.options;
|
|
342
|
+
if (onError) onError(error as Error, request, this.errorContext());
|
|
343
|
+
if (logger) logger.log("error", "A handler failed", errorFields(request, error));
|
|
344
|
+
// The error policy does not log this error again (CLI-80)
|
|
345
|
+
if (onError || logger) markLogged(error);
|
|
304
346
|
|
|
305
347
|
// Convert error to response
|
|
306
348
|
return this.errorToResponse<TRes>(request, error as Error);
|