@mcp-abap-adt/connection 15.1.0 → 17.0.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 +187 -1
- package/README.md +137 -33
- package/dist/connection/AbstractAbapConnection.d.ts +140 -58
- package/dist/connection/AbstractAbapConnection.d.ts.map +1 -1
- package/dist/connection/AbstractAbapConnection.js +349 -255
- package/dist/connection/AdtCloudConnector.d.ts +6 -1
- package/dist/connection/AdtCloudConnector.d.ts.map +1 -1
- package/dist/connection/AdtCloudConnector.js +7 -2
- package/dist/connection/AdtOnPremConnector.d.ts +6 -1
- package/dist/connection/AdtOnPremConnector.d.ts.map +1 -1
- package/dist/connection/AdtOnPremConnector.js +7 -2
- package/dist/connection/CloudHttpTransport.d.ts +8 -1
- package/dist/connection/CloudHttpTransport.d.ts.map +1 -1
- package/dist/connection/CloudHttpTransport.js +30 -18
- package/dist/connection/CredentialAbapConnection.d.ts +3 -1
- package/dist/connection/CredentialAbapConnection.d.ts.map +1 -1
- package/dist/connection/CredentialAbapConnection.js +4 -2
- package/dist/connection/GenericWebSocketTransport.d.ts.map +1 -1
- package/dist/connection/GenericWebSocketTransport.js +7 -4
- package/dist/connection/HttpTransport.d.ts +80 -6
- package/dist/connection/HttpTransport.d.ts.map +1 -1
- package/dist/connection/HttpTransport.js +258 -25
- package/dist/connection/IAdtTransport.d.ts +46 -22
- package/dist/connection/IAdtTransport.d.ts.map +1 -1
- package/dist/connection/OnPremHttpTransport.d.ts +2 -13
- package/dist/connection/OnPremHttpTransport.d.ts.map +1 -1
- package/dist/connection/OnPremHttpTransport.js +16 -32
- package/dist/connection/RfcTransport.d.ts +7 -6
- package/dist/connection/RfcTransport.d.ts.map +1 -1
- package/dist/connection/RfcTransport.js +27 -49
- package/dist/connection/createConnection.d.ts +95 -0
- package/dist/connection/createConnection.d.ts.map +1 -0
- package/dist/connection/createConnection.js +44 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -5
- package/docs/INDEX.md +6 -2
- package/docs/MIGRATION-16.0.md +123 -0
- package/docs/MIGRATION-17.0.md +119 -0
- package/docs/SCOPE.md +22 -45
- package/docs/STATEFUL_SESSION_GUIDE.md +49 -49
- package/docs/USAGE.md +244 -120
- package/package.json +2 -2
- package/dist/connection/requestAbort.d.ts +0 -32
- package/dist/connection/requestAbort.d.ts.map +0 -1
- package/dist/connection/requestAbort.js +0 -69
- package/dist/utils/timeouts.d.ts +0 -18
- package/dist/utils/timeouts.d.ts.map +0 -1
- package/dist/utils/timeouts.js +0 -37
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
# Migration to 17.0
|
|
2
|
+
|
|
3
|
+
17.0.0 does two things that [SCOPE.md](./SCOPE.md) lists: a request carries no
|
|
4
|
+
deadline but the caller's own, and an instance can be built on an existing SAP
|
|
5
|
+
session. For a consumer on 16.x that means the following.
|
|
6
|
+
|
|
7
|
+
## No deadline of the package's own
|
|
8
|
+
|
|
9
|
+
A client deadline closes the socket, and SAP then ends the synchronous request
|
|
10
|
+
that was running on it — a write in it is lost. So nothing this package sends
|
|
11
|
+
carries a deadline it chose.
|
|
12
|
+
|
|
13
|
+
### What changed
|
|
14
|
+
|
|
15
|
+
- **`getTimeout`, `getTimeoutConfig` and the `TimeoutConfig` type are no longer
|
|
16
|
+
exported**, and nothing reads `SAP_TIMEOUT_DEFAULT`, `SAP_TIMEOUT_CSRF`,
|
|
17
|
+
`SAP_TIMEOUT_LONG` or `SAP_TIMEOUT_CRITICAL` any more. Setting them changes
|
|
18
|
+
nothing.
|
|
19
|
+
- **A request carries the `timeout` you pass, unchanged, and nothing else.**
|
|
20
|
+
The CSRF fetch (in `connect()`, before a mutation, and the one a refused
|
|
21
|
+
token triggers) and the cloud session preflight carry none; before, each was
|
|
22
|
+
bounded by `SAP_TIMEOUT_CSRF` (15 s).
|
|
23
|
+
- **Inside a critical section a request carries no deadline at all — not even
|
|
24
|
+
yours.** Before, `beginCriticalSection()` raised the request's timeout to
|
|
25
|
+
`max(yours, SAP_TIMEOUT_CRITICAL)` (600 s by default). Now the `timeout` you
|
|
26
|
+
pass is not applied while a section is active, and applies again once the
|
|
27
|
+
outermost section ends. The critical section itself is unchanged.
|
|
28
|
+
- **`GenericWebSocketTransport.connect()` sets no timer** unless you pass
|
|
29
|
+
`connectTimeoutMs`; the 15 s default is gone. A `connectTimeoutMs` you pass is
|
|
30
|
+
honoured as before.
|
|
31
|
+
- **`IAdtEstablishContext.timeoutMs` is gone** from the transport seam.
|
|
32
|
+
- `ITimeoutConfig` in `@mcp-abap-adt/interfaces-adt-connection` is unchanged;
|
|
33
|
+
this package no longer uses it.
|
|
34
|
+
|
|
35
|
+
### What you do
|
|
36
|
+
|
|
37
|
+
- Replace `timeout: getTimeout('default')` (or `'csrf'`, `'long'`) with a number
|
|
38
|
+
of your own. `IAbapRequestOptions.timeout` is still a required field of the
|
|
39
|
+
contract; `0` means none over HTTP (axios reads it so), and the RFC wire does
|
|
40
|
+
not read it at all.
|
|
41
|
+
- Drop `SAP_TIMEOUT_*` from your environment, or read them yourself if you want
|
|
42
|
+
them to keep meaning something.
|
|
43
|
+
- If you relied on `connect()` giving up after 15 s against a host that does
|
|
44
|
+
not answer: it now waits for the network to fail. A bound on it is yours to
|
|
45
|
+
set around the call.
|
|
46
|
+
|
|
47
|
+
Before:
|
|
48
|
+
|
|
49
|
+
```text
|
|
50
|
+
import { getTimeout } from '@mcp-abap-adt/connection';
|
|
51
|
+
await connection.makeAdtRequest({ method: 'GET', url, timeout: getTimeout('default') });
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
After:
|
|
55
|
+
|
|
56
|
+
```typescript
|
|
57
|
+
import { createConnection } from '@mcp-abap-adt/connection';
|
|
58
|
+
import type { SapConfig } from '@mcp-abap-adt/connection';
|
|
59
|
+
import { BasicAuthProvider } from '@mcp-abap-adt/auth-providers';
|
|
60
|
+
|
|
61
|
+
const system: SapConfig = {
|
|
62
|
+
url: 'https://your-sap-system.com',
|
|
63
|
+
client: '100',
|
|
64
|
+
authType: 'basic',
|
|
65
|
+
username: 'your-username',
|
|
66
|
+
password: 'your-password',
|
|
67
|
+
};
|
|
68
|
+
const connection = createConnection({
|
|
69
|
+
system: 'onprem',
|
|
70
|
+
transport: 'http',
|
|
71
|
+
config: system,
|
|
72
|
+
credential: new BasicAuthProvider(system.username!, system.password!),
|
|
73
|
+
});
|
|
74
|
+
await connection.connect();
|
|
75
|
+
// Your own deadline, or 0 for none.
|
|
76
|
+
await connection.makeAdtRequest({ method: 'GET', url: '/sap/bc/adt/discovery', timeout: 45_000 });
|
|
77
|
+
await connection.disconnect();
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
## An instance on an existing session
|
|
81
|
+
|
|
82
|
+
New, and nothing changes for a consumer that does not use it.
|
|
83
|
+
|
|
84
|
+
- **`sessionCookies()`** on every connector: the cookies of the instance's SAP
|
|
85
|
+
session as one `Cookie`-header string — `SAP_SESSIONID_*`, `sap-usercontext`,
|
|
86
|
+
`sap-contextid` when a stateful request opened a context, and whatever else
|
|
87
|
+
the server set to keep the session where it lives; everything the wire holds
|
|
88
|
+
but `sap-XSRF_*`. `null` before a session, after it ended, and over RFC. It
|
|
89
|
+
acts as the user while the session lives: keep it as a secret. The package
|
|
90
|
+
never logs it.
|
|
91
|
+
- **`createConnection({ …, session })`** (and a sixth constructor argument,
|
|
92
|
+
`session`, on `AdtOnPremConnector` / `AdtCloudConnector`) builds the instance
|
|
93
|
+
on that session. `connect()` does not log on: it makes one request in that
|
|
94
|
+
session without the credential — the CSRF fetch; on cloud with
|
|
95
|
+
`x-sap-security-session: use` and no preflight — following no redirect, and
|
|
96
|
+
SAP's answer says whether the session is alive. Alive: the session is the instance's, a stateful
|
|
97
|
+
request reaches its `sap-contextid`, and `disconnect()` logs it off as for any
|
|
98
|
+
instance. Gone (a `401`, a redirect — not followed, its target never asked —
|
|
99
|
+
or an answer that is not the session's):
|
|
100
|
+
`connect()` rejects with SAP's answer as it is, nothing is logged off, and the
|
|
101
|
+
instance is spent.
|
|
102
|
+
- **HTTP wires only.** Over RFC, `session` is refused by `createConnection` at
|
|
103
|
+
construction, and by the RFC wire at `connect()` when the connector was built
|
|
104
|
+
by hand, before anything is sent. An empty `session` is refused at
|
|
105
|
+
construction.
|
|
106
|
+
|
|
107
|
+
See [USAGE.md — An instance on an existing session](./USAGE.md#an-instance-on-an-existing-session-session-and-sessioncookies).
|
|
108
|
+
|
|
109
|
+
## A wire of your own
|
|
110
|
+
|
|
111
|
+
`IAdtTransport` has two new required members:
|
|
112
|
+
|
|
113
|
+
- `resume(context, session): Promise<void>` — take over the session `session`
|
|
114
|
+
names, without the credential, or reject with the server's answer. A wire
|
|
115
|
+
whose session no cookie names rejects without sending anything, as
|
|
116
|
+
`RfcTransport` does.
|
|
117
|
+
- `sessionCookies(): string | null` — what `resume()` takes, or `null`.
|
|
118
|
+
|
|
119
|
+
A wire built on `HttpTransport` inherits both.
|
package/docs/SCOPE.md
CHANGED
|
@@ -1,45 +1,22 @@
|
|
|
1
|
-
# Scope
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
## Why there is no RFC to SAP BTP / cloud
|
|
25
|
-
|
|
26
|
-
Short answer: because SAP does not support it that way, and Eclipse ADT does not do it that way either.
|
|
27
|
-
|
|
28
|
-
**1. Eclipse ADT talks to cloud over HTTP, not RFC.**
|
|
29
|
-
The `com.sap.adt.communication.http.*` package is the only transport Eclipse ADT uses for ADT itself. Cloud login in Eclipse goes through `SamlWithReentranceTicketLogonFacade` → `IcfEndpointBasedSystemUrlInfoProvider` → `HttpLowLevelConnection.sendRequest`. This is an HTTP flow via the ABAP ICF (Internet Communication Framework) endpoint, with a browser SAML login minting a short-lived reentrance ticket, which is then exchanged for a `MYSAPSSO2` session cookie over HTTP. There is no RFC anywhere in this path. JCo/RFC calls that appear in Eclipse logs come from unrelated features (GUI integration, JCo destination tests) — not ADT.
|
|
30
|
-
|
|
31
|
-
**2. NW RFC SDK has no JWT or SAML-2.0-XML logon parameter.**
|
|
32
|
-
Inspection of `sapnwrfc.h` and the SDK's reference `sapnwrfc.ini` confirms the supported client logon parameters are: `USER`/`PASSWD`, `X509CERT`, `MYSAPSSO2` (accepts SSO2 tickets and SAP-internal "assertion tickets", *not* SAML 2.0 XML assertions), plus SNC (`SNC_QOP`, `SNC_MYNAME`, `SNC_PARTNERNAME`, `SNC_LIB`) for Kerberos/x509 over RFC. For WebSocket-RFC: `WSHOST`/`WSPORT`, `ALIAS_USER`, `TLS_CLIENT_PSE`, `TLS_CLIENT_CERTIFICATE_LOGON`. No `JWT`, no `BEARER`, no `SAML_ASSERTION`, no `OAUTH` keys exist in the SDK headers.
|
|
33
|
-
|
|
34
|
-
**3. `@mcp-abap-adt/sap-rfc-lite` is a pure passthrough.**
|
|
35
|
-
It forwards every `(name, value)` pair from the JS `Client(params)` object to `RFC_CONNECTION_PARAMETER[]` without filtering. So the wrapper is not a constraint — the constraint is the SDK itself.
|
|
36
|
-
|
|
37
|
-
**4. For BTP on-prem scenarios (Cloud Connector), the JWT→x509/SNC swap happens server-side in the CC.** The client-side RFC call still carries classic credentials (x509 + SNC), not the JWT. Supporting that would be adding SNC-over-RFC for on-prem backends behind a CC tunnel — an on-prem extension, not a "cloud RFC" feature.
|
|
38
|
-
|
|
39
|
-
**Conclusion:** "RFC to cloud" is not a missing feature that would be useful to add; it is a category error. ADT to cloud = HTTP (already supported here). RFC to on-prem = supported here, by handing `AdtOnPremConnector` an `RfcTransport`. Anything claiming a third combination does not map to what the SAP stack actually exposes.
|
|
40
|
-
|
|
41
|
-
## See also
|
|
42
|
-
|
|
43
|
-
- [`INSTALLATION.md`](./INSTALLATION.md)
|
|
44
|
-
- [`USAGE.md`](./USAGE.md)
|
|
45
|
-
- Sibling packages: `@mcp-abap-adt/interfaces-adt-connection`, `@mcp-abap-adt/interfaces-auth`, `@mcp-abap-adt/interfaces-auth-sap`, `@mcp-abap-adt/interfaces-network`, `@mcp-abap-adt/interfaces-utils`, `@mcp-abap-adt/auth-errors` (mints and classifies every auth refusal), `@mcp-abap-adt/sap-rfc-lite`, `@mcp-abap-adt/auth-broker`
|
|
1
|
+
# Scope
|
|
2
|
+
|
|
3
|
+
`@mcp-abap-adt/connection` answers for this, and only this:
|
|
4
|
+
|
|
5
|
+
1. **Building a connection.** `createConnection({ system, transport, … })`: cloud + HTTP,
|
|
6
|
+
on-prem + HTTP, on-prem + legacy HTTP (BASIS 7.40), on-prem + RFC. The caller states
|
|
7
|
+
the system and the transport; nothing is inferred.
|
|
8
|
+
2. **One instance, one SAP session.** `connect()` logs on; the first authenticated request
|
|
9
|
+
opens the session. A new session is a new instance. An instance may instead be built on
|
|
10
|
+
an existing session: `createConnection({ …, session })` takes that session's cookies;
|
|
11
|
+
`connect()` does not log on, and SAP's answer to the first request says whether the
|
|
12
|
+
session is alive. The cookies of the instance's session are readable (`sessionCookies()`),
|
|
13
|
+
for the caller to keep.
|
|
14
|
+
3. **Requests.** Each carries the credential the `IAuthProvider` hands over, the CSRF token
|
|
15
|
+
and the session's cookies. A request is sent stateful (`LOCK`, `UNLOCK`, activation) or
|
|
16
|
+
stateless; nothing else of the session is kept between requests. A request carries no
|
|
17
|
+
deadline but the caller's own timeout.
|
|
18
|
+
4. **SAP's answer** reaches the caller as SAP gave it.
|
|
19
|
+
5. **`disconnect()`, once.** It sends the logoff when the instance holds a live
|
|
20
|
+
`SAP_SESSIONID` and resolves when the logoff is written. A `connect()` that failed after
|
|
21
|
+
opening a session logs it off before it rejects. `flushGoodbye(ms?)` waits for SAP's
|
|
22
|
+
answer to the logoff.
|
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
> and context cookie. Another handler can flip it back while your lock is open. Nothing in this
|
|
6
6
|
> layer tracks locks: that belongs to `@mcp-abap-adt/adt-clients`, which holds the
|
|
7
7
|
> handles and pairs each LOCK with its UNLOCK per object. What the connection
|
|
8
|
-
> offers is `beginCriticalSection()` / `endCriticalSection()`,
|
|
9
|
-
>
|
|
8
|
+
> offers is `beginCriticalSection()` / `endCriticalSection()`, inside which a
|
|
9
|
+
> request carries no deadline at all, so nothing cuts it mid-span. See
|
|
10
10
|
> [USAGE.md — Session Lifecycle](./USAGE.md#session-lifecycle).
|
|
11
11
|
|
|
12
12
|
|
|
@@ -81,7 +81,7 @@ is what every stateless call cost with `sap-rfc-lite` 0.1.x (and with 0.2.0,
|
|
|
81
81
|
whose npm package lacks the reset), and why 9.4.2 requires 0.2.1. Direct connector users must mark
|
|
82
82
|
LOCK and UNLOCK stateful to retain their conversation. If disconnect occurs
|
|
83
83
|
while a temporary conversation is logging on, it is closed without sending
|
|
84
|
-
the request;
|
|
84
|
+
the request; a new connection does not revive that pending request.
|
|
85
85
|
|
|
86
86
|
## Enabling Stateful Sessions
|
|
87
87
|
|
|
@@ -106,7 +106,6 @@ const logger = console;
|
|
|
106
106
|
import {
|
|
107
107
|
AdtOnPremConnector,
|
|
108
108
|
OnPremHttpTransport,
|
|
109
|
-
getTimeout,
|
|
110
109
|
} from '@mcp-abap-adt/connection';
|
|
111
110
|
import { BasicAuthProvider } from '@mcp-abap-adt/auth-providers';
|
|
112
111
|
|
|
@@ -125,7 +124,7 @@ await connection.connect(); // required before any request
|
|
|
125
124
|
connection.setSessionType('stateful');
|
|
126
125
|
|
|
127
126
|
// Following requests use the stateful context until the mode is changed
|
|
128
|
-
await connection.makeAdtRequest({ method: 'GET', url: '/sap/bc/adt/discovery' , timeout:
|
|
127
|
+
await connection.makeAdtRequest({ method: 'GET', url: '/sap/bc/adt/discovery' , timeout: 0 });
|
|
129
128
|
|
|
130
129
|
// Switch back to stateless
|
|
131
130
|
connection.setSessionType('stateless');
|
|
@@ -172,51 +171,47 @@ Every ADT request issued through `makeAdtRequest` automatically:
|
|
|
172
171
|
|
|
173
172
|
This logic is transparent to callers (Builders, handlers, CLI scripts).
|
|
174
173
|
|
|
175
|
-
A
|
|
176
|
-
something after its caller aborted: the upfront token fetch, the send itself,
|
|
177
|
-
the CSRF retry, the cookie retry of a GET and the provider's renewal below. Each
|
|
178
|
-
wait in between — the provider's `authorize()` and `rejected()`, a logon, the
|
|
179
|
-
token exchange, an RFC conversation's `open()` — ends for that caller at the
|
|
180
|
-
abort, with `ADT_REQUEST_ABORTED`; the session's token and cookies are left as
|
|
181
|
-
they are, for the requests still running on them. A request already on the wire
|
|
182
|
-
is not recalled. See [USAGE.md — Cancelling a request](./USAGE.md#cancelling-a-request).
|
|
183
|
-
|
|
184
|
-
A 401 that survives the wire's own CSRF recovery is put to the provider (`rejected`). On Ok the
|
|
174
|
+
A 401 that survives the wire's own CSRF recovery (in the same session) is put to the provider (`rejected`). On Ok the
|
|
185
175
|
request is sent once more, always under the same lease and generation as the attempt it repeats,
|
|
186
176
|
so stale-request fencing applies. After a rejection at `'request'` that resend goes out on the
|
|
187
177
|
same session; after a rejection at `'logon'` the wire logs on again before the resend.
|
|
188
|
-
**
|
|
178
|
+
**No 401 opens a new session, and the lock in the session is kept:** a mutation
|
|
189
179
|
(POST / PUT / DELETE) refused with a 401 while a CSRF token is cached goes to the provider and is
|
|
190
|
-
resent on the same session with the same token,
|
|
191
|
-
fails with `SESSION_REPLACED` instead of carrying on in a new one.
|
|
192
|
-
that mutation
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
**
|
|
196
|
-
the SAME session cookie (no `Set-Cookie`), the connection cannot tell it
|
|
197
|
-
credential — the second 401 ends the request as `AuthRefusedError` with the
|
|
198
|
-
verdict (`at: 'request'`), not `SESSION_REPLACED`, and the connection stays
|
|
199
|
-
|
|
200
|
-
a new lock.
|
|
180
|
+
resent on the same session with the same token, inside a critical section or not, and if SAP did
|
|
181
|
+
replace the session the request fails with `SESSION_REPLACED` instead of carrying on in a new one.
|
|
182
|
+
Before 16.0.0, outside a critical section, that mutation discarded the session and retried in a
|
|
183
|
+
new one on the same instance; that recovery is gone. One instance is one session: if you want a
|
|
184
|
+
new session after a 401, create a new connection.
|
|
185
|
+
**A dead session can look like a refused credential:** when the session is really dead but SAP
|
|
186
|
+
answers the resend with the SAME session cookie (no `Set-Cookie`), the connection cannot tell it
|
|
187
|
+
from a refused credential — the second 401 ends the request as `AuthRefusedError` with the
|
|
188
|
+
refused-again verdict (`at: 'request'`), not `SESSION_REPLACED`, and the connection stays
|
|
189
|
+
connected. Treat that as a lost session, and any lock in it as lost: `disconnect()`, create a new
|
|
190
|
+
connection, and redo the work under a new lock there.
|
|
201
191
|
If the provider says no, or the retry is refused too, the caller gets an `AuthRefusedError` (the refused-again verdict is `refusal.kind === 'connection'`, `facts.problem === 'refused-after-renewal'`). A 403 is an authorization answer, not a credential one: it never goes to the
|
|
202
192
|
provider. See [When the credential is refused](./USAGE.md#when-the-credential-is-refused).
|
|
203
193
|
|
|
204
|
-
|
|
194
|
+
**One connection instance is one session.** After `disconnect()`, or a failed `connect()` that
|
|
195
|
+
received a session cookie (whether or not a logoff was sent for it), the instance is spent and `connect()` on it rejects `NOT_CONNECTED`. A new
|
|
196
|
+
session is a new instance, created by the consumer (its own factory, or `createConnection`), and
|
|
197
|
+
outside a lock window rather than inside one.
|
|
205
198
|
|
|
206
|
-
**Wait for the goodbye before opening the next one.** `disconnect()`
|
|
207
|
-
not
|
|
208
|
-
still
|
|
199
|
+
**Wait for the goodbye before opening the next one.** `disconnect()` resolves once the logoff is
|
|
200
|
+
written, not answered, so a new connection otherwise opens the next session while the previous
|
|
201
|
+
one's goodbye is still unanswered, and the server keeps both:
|
|
209
202
|
|
|
210
203
|
```typescript
|
|
211
204
|
await conn.disconnect();
|
|
212
|
-
await conn.flushGoodbye(); //
|
|
213
|
-
|
|
205
|
+
await conn.flushGoodbye(); // wait for the goodbye's answer; flushGoodbye(ms) bounds it
|
|
206
|
+
const next = createYourConnection(); // a new instance for the new session
|
|
207
|
+
await next.connect();
|
|
214
208
|
```
|
|
215
209
|
|
|
216
210
|
Measured on E19 through a harness that recycled the session after each test: a new ABAP session
|
|
217
211
|
every one to two seconds for a whole run, none released, each living to its own thirty-minute idle
|
|
218
|
-
timeout.
|
|
219
|
-
|
|
212
|
+
timeout. Without an argument `flushGoodbye()` waits for the answer as long as SAP takes; a budget
|
|
213
|
+
you pass bounds the waiting, not the overlap — if the goodbye finishes in time there is none, and if
|
|
214
|
+
it does not you proceed while it stays outstanding. Calling `disconnect()` again is not
|
|
220
215
|
a substitute: a repeat call does not wait either.
|
|
221
216
|
|
|
222
217
|
---
|
|
@@ -246,7 +241,7 @@ The link to the ABAP session is not guaranteed, and that is the whole problem:
|
|
|
246
241
|
Both are reported, neither is worked around. `connect()` fails with the reason
|
|
247
242
|
when no session was opened; a session lost afterwards surfaces as
|
|
248
243
|
`ADT_SESSION_REPLACED` rather than a request quietly continuing somewhere it
|
|
249
|
-
does not belong. What to do about either — wait, retry,
|
|
244
|
+
does not belong. What to do about either — wait, retry, create a new connection, release
|
|
250
245
|
sessions the user still holds, carry on read-only — is the caller's decision,
|
|
251
246
|
made with the cookies and the answers in hand.
|
|
252
247
|
|
|
@@ -284,20 +279,23 @@ server's own timeout releases them together.
|
|
|
284
279
|
This is what makes an aborted request expensive, and it is not what it looks
|
|
285
280
|
like. Aborting costs you **knowledge**, not a session: whether the modification
|
|
286
281
|
was applied becomes unknowable, and the handle `unlock` needs is gone, while the
|
|
287
|
-
lock is still very much held.
|
|
288
|
-
|
|
289
|
-
|
|
282
|
+
lock is still very much held. And SAP, seeing the socket close, ends the
|
|
283
|
+
synchronous request that was running on it — a write in it is lost. That — not
|
|
284
|
+
any teardown — is why a request inside `beginCriticalSection()` carries no
|
|
285
|
+
deadline at all for the duration of a `lock → modify → unlock` chain.
|
|
290
286
|
|
|
291
287
|
Since 8.0.0 you reach it through the contract rather than the class: it is
|
|
292
288
|
`ICriticalSection` in `@mcp-abap-adt/interfaces-adt-connection`, which this connection declares.
|
|
293
|
-
What it promises is narrow and worth stating exactly — inside a section
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
289
|
+
What it promises is narrow and worth stating exactly — inside a section no
|
|
290
|
+
deadline of this package's applies, and the caller's per-request `timeout` is
|
|
291
|
+
not applied either (17.0.0; before, a ten-minute `SAP_TIMEOUT_CRITICAL` ceiling
|
|
292
|
+
replaced it). Not that no request can be cut short: the network, a proxy or the
|
|
293
|
+
server's own limits end a request whatever a contract says.
|
|
297
294
|
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
295
|
+
A section keeps its session through a credential renewal: a mutation refused
|
|
296
|
+
with a 401 inside it is renewed and resent on the same session, never moved to
|
|
297
|
+
a new one. Since 16.0.0 that holds outside a section too: no 401 moves a
|
|
298
|
+
request to a new session (see [Request Hooks](#request-hooks)).
|
|
301
299
|
|
|
302
300
|
### Two sessions, and they are not the same thing
|
|
303
301
|
|
|
@@ -348,7 +346,8 @@ you get by asking — `getSessionIdentity()` for which session you are in, and
|
|
|
348
346
|
## Troubleshooting
|
|
349
347
|
|
|
350
348
|
- **CSRF token errors**: discard the session and establish a new one. That is
|
|
351
|
-
`disconnect()
|
|
349
|
+
`disconnect()`, then a NEW connection's `connect()` — one instance is one
|
|
350
|
+
session — and there is no local-only discard, because
|
|
352
351
|
dropping the cookie leaves the ABAP session open on the server. Both live on
|
|
353
352
|
the HTTP connection classes and are **not** on the `IAbapConnection` type
|
|
354
353
|
a bare `IAbapConnection` carries — reach them through a connector type, or
|
|
@@ -360,9 +359,10 @@ import { BasicAuthProvider } from '@mcp-abap-adt/auth-providers';
|
|
|
360
359
|
|
|
361
360
|
const connection = new AdtOnPremConnector(config, new BasicAuthProvider(user, pass), new OnPremHttpTransport(() => ({}), logger, { client: config.client, baseUrl: config.url }), logger);
|
|
362
361
|
await connection.disconnect(); // ends the session on the server, then clears
|
|
363
|
-
|
|
362
|
+
const next = new AdtOnPremConnector(config, new BasicAuthProvider(user, pass), new OnPremHttpTransport(() => ({}), logger, { client: config.client, baseUrl: config.url }), logger);
|
|
363
|
+
await next.connect(); // a new session is a new instance
|
|
364
364
|
```
|
|
365
|
-
- **Session expired**:
|
|
365
|
+
- **Session expired**: create a new connection; a new session is a new instance.
|
|
366
366
|
- **Multiple connections**: each connector holds its own wire, and the wire holds the cookie jar; share the instance if you need continuity.
|
|
367
367
|
|
|
368
368
|
---
|