@astrale-os/kernel-client 1.0.0-beta.14 → 1.0.0-beta.17
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.
|
@@ -5,6 +5,7 @@ import { invocationFailure } from '../failure.js';
|
|
|
5
5
|
import { asError, controlledSignal, positiveInteger, requireLive, } from '../index.js';
|
|
6
6
|
import { admitResponse } from './admission.js';
|
|
7
7
|
import { capture } from './configuration.js';
|
|
8
|
+
import { unprocessed } from './unprocessed.js';
|
|
8
9
|
/** HTTP implementation of the universal invocation protocol. */
|
|
9
10
|
export class HttpTransport {
|
|
10
11
|
url;
|
|
@@ -74,7 +75,9 @@ export class HttpTransport {
|
|
|
74
75
|
return result;
|
|
75
76
|
}
|
|
76
77
|
catch (error) {
|
|
77
|
-
|
|
78
|
+
// A request the server refused unprocessed, even when sent again, was never delivered.
|
|
79
|
+
const proven = phase === 'send' && unprocessed(error) ? 'not-sent' : delivery;
|
|
80
|
+
throw transportFailure(error, control, options.signal, timeoutMs, this.url, phase, proven);
|
|
78
81
|
}
|
|
79
82
|
finally {
|
|
80
83
|
if (!handedOff)
|
|
@@ -103,7 +106,16 @@ export class HttpTransport {
|
|
|
103
106
|
body: binaryBody ?? toBody(encoded),
|
|
104
107
|
signal: control.signal,
|
|
105
108
|
};
|
|
106
|
-
|
|
109
|
+
try {
|
|
110
|
+
return await this.fetchImpl(this.url, init);
|
|
111
|
+
}
|
|
112
|
+
catch (error) {
|
|
113
|
+
// The server processed none of it: send it once more, on the connection that replaces the
|
|
114
|
+
// one that refused it, under the same timeout and signal (CLIENT-HTTP-UNPROCESSED-RESEND).
|
|
115
|
+
if (!unprocessed(error) || control.signal.aborted)
|
|
116
|
+
throw error;
|
|
117
|
+
return this.fetchImpl(this.url, init);
|
|
118
|
+
}
|
|
107
119
|
}
|
|
108
120
|
nextRequestId() {
|
|
109
121
|
const requestId = this.nextId;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The failure undici's Fetch reports for a request that an HTTP/2 GOAWAY with NO_ERROR refused: one
|
|
3
|
+
* whose stream it never opened, or opened above the GOAWAY's last stream identifier. The server
|
|
4
|
+
* processed none of them (RFC 9113, Section 6.8). undici sends such a request again itself only
|
|
5
|
+
* when its body can be replayed, which a Fetch request body, always a stream, cannot.
|
|
6
|
+
*/
|
|
7
|
+
const GOAWAY_REFUSAL = Object.freeze({
|
|
8
|
+
code: 'UND_ERR_INFO',
|
|
9
|
+
message: 'HTTP/2: "GOAWAY" frame received with code 0',
|
|
10
|
+
});
|
|
11
|
+
/** Causes a Fetch failure wraps before the one that names the refusal. */
|
|
12
|
+
const MAXIMUM_CAUSES = 4;
|
|
13
|
+
/**
|
|
14
|
+
* Whether a Fetch failure proves that the server never processed the request. Only the exact
|
|
15
|
+
* refusal above does: any other failure, or a refusal reported in other words, proves nothing.
|
|
16
|
+
*/
|
|
17
|
+
export function unprocessed(failure) {
|
|
18
|
+
let cause = failure;
|
|
19
|
+
for (let depth = 0; depth <= MAXIMUM_CAUSES; depth++) {
|
|
20
|
+
if (typeof cause !== 'object' || cause === null)
|
|
21
|
+
return false;
|
|
22
|
+
const { code, message } = cause;
|
|
23
|
+
if (code === GOAWAY_REFUSAL.code && message === GOAWAY_REFUSAL.message)
|
|
24
|
+
return true;
|
|
25
|
+
cause = cause.cause;
|
|
26
|
+
}
|
|
27
|
+
return false;
|
|
28
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@astrale-os/kernel-client",
|
|
3
|
-
"version": "1.0.0-beta.
|
|
3
|
+
"version": "1.0.0-beta.17",
|
|
4
4
|
"description": "Universal Client — protocol-first, transport-agnostic",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"astrale",
|
|
@@ -65,16 +65,17 @@
|
|
|
65
65
|
"access": "public"
|
|
66
66
|
},
|
|
67
67
|
"dependencies": {
|
|
68
|
-
"@astrale-os/kernel-core": "1.0.0-beta.
|
|
69
|
-
"@astrale-os/kernel-dsl": "1.0.0-beta.
|
|
70
|
-
"@astrale-os/kernel-protocol": "1.0.0-beta.
|
|
68
|
+
"@astrale-os/kernel-core": "1.0.0-beta.14",
|
|
69
|
+
"@astrale-os/kernel-dsl": "1.0.0-beta.7",
|
|
70
|
+
"@astrale-os/kernel-protocol": "1.0.0-beta.14",
|
|
71
71
|
"@tanstack/pacer": "0.20.1"
|
|
72
72
|
},
|
|
73
73
|
"devDependencies": {
|
|
74
|
-
"@astrale-os/kernel-server": "1.0.0-beta.
|
|
74
|
+
"@astrale-os/kernel-server": "1.0.0-beta.14",
|
|
75
75
|
"@astrale/typescript-config": "npm:@jsr/astrale__typescript-config@~1.1.0",
|
|
76
76
|
"@types/node": "^22.0.0",
|
|
77
77
|
"typescript": "7.0.2",
|
|
78
|
+
"undici": "8.10.0",
|
|
78
79
|
"vitest": "^5.0.1"
|
|
79
80
|
},
|
|
80
81
|
"scripts": {
|