@mcp-abap-adt/connection 18.0.1 → 19.1.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 CHANGED
@@ -7,6 +7,107 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [19.1.0] - 2026-10-23
11
+
12
+ The HTTP wire's sockets change (below: Fixed and the first two Changed entries; a minor release because `https:` now keeps sockets alive); the
13
+ dependency ranges are unchanged. The rest is the repository's own install, lockfile, tests and
14
+ workflows.
15
+
16
+ ### Fixed
17
+
18
+ - **A request lost on a dead kept-alive socket is sent once more, on a new connection**
19
+ (mcp-abap-adt#314) — a named exception to "no retries". Over `http:` the wire used Node.js's
20
+ global agent, which keeps sockets alive; a server may close an idle one just as a request is
21
+ written onto it, and the request is lost unread. After a `500` in a stateful session the cleanup
22
+ `UNLOCK` failed so, with "socket hang up", and the enqueue lock stayed with the session — still
23
+ alive — until SM12. Now a request that went out on a socket taken from the pool, and whose
24
+ socket ended with no byte of an answer read (`ECONNRESET`, `EPIPE`), is resent once on a socket
25
+ opened for it, with the same cookies, session headers, CSRF token and body: the ABAP session and
26
+ its locks are bound to the cookies, not to the TCP connection (measured on an on-premise system,
27
+ 2026-10-23: an `UNLOCK` on a fresh connection with the same cookies and lock handle released the
28
+ lock). Never resent: a request on a socket opened for it, one that read any byte of an answer,
29
+ one after a redirect, one with a stream body, the logoff, and the resend itself. All methods
30
+ qualify. The resend shows only as a `debug` line in fixed words. The risk, stated: a server that
31
+ read the request and died before a byte of its answer would run a non-idempotent request twice —
32
+ not what happens to a socket the server closed while idle.
33
+
34
+ ### Changed
35
+
36
+ - **`https:` keeps its sockets alive too.** The HTTPS agent is built with Node.js's global-agent
37
+ options (`keepAlive: true`, `scheduling: 'lifo'`, `timeout: 5000` — an idle pooled socket is
38
+ closed after 5 s), as plain `http:` always had them, so a TLS handshake is no longer paid per
39
+ request. Your `agentOptions` and the TLS material still win over these: `ca`,
40
+ `rejectUnauthorized`, the client certificate are kept as before, and `keepAlive: false` there
41
+ turns the pool off. The wire's own `http.Agent` replaces the global one, with the same options.
42
+ - **The logoff always goes out on a connection of its own**, with `Connection: close` — over
43
+ `https:` also when your `agentOptions` say `keepAlive: true` (before, it then took a pooled
44
+ socket, and "written" could be a write onto a socket the server had closed).
45
+ - **The 7-day release age is dropped** (it was added earlier in this section and never shipped). `.npmrc` sets neither `min-release-age=7` nor
46
+ `min-release-age-exclude[]=@mcp-abap-adt/*`. The age gate conflicted with the gating
47
+ `npm audit`: a security fix younger than the gate could not be installed while the audit blocked
48
+ CI (seen 2026-10-22 with markdown-it 14.3.3). The defences that stay: `allowScripts` with
49
+ `strict-allow-scripts=true` (no dependency install script runs), lockfile hashes,
50
+ `npm ci --ignore-scripts` in CI, and the gating `npm audit`. Dependabot's own cooldown is
51
+ unchanged.
52
+
53
+ ### Security
54
+
55
+ - **`npm audit` finds nothing, dev dependencies included** (it found 21: 19 moderate, 1 high,
56
+ 1 critical). `follow-redirects` (under `axios`) 1.16.0 → 1.16.1 by a lockfile refresh within
57
+ the declared ranges (GHSA-q3jh-wrc6-jgq8, GHSA-8r9p-f939-6h3c — the one that reached the
58
+ runtime tree). The rest came with Jest: `handlebars` under `ts-jest` (GHSA-xw65-4hp5-5hc7,
59
+ GHSA-8r5x-fm3f-whwj, GHSA-p8wg-vrv2-v86f) and `sprintf-js` under `babel-plugin-istanbul` →
60
+ `@istanbuljs/load-nyc-config` → `js-yaml` 3 → `argparse` 1 (GHSA-hp3w-g68c-fv3c, no fixed
61
+ release), and they left with it (below). `@biomejs/biome` 2.5.15, `@types/node` 25.9.9.
62
+ - **No dependency has an install script, and none may run one.** With Jest gone the tree has no
63
+ package with an install script (it had two, `@parcel/watcher` and `unrs-resolver`, both
64
+ Jest's). `allowScripts` in `package.json` is empty — no dependency is allowed one — and `.npmrc`
65
+ sets `strict-allow-scripts=true`, so a new dependency with an unreviewed install script fails
66
+ the install instead of running it. npm reads these settings in full from 11.19.0 (measured
67
+ there); earlier npm 11 releases read part of them and npm 10, bundled with Node.js 22, none — so
68
+ CI and the release workflow install with `--ignore-scripts`, and docs/INSTALLATION.md, "From
69
+ Source", says `npm ci --ignore-scripts`. `.npmrc` does not set `ignore-scripts=true`: it would
70
+ also skip this package's own `prepublishOnly` gate.
71
+ - **CI and the release workflow run `npm audit --audit-level=moderate`**, dev dependencies
72
+ included, and run the tests through `npm run test:ci` instead of `npx jest`; the package scripts
73
+ call Biome and `tsc` from the installed dependencies instead of through `npx`.
74
+ - The `brace-expansion` override is gone: the package was reachable only through Jest.
75
+
76
+ ### Changed
77
+
78
+ - **The tests run on Node.js's own test runner (`node:test`), not Jest.** `npm test` (and
79
+ `test:ci`, `test:shape`) runs `scripts/run-tests.mjs`: it compiles `src` with the tests by `tsc`
80
+ (`tsconfig.test.json`) into the git-ignored `.test-build/`, afresh on every run, and hands the
81
+ compiled `*.test.js` files to `node --test` — with Jest's default bound of 5 s a test from
82
+ Node.js 24 on (`--test-timeout`; Node.js 22 applies that flag to a whole file, so there a test is
83
+ bounded only by its own `timeout`); every `timeout` a test set under Jest is kept. `jest`, `ts-jest`, `@types/jest` and `jest-util`
84
+ are no longer dev dependencies, `jest.config.js` is gone, and with them 1,600-odd packages of
85
+ the dev tree. Every suite is converted as it was: `expect` → `node:assert/strict` (Jest's
86
+ `toMatchObject` as `helpers/assertions.ts`'s `assertMatchObject`, the asymmetric matchers as
87
+ the explicit checks they stood for), `jest.fn` / `spyOn` → `mock.fn` / `mock.method`, fake
88
+ timers → `mock.timers`, `jest.doMock` / `isolateModules` → `helpers/moduleCache.ts` over
89
+ `require.cache`. No production code changed. Same counts: 585 passed, 13 skipped (the live
90
+ RFC/SNC blocks, still listed and skipped with their reason, none of their hooks run). One file
91
+ or several: `node scripts/run-tests.mjs rfcLogon shapeCheck`; anything after `--` goes to
92
+ `node --test`. The plain-node scenario of `dispatchedGoodbye` now runs compiled, without the
93
+ transpiling `register.cjs`.
94
+ - **Every CI and release job is capped at 20 minutes** (`timeout-minutes`): on Node.js 22,
95
+ `node:test` bounds no single test (`--test-timeout` there bounds a whole file), so a hung test
96
+ would otherwise run until GitHub's 6-hour limit.
97
+
98
+ ## [19.0.0] - 2026-10-22
99
+
100
+ ### Changed (breaking)
101
+
102
+ - **`@mcp-abap-adt/sap-rfc-lite` `^0.3.2`** (optional dependency, was `^0.2.2`). 0.3 installs with
103
+ no install script — `npm install` and `npm ci` compile nothing — and loads its prebuilt binding
104
+ for linux-x64 (glibc), win32-x64 and darwin-arm64. **On any other platform** (linux-arm64,
105
+ darwin-x64, Alpine, …) installing no longer compiles the binding: the install succeeds and the
106
+ RFC wire fails when it loads sap-rfc-lite, until a binding built from sap-rfc-lite's repository
107
+ is installed. At run time the RFC library is SAP GUI's 64-bit `sapnwrfc.dll` on Windows where
108
+ installed, otherwise the SAP NW RFC SDK. The connection's API and the RFC wire's behaviour are
109
+ unchanged. See [Migration to 19.0.0](./docs/MIGRATION-19.0.md); README, "RFC", says so.
110
+
10
111
  ## [18.0.1] - 2026-10-20
11
112
 
12
113
  ### Fixed
@@ -2690,6 +2791,8 @@ const connection = createAbapConnection(config, logger);
2690
2791
  - Permission errors (403 with "ExceptionResourceNoAccess") no longer trigger JWT refresh loops
2691
2792
  - Proper separation: base class handles HTTP/session, concrete classes handle auth-specific errors
2692
2793
  [Unreleased]: https://github.com/fr0ster/mcp-abap-connection/compare/v18.0.1...HEAD
2794
+ [19.1.0]: https://github.com/fr0ster/mcp-abap-connection/compare/v19.0.0...v19.1.0
2795
+ [19.0.0]: https://github.com/fr0ster/mcp-abap-connection/compare/v18.0.1...v19.0.0
2693
2796
  [18.0.1]: https://github.com/fr0ster/mcp-abap-connection/compare/v18.0.0...v18.0.1
2694
2797
  [18.0.0]: https://github.com/fr0ster/mcp-abap-connection/compare/v17.1.0...v18.0.0
2695
2798
  [17.1.0]: https://github.com/fr0ster/mcp-abap-connection/compare/v17.0.0...v17.1.0
package/README.md CHANGED
@@ -161,6 +161,7 @@ the packages above. See [Migration to 9.0.0](./docs/MIGRATION-9.0.md).
161
161
 
162
162
  - 📦 **[Installation Guide](./docs/INSTALLATION.md)** - Setup and installation instructions
163
163
  - 📚 **[Usage Guide](./docs/USAGE.md)** - Detailed usage examples and API documentation
164
+ - 🚚 **[Migration to 19.0.0](./docs/MIGRATION-19.0.md)** - `@mcp-abap-adt/sap-rfc-lite` ^0.3.2: no compile on install; prebuilt RFC bindings for linux-x64, win32-x64, darwin-arm64; elsewhere build sap-rfc-lite's binding from its repository; the API is unchanged
164
165
  - 🚚 **[Migration to 18.0.0](./docs/MIGRATION-18.0.md)** - `rfcParamsFrom` returns `RfcAddress` (application server or message server): narrow before reading `.ashost` / `.sysnr`; RFC through a message server and a logon group (`mshost`, `msserv` | `sysid`, `group`, `saprouter`)
165
166
  - 🚚 **[Migration to 17.0.0](./docs/MIGRATION-17.0.md)** - no deadline of the package's own: `getTimeout`, `getTimeoutConfig` and `SAP_TIMEOUT_*` are gone, and a request inside a critical section carries none at all; an instance can be built on an existing session (`session`, `sessionCookies()`)
166
167
  - 🚚 **[Migration to 16.0.0](./docs/MIGRATION-16.0.md)** - the per-request `signal` (15.1.0) and `ADT_REQUEST_ABORTED` are removed; `disconnect()` resolves once the logoff is written, not answered — a process about to exit awaits it; `flushGoodbye()` when the answer matters
@@ -279,6 +280,25 @@ the socket and SAP then ends the request running on it — a write in it lost.
279
280
  a critical section (`beginCriticalSection()`) a request carries none at all,
280
281
  not even yours.
281
282
 
283
+ **Kept-alive connections, and the one resend** (19.0.1). The HTTP wires pool
284
+ their sockets over `http:` and `https:` alike (Node.js's global-agent options:
285
+ `keepAlive`, `lifo`, an idle socket closed after 5 s; your `agentOptions` win
286
+ over `https:`, so `keepAlive: false` there turns the pool off). A server may
287
+ close an idle kept-alive connection just as a request is written onto it; that
288
+ request is lost unread. So, as a **named exception to "no retries"**: a request
289
+ that went out on a socket taken from the pool, and whose socket ended with no
290
+ byte of an answer read (`ECONNRESET` — "socket hang up" — or `EPIPE`), is sent
291
+ once more, on a new connection, with the same cookies, session headers, CSRF
292
+ token and body — the ABAP session and its locks are the cookies', not the
293
+ socket's (measured on-premise, 2026-10-23). Nothing else is resent: not a
294
+ request on a socket opened for it, not one that read any byte of an answer, not
295
+ one after a redirect, not a stream body, not the logoff, and never a second
296
+ time. The resend is visible only as a `debug` line in fixed words. **The risk,
297
+ stated:** a server that read the request and died before writing a byte of its
298
+ answer would run it twice; for a socket the server closed while it was idle,
299
+ that does not happen. Without the resend, a cleanup `UNLOCK` died so and the
300
+ enqueue lock stayed until SM12 (mcp-abap-adt#314).
301
+
282
302
  ### An instance on an existing session
283
303
 
284
304
  An instance may be built on a session that already exists, instead of logging
@@ -453,7 +473,11 @@ package state from causing PAK/058 on later writes or SADT_RESOURCE/007 on a
453
473
  read after create. Concurrent calls use a separate conversation. See
454
474
  [RFC conversation isolation](./docs/STATEFUL_SESSION_GUIDE.md#rfc-conversation-isolation-932-and-933).
455
475
 
456
- Needs the SAP NW RFC SDK on the machine and `npm install @mcp-abap-adt/sap-rfc-lite`.
476
+ Needs `npm install @mcp-abap-adt/sap-rfc-lite` (0.3.2 or newer: it installs with no install
477
+ script and carries prebuilt bindings for linux-x64 glibc, win32-x64 and darwin-arm64; elsewhere,
478
+ build one from its repository) and the SAP NetWeaver RFC library at run time: on Windows, the
479
+ 64-bit `sapnwrfc.dll` SAP GUI installs into `System32` is enough; otherwise the SAP NW RFC SDK, its
480
+ `lib` directory on the library search path (see sap-rfc-lite's README, "Runtime library loading").
457
481
 
458
482
  ```typescript
459
483
  import {
@@ -6,8 +6,9 @@
6
6
  * code path on one end cannot be named in a type — a default type parameter has
7
7
  * nothing to point at — so this is what makes the two ends symmetrical.
8
8
  *
9
- * Nothing to open or give back at this level. A request opens its own socket
10
- * and there is no conversation to establish; `open()` only offers the
9
+ * Nothing to open or give back at this level. A request takes a socket from
10
+ * the wire's pool (see `sendPooled()`), no socket is the session, and there is
11
+ * no conversation to establish; `open()` only offers the
11
12
  * credential its logon, and the subclasses add the session mechanism.
12
13
  *
13
14
  * **Where the two axes touch.** TLS client-certificate material comes from the
@@ -46,6 +47,12 @@ export declare class HttpTransport implements IAdtTransport {
46
47
  */
47
48
  readonly kind: string;
48
49
  private instance;
50
+ /**
51
+ * The agents that open a socket for one request and keep none — the
52
+ * logoff's, and the resend's after a pooled socket died. Built with the
53
+ * client, from the same options.
54
+ */
55
+ private fresh;
49
56
  /**
50
57
  * The TLS material the last logon offered. The client is built from it, and
51
58
  * a logon offering different material drops the client — never the jar.
@@ -348,6 +355,28 @@ export declare class HttpTransport implements IAdtTransport {
348
355
  * answer is not read, so not following a redirect changes nothing.
349
356
  */
350
357
  protected logoffRequest(options: RequestOptions, onResponse: (response: IncomingMessage) => void): ClientRequest;
358
+ /** The agent a logoff goes out on: never a pooled one. */
359
+ private goodbyeAgent;
360
+ /**
361
+ * One request, sent once more — on a new connection — in exactly one case,
362
+ * a named exception to "no retries": it went out on a socket taken from the
363
+ * pool, and that socket ended with no byte of an answer (`ECONNRESET` —
364
+ * "socket hang up" — or `EPIPE`). A server closes an idle kept-alive
365
+ * connection when it likes, and a request written onto it as it closes is
366
+ * lost unread; left alone, a cleanup `UNLOCK` dies so and the enqueue lock
367
+ * stays with the session until SM12 (mcp-abap-adt#314). The session is the
368
+ * cookies', not the socket's (measured on an on-premise system, 2026-10-23:
369
+ * an `UNLOCK` on a new connection with the same cookies and handle released
370
+ * the lock), so the resend carries the same config — the same cookies,
371
+ * session headers, CSRF token and body.
372
+ *
373
+ * Never resent: a request on a socket opened for it, one that read any byte
374
+ * of an answer, one after a redirect, one with a stream body, and the resend
375
+ * itself — it goes on a fresh agent, so its failure is the caller's error.
376
+ * The risk, stated: a server that read the request and died before a byte of
377
+ * its answer would run it twice.
378
+ */
379
+ private sendPooled;
351
380
  private dispatch;
352
381
  }
353
382
  //# sourceMappingURL=HttpTransport.d.ts.map
@@ -1 +1 @@
1
-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kB,EAC3B,GAAG,EAAE,MAAM,EACX,QAAQ,EAAE;QACR,OAAO,EAAE,MAAM,CAAC;QAChB,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;QACjC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;KACjC;IACD,uEAAuE;IACvE,OAAO,CAAC,EAAE,MAAM,IAAI,GACnB,OAAO,CAAC,IAAI,CAAC;IAyChB;;;;;OAKG;IACG,IAAI,CAAC,OAAO,EAAE,oBAAoB,GAAG,OAAO,CAAC,qBAAqB,CAAC;IAKzE;;;;;;OAMG;IACH,OAAO,CAAC,GAAG;IAmBX;;;;;;;;;;;;;;OAcG;cACa,YAAY,CAC1B,OAAO,EAAE,oBAAoB;IAC7B,yDAAyD;IACzD,OAAO,CAAC,EAAE,MAAM,IAAI,GACnB,OAAO,CAAC,qBAAqB,CAAC;IAIjC;;;;;;OAMG;IACH,SAAS,CAAC,aAAa,CACrB,OAAO,EAAE,cAAc,EACvB,UAAU,EAAE,CAAC,QAAQ,EAAE,eAAe,KAAK,IAAI,GAC9C,aAAa;IAMhB,0DAA0D;IAC1D,OAAO,CAAC,YAAY;IAOpB;;;;;;;;;;;;;;;;;;OAkBG;YACW,UAAU;YA+BV,QAAQ;CAgEvB"}
@@ -7,8 +7,9 @@
7
7
  * code path on one end cannot be named in a type — a default type parameter has
8
8
  * nothing to point at — so this is what makes the two ends symmetrical.
9
9
  *
10
- * Nothing to open or give back at this level. A request opens its own socket
11
- * and there is no conversation to establish; `open()` only offers the
10
+ * Nothing to open or give back at this level. A request takes a socket from
11
+ * the wire's pool (see `sendPooled()`), no socket is the session, and there is
12
+ * no conversation to establish; `open()` only offers the
12
13
  * credential its logon, and the subclasses add the session mechanism.
13
14
  *
14
15
  * **Where the two axes touch.** TLS client-certificate material comes from the
@@ -24,6 +25,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
24
25
  };
25
26
  Object.defineProperty(exports, "__esModule", { value: true });
26
27
  exports.HttpTransport = exports.isStatefulRequest = void 0;
28
+ const node_async_hooks_1 = require("node:async_hooks");
27
29
  const node_crypto_1 = require("node:crypto");
28
30
  const node_http_1 = require("node:http");
29
31
  const node_https_1 = require("node:https");
@@ -34,6 +36,108 @@ const authErrors_js_1 = require("./authErrors.js");
34
36
  const csrfConfig_js_1 = require("./csrfConfig.js");
35
37
  const IAdtTransport_js_1 = require("./IAdtTransport.js");
36
38
  const statefulRequest_js_1 = require("./statefulRequest.js");
39
+ /**
40
+ * The pool every request of the wire goes through: the options of Node's own
41
+ * global agents (`node -p "http.globalAgent.options"`), which plain `http:`
42
+ * used before the wire had an agent of its own for it — kept-alive sockets,
43
+ * the most recently freed taken first, an idle one closed after 5 s.
44
+ */
45
+ const POOLED = {
46
+ keepAlive: true,
47
+ scheduling: 'lifo',
48
+ timeout: 5000,
49
+ };
50
+ /**
51
+ * Which dispatch a request belongs to. Node hands a request to its agent
52
+ * (`addRequest()`) inside the `ClientRequest` constructor, so in the async
53
+ * context of the dispatch that made it.
54
+ */
55
+ const pooledAttempts = new node_async_hooks_1.AsyncLocalStorage();
56
+ /**
57
+ * The sockets that have carried a request. A socket is reused when it is in
58
+ * here as a request gets it — whether the agent took it from its free list
59
+ * (`reuseSocket()`) or handed it straight from a finished request to a queued
60
+ * one, which bypasses `reuseSocket()` (a caller's `maxSockets`).
61
+ */
62
+ const carried = new WeakSet();
63
+ function bytesReadOf(socket) {
64
+ const bytesRead = socket.bytesRead;
65
+ return typeof bytesRead === 'number' ? bytesRead : -1;
66
+ }
67
+ function noteRequest(request) {
68
+ const attempt = pooledAttempts.getStore();
69
+ request.once('socket', (socket) => {
70
+ const reused = carried.has(socket);
71
+ carried.add(socket);
72
+ if (attempt !== undefined) {
73
+ attempt.sent = { socket, reused, bytesRead: bytesReadOf(socket) };
74
+ }
75
+ });
76
+ }
77
+ /**
78
+ * Sees every request the agent is given. `addRequest()` is Node's own entry
79
+ * of an agent (every `ClientRequest` with an agent calls it); not in the
80
+ * typings, so reached through this one cast.
81
+ */
82
+ function seeRequests(agent) {
83
+ const target = agent;
84
+ const add = target.addRequest;
85
+ target.addRequest = function addRequest(request, options) {
86
+ noteRequest(request);
87
+ add.call(this, request, options);
88
+ };
89
+ }
90
+ class PooledHttpAgent extends node_http_1.Agent {
91
+ constructor(options) {
92
+ super(options);
93
+ seeRequests(this);
94
+ }
95
+ }
96
+ class PooledHttpsAgent extends node_https_1.Agent {
97
+ constructor(options) {
98
+ super(options);
99
+ seeRequests(this);
100
+ }
101
+ }
102
+ /** The codes of a socket that ended before an answer: "socket hang up" is `ECONNRESET`. */
103
+ const UNANSWERED_CODES = new Set(['ECONNRESET', 'EPIPE']);
104
+ function codeOf(error) {
105
+ if (typeof error !== 'object' || error === null)
106
+ return undefined;
107
+ try {
108
+ return error.code;
109
+ }
110
+ catch {
111
+ return undefined;
112
+ }
113
+ }
114
+ /**
115
+ * Whether a failed dispatch is the one case resent: it went out on a socket
116
+ * taken from the pool, no redirect was followed, and the socket ended with no
117
+ * byte of an answer read — the server had closed the idle connection while
118
+ * the request was being written onto it.
119
+ */
120
+ function diedOnPooledSocket(error, attempt) {
121
+ const sent = attempt.sent;
122
+ if (sent === undefined || !sent.reused || attempt.redirected === true) {
123
+ return false;
124
+ }
125
+ if (sent.bytesRead < 0 || bytesReadOf(sent.socket) !== sent.bytesRead) {
126
+ return false;
127
+ }
128
+ if (typeof error === 'object' && error !== null && 'response' in error) {
129
+ if (error.response !== undefined)
130
+ return false;
131
+ }
132
+ const code = codeOf(error);
133
+ return typeof code === 'string' && UNANSWERED_CODES.has(code);
134
+ }
135
+ /** A body that can be written a second time: not a stream. */
136
+ function resendable(data) {
137
+ if (typeof data !== 'object' || data === null)
138
+ return true;
139
+ return typeof data.pipe !== 'function';
140
+ }
37
141
  /**
38
142
  * Whether a `Set-Cookie`'s attributes delete it: `Max-Age` of zero or less, or
39
143
  * an `Expires` already in the past — SAP's own deletions are the latter
@@ -187,6 +291,12 @@ class HttpTransport {
187
291
  */
188
292
  kind = 'http';
189
293
  instance = null;
294
+ /**
295
+ * The agents that open a socket for one request and keep none — the
296
+ * logoff's, and the resend's after a pooled socket died. Built with the
297
+ * client, from the same options.
298
+ */
299
+ fresh = null;
190
300
  /**
191
301
  * The TLS material the last logon offered. The client is built from it, and
192
302
  * a logon offering different material drops the client — never the jar.
@@ -811,13 +921,19 @@ class HttpTransport {
811
921
  this.saidUnverified = true;
812
922
  this.logger?.debug('TLS: the server certificate is not verified (explicit opt-out)');
813
923
  }
924
+ // Both schemes pool their sockets, `https:` as plain `http:` always
925
+ // has: a TLS handshake per request is what keep-alive saves. The
926
+ // caller's `agentOptions` and the TLS material win over the pool's
927
+ // options — `keepAlive: false` there turns the pool off for `https:`.
928
+ const tls = { ...options, rejectUnauthorized, ...this.material };
814
929
  this.instance = axios_1.default.create({
815
- httpsAgent: new node_https_1.Agent({
816
- ...options,
817
- rejectUnauthorized,
818
- ...this.material,
819
- }),
930
+ httpAgent: new PooledHttpAgent(POOLED),
931
+ httpsAgent: new PooledHttpsAgent({ ...POOLED, ...tls }),
820
932
  });
933
+ this.fresh = {
934
+ http: new node_http_1.Agent({ keepAlive: false }),
935
+ https: new node_https_1.Agent({ ...tls, keepAlive: false }),
936
+ };
821
937
  }
822
938
  return this.instance;
823
939
  }
@@ -968,10 +1084,63 @@ class HttpTransport {
968
1084
  ? (0, node_https_1.request)(options, onResponse)
969
1085
  : (0, node_http_1.request)(options, onResponse);
970
1086
  }
1087
+ /** The agent a logoff goes out on: never a pooled one. */
1088
+ goodbyeAgent(options) {
1089
+ const agent = options.agent;
1090
+ if (agent instanceof PooledHttpsAgent)
1091
+ return this.fresh?.https ?? false;
1092
+ if (agent instanceof PooledHttpAgent)
1093
+ return this.fresh?.http ?? false;
1094
+ return agent === undefined || agent === null ? false : agent;
1095
+ }
1096
+ /**
1097
+ * One request, sent once more — on a new connection — in exactly one case,
1098
+ * a named exception to "no retries": it went out on a socket taken from the
1099
+ * pool, and that socket ended with no byte of an answer (`ECONNRESET` —
1100
+ * "socket hang up" — or `EPIPE`). A server closes an idle kept-alive
1101
+ * connection when it likes, and a request written onto it as it closes is
1102
+ * lost unread; left alone, a cleanup `UNLOCK` dies so and the enqueue lock
1103
+ * stays with the session until SM12 (mcp-abap-adt#314). The session is the
1104
+ * cookies', not the socket's (measured on an on-premise system, 2026-10-23:
1105
+ * an `UNLOCK` on a new connection with the same cookies and handle released
1106
+ * the lock), so the resend carries the same config — the same cookies,
1107
+ * session headers, CSRF token and body.
1108
+ *
1109
+ * Never resent: a request on a socket opened for it, one that read any byte
1110
+ * of an answer, one after a redirect, one with a stream body, and the resend
1111
+ * itself — it goes on a fresh agent, so its failure is the caller's error.
1112
+ * The risk, stated: a server that read the request and died before a byte of
1113
+ * its answer would run it twice.
1114
+ */
1115
+ async sendPooled(config) {
1116
+ const attempt = {};
1117
+ try {
1118
+ return await pooledAttempts.run(attempt, () => this.client()({
1119
+ ...config,
1120
+ beforeRedirect: () => {
1121
+ attempt.redirected = true;
1122
+ },
1123
+ }));
1124
+ }
1125
+ catch (error) {
1126
+ const fresh = this.fresh;
1127
+ if (fresh === null ||
1128
+ !resendable(config.data) ||
1129
+ !diedOnPooledSocket(error, attempt)) {
1130
+ throw error;
1131
+ }
1132
+ this.logger?.debug('HTTP: a pooled connection closed before any answer; the request is sent once more on a new connection');
1133
+ return this.client()({
1134
+ ...config,
1135
+ httpAgent: fresh.http,
1136
+ httpsAgent: fresh.https,
1137
+ });
1138
+ }
1139
+ }
971
1140
  async dispatch(request, headers, written,
972
1141
  /** `maxRedirects: 0` for the adoption probe alone; see `resume()`. */
973
1142
  redirects) {
974
- const response = await this.client()({
1143
+ const config = {
975
1144
  ...(redirects ?? {}),
976
1145
  // The write is the point `disconnect()` resolves at: the request's
977
1146
  // `finish`, emitted once its bytes are handed to the socket — not when
@@ -980,17 +1149,13 @@ class HttpTransport {
980
1149
  ? {
981
1150
  transport: {
982
1151
  request: (options, onResponse) => {
983
- // A socket of its own: with no agent of the wire's (plain
984
- // `http:` — the TLS material's agent and a proxy's are kept),
985
- // node would take a pooled keep-alive socket, whose write can
1152
+ // A socket of its own: a pooled keep-alive socket's write can
986
1153
  // succeed after the server closed it, losing the logoff after
987
- // `finish`. `agent: false` opens a fresh connection, and node
988
- // sends `Connection: close` on it. Over `https:` the wire's
989
- // own agent keeps no socket alive unless the caller's
990
- // `agentOptions` say `keepAlive: true`.
991
- const outgoing = this.logoffRequest(options.agent === undefined
992
- ? { ...options, agent: false }
993
- : options, onResponse);
1154
+ // `finish`. The wire's fresh agents open a new connection and
1155
+ // keep none (node sends `Connection: close` on it) — over
1156
+ // `https:` with the pool's TLS options. A proxy's agent is
1157
+ // kept; with no agent at all, `agent: false` does the same.
1158
+ const outgoing = this.logoffRequest({ ...options, agent: this.goodbyeAgent(options) }, onResponse);
994
1159
  outgoing.once('finish', written);
995
1160
  return outgoing;
996
1161
  },
@@ -1011,7 +1176,12 @@ class HttpTransport {
1011
1176
  ...(request.validateStatus !== undefined
1012
1177
  ? { validateStatus: request.validateStatus }
1013
1178
  : {}),
1014
- });
1179
+ };
1180
+ // A logoff opens a socket of its own and is never resent: its answer is
1181
+ // not read, and its write is what `disconnect()` resolves at.
1182
+ const response = written !== undefined
1183
+ ? await this.client()(config)
1184
+ : await this.sendPooled(config);
1015
1185
  return {
1016
1186
  status: response.status,
1017
1187
  statusText: response.statusText,
@@ -27,10 +27,16 @@ yarn add @mcp-abap-adt/connection
27
27
  ```bash
28
28
  git clone https://github.com/fr0ster/mcp-abap-connection.git
29
29
  cd mcp-abap-connection
30
- npm install
30
+ npm ci --ignore-scripts
31
31
  npm run build
32
32
  ```
33
33
 
34
+ `--ignore-scripts` because no dependency needs its install script to build or
35
+ test, and because the repository's own guard depends on the npm version: its
36
+ `.npmrc` lets no dependency run an install script that `package.json`
37
+ `allowScripts` does not allow, which npm reads in full only from 11.19.0 (measured there); earlier npm 11
38
+ releases read part of it, and npm 10 (bundled with Node.js 22) none.
39
+
34
40
  ## Environment Setup
35
41
 
36
42
  ### Basic Authentication (On-Premise)
@@ -0,0 +1,38 @@
1
+ # Migration to 19.0
2
+
3
+ 19.0.0 moves the optional RFC dependency `@mcp-abap-adt/sap-rfc-lite` from `^0.2.2` to `^0.3.2`.
4
+ The connection's API and the RFC wire's behaviour are unchanged; what changes is how the RFC
5
+ binding gets onto a machine.
6
+
7
+ ## What changed
8
+
9
+ - **sap-rfc-lite compiles nothing on install.** 0.2.x compiled its native binding during
10
+ `npm install` (with the SAP NW RFC SDK and a C++ toolchain). 0.3.x has no install script —
11
+ `npm install` and `npm ci` run nothing — and loads a prebuilt binding at run time.
12
+ - **Prebuilt bindings exist for linux-x64 (glibc), win32-x64 and darwin-arm64.** On these, an
13
+ install needs no SDK headers and no compiler.
14
+ - **Anywhere else there is no binding after install** — linux-arm64, darwin-x64, Linux with musl
15
+ (Alpine), and any other platform. The install succeeds (the dependency is optional), and the RFC
16
+ wire fails when `rfcConversationFrom` loads sap-rfc-lite.
17
+ - **The RFC library at run time:** on Windows, the 64-bit `sapnwrfc.dll` SAP GUI installs into
18
+ `System32` is enough; otherwise the SAP NW RFC SDK, its `lib` directory on the library search
19
+ path.
20
+ - sap-rfc-lite 0.3 needs Node.js 20 or newer; this package already needs 22.
21
+
22
+ ## What to do
23
+
24
+ - **On linux-x64 (glibc), win32-x64 or darwin-arm64:** nothing. If you built with
25
+ `SAPNWRFC_HOME` only for the install, it is no longer needed then; keep the SDK libraries
26
+ loadable at run time (or SAP GUI's on Windows).
27
+ - **On any other platform**, build sap-rfc-lite's binding from its repository and install the
28
+ package you built (sap-rfc-lite's README, "Installation"):
29
+
30
+ ```bash
31
+ git clone https://github.com/fr0ster/sap-rfc-lite.git && cd sap-rfc-lite
32
+ git checkout v0.3.2
33
+ npm ci
34
+ npm run prebuild:native # needs SAPNWRFC_HOME and a C++ toolchain
35
+ npm pack # install the .tgz in your project
36
+ ```
37
+
38
+ - **HTTP only:** nothing; sap-rfc-lite is loaded only by the RFC wire.
@@ -265,6 +265,14 @@ and does not belong to the cookies — it belongs to the **ABAP session**, and
265
265
  that session is the server's. This side never ends one: it can ask (a logoff),
266
266
  and otherwise waits for a timeout it cannot see.
267
267
 
268
+ That is also why the HTTP wire may resend a request on a new connection: when a
269
+ pooled kept-alive socket ends before a byte of the answer (the server closed it
270
+ while idle), the request is sent once more with the same cookies, and an
271
+ `UNLOCK` on the new connection reaches the lock a `LOCK` took on another
272
+ (measured on an on-premise system, 2026-10-23). Without it, the cleanup
273
+ `UNLOCK` after a failed save died with "socket hang up" and the lock stayed
274
+ until SM12. See USAGE.md, "Kept-alive connections, and the one resend".
275
+
268
276
  A closed socket is just a client that stopped listening. The ABAP session
269
277
  neither knows nor cares — which is why `SM04` shows sessions left behind by
270
278
  connections that never said they were finished, and why this package sends an
package/docs/USAGE.md CHANGED
@@ -683,7 +683,9 @@ carry on over a session the caller never opened.
683
683
 
684
684
  In both cases the connector does **not** retry the request internally. Retrying
685
685
  blindly is what produced further orphaned locks in the field. That decision is
686
- yours.
686
+ yours. (The one resend the HTTP wire makes is of a request that never reached
687
+ an answer on a dead pooled socket — see "Kept-alive connections, and the one
688
+ resend" under the transports; it never resends a request the server answered.)
687
689
 
688
690
  **A lost session spends the instance** (since 16.0.0), as `disconnect()` does.
689
691
  After either of these, `connect()` and every request on the instance reject
@@ -863,7 +865,7 @@ try {
863
865
 
864
866
  ### Network Error Detection
865
867
 
866
- The connection automatically detects network-level errors and prevents unnecessary retry attempts. Network errors include:
868
+ The connection automatically detects network-level errors and prevents unnecessary retry attempts (the HTTP wire's one exception: a request whose pooled kept-alive socket ended before any byte of an answer is sent once more on a new connection — see "Kept-alive connections, and the one resend"; a second failure is the error). Network errors include:
867
869
 
868
870
  - `ECONNREFUSED` - Connection refused (server not reachable)
869
871
  - `ETIMEDOUT` - Connection timeout
@@ -1023,6 +1025,26 @@ carries it; the wire never reads `config.username` or `config.password`.
1023
1025
  (see [MIGRATION-11.0.md](./MIGRATION-11.0.md)). A later logon offering different material
1024
1026
  replaces the client; the cookie jar and CSRF token are the session's and stay.
1025
1027
  HTTP refuses logon parameters.
1028
+ - **Kept-alive connections, and the one resend** (19.0.1). The HTTP wires pool
1029
+ their sockets over `http:` and `https:` alike (Node.js's global-agent options:
1030
+ `keepAlive`, `lifo`, an idle socket closed after 5 s; your `agentOptions` win
1031
+ over `https:`, so `keepAlive: false` there turns the pool off). A server may
1032
+ close an idle kept-alive connection just as a request is written onto it; that
1033
+ request is lost unread. So, as a **named exception to "no retries"**: a request
1034
+ that went out on a socket taken from the pool, and whose socket ended with no
1035
+ byte of an answer read (`ECONNRESET` — "socket hang up" — or `EPIPE`), is sent
1036
+ once more, on a new connection, with the same cookies, session headers, CSRF
1037
+ token and body — the ABAP session and its locks are the cookies', not the
1038
+ socket's (measured on-premise, 2026-10-23). Nothing else is resent: not a
1039
+ request on a socket opened for it, not one that read any byte of an answer, not
1040
+ one after a redirect, not a stream body, not the logoff, and never a second
1041
+ time. The resend is visible only as a `debug` line in fixed words. **The risk,
1042
+ stated:** a server that read the request and died before writing a byte of its
1043
+ answer would run it twice; for a socket the server closed while it was idle,
1044
+ that does not happen. Without the resend, a cleanup `UNLOCK` died so and the
1045
+ enqueue lock stayed until SM12 (mcp-abap-adt#314).
1046
+ The logoff goes out on a connection of its own, with `Connection: close`,
1047
+ whatever your `agentOptions` say.
1026
1048
  - RFC takes logon parameters (a password, or SNC settings) on every conversation
1027
1049
  it opens, the session's own and each per-call one. RFC refuses TLS material,
1028
1050
  and a provider that writes no logon parameters (a bearer token) cannot log on
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mcp-abap-adt/connection",
3
- "version": "18.0.1",
3
+ "version": "19.1.0",
4
4
  "description": "ABAP connection layer for MCP ABAP ADT server",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -34,17 +34,18 @@
34
34
  "scripts": {
35
35
  "chrono": "node scripts/version-stats.mjs",
36
36
  "clean": "node scripts/clean.mjs",
37
- "lint": "npx biome check --write src scripts",
38
- "lint:check": "npx biome check src scripts --error-on-warnings",
39
- "test:shape": "jest src/__tests__/shapeCheck.test.ts",
40
- "format": "npx biome format --write src scripts",
41
- "build": "npm run --silent clean && npx biome check src scripts --diagnostic-level=error && npx tsc -p tsconfig.json && npm run --silent typecheck:scripts",
42
- "build:fast": "npx tsc -p tsconfig.json",
43
- "test": "npm run --silent check:docs && jest",
37
+ "lint": "biome check --write src scripts",
38
+ "lint:check": "biome check src scripts --error-on-warnings",
39
+ "test:shape": "node scripts/run-tests.mjs src/__tests__/shapeCheck.test.ts",
40
+ "format": "biome format --write src scripts",
41
+ "build": "npm run --silent clean && biome check src scripts --diagnostic-level=error && tsc -p tsconfig.json && npm run --silent typecheck:scripts",
42
+ "build:fast": "tsc -p tsconfig.json",
43
+ "test": "npm run --silent check:docs && node scripts/run-tests.mjs",
44
44
  "prepublishOnly": "npm run build && npm run lint:check && npm run test:shape && npm run check:docs && npm run --silent check:pack",
45
45
  "check:docs": "node scripts/check-docs.mjs",
46
- "typecheck:scripts": "npx tsc -p tsconfig.scripts.json",
47
- "check:pack": "node scripts/check-pack.mjs"
46
+ "typecheck:scripts": "tsc -p tsconfig.scripts.json",
47
+ "check:pack": "node scripts/check-pack.mjs",
48
+ "test:ci": "node scripts/run-tests.mjs"
48
49
  },
49
50
  "engines": {
50
51
  "node": "^22 || ^24 || ^26"
@@ -59,20 +60,14 @@
59
60
  "axios": "^1.16.0"
60
61
  },
61
62
  "optionalDependencies": {
62
- "@mcp-abap-adt/sap-rfc-lite": "^0.2.2"
63
+ "@mcp-abap-adt/sap-rfc-lite": "^0.3.2"
63
64
  },
64
65
  "devDependencies": {
65
66
  "@biomejs/biome": "^2.3.14",
66
67
  "@mcp-abap-adt/auth-providers": "^6.0.2",
67
- "@types/jest": "^30.0.0",
68
68
  "@types/node": "^25.2.3",
69
69
  "dotenv": "^17.3.1",
70
- "jest": "^30.2.0",
71
- "jest-util": "^30.2.0",
72
- "ts-jest": "^29.2.5",
73
70
  "typescript": "^5.9.2"
74
71
  },
75
- "overrides": {
76
- "brace-expansion": "^5.0.8"
77
- }
72
+ "allowScripts": {}
78
73
  }