@kumiai/rpc 0.12.0 → 0.12.2
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/lib/hub-mux.js +17 -6
- package/lib/peer-epoch.js +3 -0
- package/lib/peer.js +3 -0
- package/package.json +6 -6
package/lib/hub-mux.js
CHANGED
|
@@ -127,9 +127,6 @@ const warnReceiveEnded = (ended)=>{
|
|
|
127
127
|
* whose `subscribe` registers synchronously is registered by the time `retain` returns — the
|
|
128
128
|
* subscribe-then-pull ordering the commit lane depends on is unchanged.
|
|
129
129
|
*/ const attemptSubscribe = async (topicID, options, attempt)=>{
|
|
130
|
-
subscriptions.set(topicID, {
|
|
131
|
-
kind: 'asking'
|
|
132
|
-
});
|
|
133
130
|
try {
|
|
134
131
|
// Inside the try, and awaited: `subscribe` may reject OR throw synchronously (the type
|
|
135
132
|
// allows `void`), and the old code's `Promise.resolve(...).catch()` caught only the first.
|
|
@@ -164,6 +161,18 @@ const warnReceiveEnded = (ended)=>{
|
|
|
164
161
|
await attemptSubscribe(topicID, options, attempt + 1);
|
|
165
162
|
}
|
|
166
163
|
};
|
|
164
|
+
const startSubscribe = (topicID, options)=>{
|
|
165
|
+
// Not `Promise.withResolvers`: this runs on Hermes too. `attemptSubscribe` never rejects.
|
|
166
|
+
let settle = ()=>{};
|
|
167
|
+
const ready = new Promise((resolve)=>{
|
|
168
|
+
settle = resolve;
|
|
169
|
+
});
|
|
170
|
+
subscriptions.set(topicID, {
|
|
171
|
+
kind: 'asking',
|
|
172
|
+
ready
|
|
173
|
+
});
|
|
174
|
+
void attemptSubscribe(topicID, options, 0).finally(settle);
|
|
175
|
+
};
|
|
167
176
|
const retain = (topicID, options)=>{
|
|
168
177
|
refcount.set(topicID, (refcount.get(topicID) ?? 0) + 1);
|
|
169
178
|
// Gated on the SUBSCRIPTION, never on the refcount. A topic held, or currently being asked
|
|
@@ -171,7 +180,7 @@ const warnReceiveEnded = (ended)=>{
|
|
|
171
180
|
// hold it, and the data structure must not pretend otherwise.
|
|
172
181
|
const state = subscriptions.get(topicID);
|
|
173
182
|
if (state == null) {
|
|
174
|
-
|
|
183
|
+
startSubscribe(topicID, options);
|
|
175
184
|
return;
|
|
176
185
|
}
|
|
177
186
|
if (state.kind !== 'refused') return;
|
|
@@ -185,7 +194,7 @@ const warnReceiveEnded = (ended)=>{
|
|
|
185
194
|
if (state.permanent && (options?.retention == null || options.retention === state.options?.retention)) {
|
|
186
195
|
return;
|
|
187
196
|
}
|
|
188
|
-
|
|
197
|
+
startSubscribe(topicID, options);
|
|
189
198
|
};
|
|
190
199
|
/**
|
|
191
200
|
* Clear a latched refusal so the topic is asked for once more, on the caller's word that the
|
|
@@ -209,7 +218,7 @@ const warnReceiveEnded = (ended)=>{
|
|
|
209
218
|
const { options } = state;
|
|
210
219
|
subscriptions.delete(topicID);
|
|
211
220
|
if ((refcount.get(topicID) ?? 0) > 0) {
|
|
212
|
-
|
|
221
|
+
startSubscribe(topicID, options);
|
|
213
222
|
}
|
|
214
223
|
};
|
|
215
224
|
/**
|
|
@@ -557,6 +566,8 @@ const warnReceiveEnded = (ended)=>{
|
|
|
557
566
|
// A fetch of a refused topic would die of `NotSubscribedError` — the SYMPTOM, naming the mux's
|
|
558
567
|
// own failure to subscribe as if it were the caller's mistake. The latched refusal is raised
|
|
559
568
|
// instead, so what reaches the host is the reason.
|
|
569
|
+
const state = subscriptions.get(params.topicID);
|
|
570
|
+
if (state?.kind === 'asking') await state.ready;
|
|
560
571
|
assertSubscribable(params.topicID);
|
|
561
572
|
// Called on `hub`, not through a detached reference: a LogHub is often a class, and
|
|
562
573
|
// an unbound method loses its receiver.
|
package/lib/peer-epoch.js
CHANGED
|
@@ -3,6 +3,7 @@ import { BroadcastClient, createBroadcastResponder, createBroadcastTransport, en
|
|
|
3
3
|
import { decodeAppAAD, encodeAppAAD } from './app-aad.js';
|
|
4
4
|
import { isFrameAhead } from './crypto.js';
|
|
5
5
|
import { createDirectedClient, createInboxAcceptor, createInboxPath, createUnroutedTagResponder } from './directed.js';
|
|
6
|
+
import { PeerDisposedError } from './errors.js';
|
|
6
7
|
import { assertFrameFits } from './frame-size.js';
|
|
7
8
|
import { adaptBusHandlers } from './handlers.js';
|
|
8
9
|
import { wrapGatherOptions } from './host-boundary.js';
|
|
@@ -233,6 +234,7 @@ import { inboxTopic, protocolTopic } from './topic.js';
|
|
|
233
234
|
};
|
|
234
235
|
/** Wait while an advance can move the handle before its new anchor is captured. */ const sealForSegment = async (name, bytes, intent = 'ephemeral')=>{
|
|
235
236
|
while(true){
|
|
237
|
+
if (isDisposed()) throw new PeerDisposedError('Peer is disposed');
|
|
236
238
|
const refused = sealError();
|
|
237
239
|
if (refused != null) throw refused;
|
|
238
240
|
const barrier = sealBarrier();
|
|
@@ -248,6 +250,7 @@ import { inboxTopic, protocolTopic } from './topic.js';
|
|
|
248
250
|
intent
|
|
249
251
|
})
|
|
250
252
|
});
|
|
253
|
+
if (isDisposed()) throw new PeerDisposedError('Peer is disposed');
|
|
251
254
|
const refusedAfter = sealError();
|
|
252
255
|
if (refusedAfter != null) throw refusedAfter;
|
|
253
256
|
if (anchor() === at && sealBarrier() == null) {
|
package/lib/peer.js
CHANGED
|
@@ -2702,6 +2702,9 @@ export function createGroupPeer(input) {
|
|
|
2702
2702
|
dispose: ()=>{
|
|
2703
2703
|
if (disposePromise != null) return disposePromise;
|
|
2704
2704
|
disposed = true;
|
|
2705
|
+
// Rotation can no longer release sealing writes that transport teardown must drain.
|
|
2706
|
+
sealError = new PeerDisposedError('Peer is disposed');
|
|
2707
|
+
finishSealBarrier();
|
|
2705
2708
|
appOutboxAcceptance?.close();
|
|
2706
2709
|
logDelivery?.close();
|
|
2707
2710
|
clearRecoveryRetry();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kumiai/rpc",
|
|
3
|
-
"version": "0.12.
|
|
3
|
+
"version": "0.12.2",
|
|
4
4
|
"description": "High-level MLS-aware group RPC for Enkaku: bus broadcast/anycast/gather plus directed RPC over the pub/sub hub",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"rpc",
|
|
@@ -26,11 +26,11 @@
|
|
|
26
26
|
"lib/*"
|
|
27
27
|
],
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@enkaku/client": "^0.22.
|
|
30
|
-
"@enkaku/protocol": "^0.22.
|
|
31
|
-
"@enkaku/server": "^0.22.
|
|
32
|
-
"@enkaku/transport": "^0.22.
|
|
33
|
-
"@kokuin/token": "^0.6.
|
|
29
|
+
"@enkaku/client": "^0.22.3",
|
|
30
|
+
"@enkaku/protocol": "^0.22.3",
|
|
31
|
+
"@enkaku/server": "^0.22.3",
|
|
32
|
+
"@enkaku/transport": "^0.22.3",
|
|
33
|
+
"@kokuin/token": "^0.6.4",
|
|
34
34
|
"@kumiai/broadcast": "^0.12.0",
|
|
35
35
|
"@kumiai/hub-protocol": "^0.12.0",
|
|
36
36
|
"@kumiai/hub-tunnel": "^0.12.0",
|