@naylence/runtime 0.3.5-test.958 → 0.3.5-test.959
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/dist/browser/index.cjs +50 -25
- package/dist/browser/index.mjs +50 -25
- package/dist/cjs/naylence/fame/connector/base-async-connector.js +40 -2
- package/dist/cjs/naylence/fame/connector/websocket-connector.js +0 -3
- package/dist/cjs/naylence/fame/util/lock.js +8 -18
- package/dist/cjs/version.js +2 -2
- package/dist/esm/naylence/fame/connector/base-async-connector.js +40 -2
- package/dist/esm/naylence/fame/connector/websocket-connector.js +0 -3
- package/dist/esm/naylence/fame/util/lock.js +8 -18
- package/dist/esm/version.js +2 -2
- package/dist/node/index.cjs +50 -25
- package/dist/node/index.mjs +50 -25
- package/dist/node/node.cjs +50 -25
- package/dist/node/node.mjs +50 -25
- package/dist/types/naylence/fame/util/lock.d.ts +2 -3
- package/dist/types/version.d.ts +1 -1
- package/package.json +1 -1
package/dist/browser/index.cjs
CHANGED
|
@@ -98,12 +98,12 @@ installProcessEnvShim();
|
|
|
98
98
|
// --- END ENV SHIM ---
|
|
99
99
|
|
|
100
100
|
// This file is auto-generated during build - do not edit manually
|
|
101
|
-
// Generated from package.json version: 0.3.5-test.
|
|
101
|
+
// Generated from package.json version: 0.3.5-test.959
|
|
102
102
|
/**
|
|
103
103
|
* The package version, injected at build time.
|
|
104
104
|
* @internal
|
|
105
105
|
*/
|
|
106
|
-
const VERSION = '0.3.5-test.
|
|
106
|
+
const VERSION = '0.3.5-test.959';
|
|
107
107
|
|
|
108
108
|
/**
|
|
109
109
|
* Fame protocol specific error classes with WebSocket close codes and proper inheritance.
|
|
@@ -1358,38 +1358,28 @@ class TaskSpawner {
|
|
|
1358
1358
|
}
|
|
1359
1359
|
}
|
|
1360
1360
|
|
|
1361
|
-
// import { getLogger } from './logging.js';
|
|
1362
|
-
// const logger = getLogger('naylence.fame.util.lock');
|
|
1363
1361
|
class AsyncLock {
|
|
1364
1362
|
constructor() {
|
|
1365
|
-
this.
|
|
1363
|
+
this.tail = Promise.resolve();
|
|
1366
1364
|
}
|
|
1367
|
-
async
|
|
1368
|
-
const currentQueue = this.queue;
|
|
1365
|
+
async runExclusive(operation) {
|
|
1369
1366
|
let release;
|
|
1370
|
-
const
|
|
1367
|
+
const next = new Promise((resolve) => {
|
|
1371
1368
|
release = resolve;
|
|
1372
1369
|
});
|
|
1373
|
-
|
|
1374
|
-
this.
|
|
1375
|
-
|
|
1376
|
-
// logger.debug('waiting_for_lock');
|
|
1377
|
-
await currentQueue;
|
|
1378
|
-
// logger.debug('lock_acquired');
|
|
1370
|
+
const previous = this.tail;
|
|
1371
|
+
this.tail = previous.then(() => next, () => next);
|
|
1372
|
+
await previous;
|
|
1379
1373
|
try {
|
|
1380
|
-
return await
|
|
1374
|
+
return await operation();
|
|
1381
1375
|
}
|
|
1382
1376
|
finally {
|
|
1383
1377
|
release();
|
|
1384
|
-
// logger.debug('lock_released');
|
|
1385
1378
|
}
|
|
1386
1379
|
}
|
|
1387
|
-
async runExclusive(task) {
|
|
1388
|
-
return this.acquire(task);
|
|
1389
|
-
}
|
|
1390
1380
|
}
|
|
1391
1381
|
async function withLock(lock, operation) {
|
|
1392
|
-
return await lock.
|
|
1382
|
+
return await lock.runExclusive(operation);
|
|
1393
1383
|
}
|
|
1394
1384
|
|
|
1395
1385
|
/**
|
|
@@ -9686,11 +9676,31 @@ class BaseAsyncConnector extends TaskSpawner {
|
|
|
9686
9676
|
* Emit credit update if flow control needs refill
|
|
9687
9677
|
*/
|
|
9688
9678
|
async _maybeEmitCredit(flowId, traceId) {
|
|
9689
|
-
|
|
9679
|
+
const remainingCredits = this._flowCtrl.getCredits(flowId);
|
|
9680
|
+
const needsRefill = this._flowCtrl.needsRefill(flowId);
|
|
9681
|
+
logger$$.debug('maybe_emit_credit_check', {
|
|
9682
|
+
connector_id: this._connectorFlowId,
|
|
9683
|
+
flow_id: flowId,
|
|
9684
|
+
trace_id: traceId ?? null,
|
|
9685
|
+
remaining_credits: remainingCredits,
|
|
9686
|
+
low_watermark: this._flowCtrl instanceof FlowController
|
|
9687
|
+
? this._flowCtrl.lowWatermark
|
|
9688
|
+
: null,
|
|
9689
|
+
initial_window: this._initialWindow,
|
|
9690
|
+
needs_refill: needsRefill,
|
|
9691
|
+
});
|
|
9692
|
+
if (!needsRefill) {
|
|
9690
9693
|
return;
|
|
9691
9694
|
}
|
|
9692
9695
|
const delta = this._initialWindow;
|
|
9693
9696
|
this._flowCtrl.addCredits(flowId, delta);
|
|
9697
|
+
logger$$.debug('maybe_emit_credit_emit', {
|
|
9698
|
+
connector_id: this._connectorFlowId,
|
|
9699
|
+
flow_id: flowId,
|
|
9700
|
+
trace_id: traceId ?? null,
|
|
9701
|
+
emitted_credits: delta,
|
|
9702
|
+
post_emit_balance: this._flowCtrl.getCredits(flowId),
|
|
9703
|
+
});
|
|
9694
9704
|
const ackEnv = core.createFameEnvelope({
|
|
9695
9705
|
...(traceId && { traceId }),
|
|
9696
9706
|
flowId,
|
|
@@ -9702,7 +9712,25 @@ class BaseAsyncConnector extends TaskSpawner {
|
|
|
9702
9712
|
},
|
|
9703
9713
|
flags: core.FlowFlags.ACK,
|
|
9704
9714
|
});
|
|
9705
|
-
|
|
9715
|
+
try {
|
|
9716
|
+
await this.send(ackEnv);
|
|
9717
|
+
logger$$.debug('maybe_emit_credit_sent', {
|
|
9718
|
+
connector_id: this._connectorFlowId,
|
|
9719
|
+
flow_id: flowId,
|
|
9720
|
+
trace_id: traceId ?? null,
|
|
9721
|
+
credits_acknowledged: delta,
|
|
9722
|
+
});
|
|
9723
|
+
}
|
|
9724
|
+
catch (error) {
|
|
9725
|
+
logger$$.error('maybe_emit_credit_send_failed', {
|
|
9726
|
+
connector_id: this._connectorFlowId,
|
|
9727
|
+
flow_id: flowId,
|
|
9728
|
+
trace_id: traceId ?? null,
|
|
9729
|
+
credits_attempted: delta,
|
|
9730
|
+
error: error instanceof Error ? error.message : String(error),
|
|
9731
|
+
});
|
|
9732
|
+
throw error;
|
|
9733
|
+
}
|
|
9706
9734
|
}
|
|
9707
9735
|
// ---------------------------------------------------------------------
|
|
9708
9736
|
// Shutdown Management
|
|
@@ -19981,9 +20009,6 @@ class WebSocketConnector extends BaseAsyncConnector {
|
|
|
19981
20009
|
// Browser WebSocket or Node.js ws client
|
|
19982
20010
|
this._websocket.send(data);
|
|
19983
20011
|
}
|
|
19984
|
-
logger$H.debug('websocket_sent_bytes', {
|
|
19985
|
-
byte_length: data.length,
|
|
19986
|
-
});
|
|
19987
20012
|
}
|
|
19988
20013
|
catch (error) {
|
|
19989
20014
|
// Handle WebSocket disconnection errors
|
package/dist/browser/index.mjs
CHANGED
|
@@ -96,12 +96,12 @@ installProcessEnvShim();
|
|
|
96
96
|
// --- END ENV SHIM ---
|
|
97
97
|
|
|
98
98
|
// This file is auto-generated during build - do not edit manually
|
|
99
|
-
// Generated from package.json version: 0.3.5-test.
|
|
99
|
+
// Generated from package.json version: 0.3.5-test.959
|
|
100
100
|
/**
|
|
101
101
|
* The package version, injected at build time.
|
|
102
102
|
* @internal
|
|
103
103
|
*/
|
|
104
|
-
const VERSION = '0.3.5-test.
|
|
104
|
+
const VERSION = '0.3.5-test.959';
|
|
105
105
|
|
|
106
106
|
/**
|
|
107
107
|
* Fame protocol specific error classes with WebSocket close codes and proper inheritance.
|
|
@@ -1356,38 +1356,28 @@ class TaskSpawner {
|
|
|
1356
1356
|
}
|
|
1357
1357
|
}
|
|
1358
1358
|
|
|
1359
|
-
// import { getLogger } from './logging.js';
|
|
1360
|
-
// const logger = getLogger('naylence.fame.util.lock');
|
|
1361
1359
|
class AsyncLock {
|
|
1362
1360
|
constructor() {
|
|
1363
|
-
this.
|
|
1361
|
+
this.tail = Promise.resolve();
|
|
1364
1362
|
}
|
|
1365
|
-
async
|
|
1366
|
-
const currentQueue = this.queue;
|
|
1363
|
+
async runExclusive(operation) {
|
|
1367
1364
|
let release;
|
|
1368
|
-
const
|
|
1365
|
+
const next = new Promise((resolve) => {
|
|
1369
1366
|
release = resolve;
|
|
1370
1367
|
});
|
|
1371
|
-
|
|
1372
|
-
this.
|
|
1373
|
-
|
|
1374
|
-
// logger.debug('waiting_for_lock');
|
|
1375
|
-
await currentQueue;
|
|
1376
|
-
// logger.debug('lock_acquired');
|
|
1368
|
+
const previous = this.tail;
|
|
1369
|
+
this.tail = previous.then(() => next, () => next);
|
|
1370
|
+
await previous;
|
|
1377
1371
|
try {
|
|
1378
|
-
return await
|
|
1372
|
+
return await operation();
|
|
1379
1373
|
}
|
|
1380
1374
|
finally {
|
|
1381
1375
|
release();
|
|
1382
|
-
// logger.debug('lock_released');
|
|
1383
1376
|
}
|
|
1384
1377
|
}
|
|
1385
|
-
async runExclusive(task) {
|
|
1386
|
-
return this.acquire(task);
|
|
1387
|
-
}
|
|
1388
1378
|
}
|
|
1389
1379
|
async function withLock(lock, operation) {
|
|
1390
|
-
return await lock.
|
|
1380
|
+
return await lock.runExclusive(operation);
|
|
1391
1381
|
}
|
|
1392
1382
|
|
|
1393
1383
|
/**
|
|
@@ -9684,11 +9674,31 @@ class BaseAsyncConnector extends TaskSpawner {
|
|
|
9684
9674
|
* Emit credit update if flow control needs refill
|
|
9685
9675
|
*/
|
|
9686
9676
|
async _maybeEmitCredit(flowId, traceId) {
|
|
9687
|
-
|
|
9677
|
+
const remainingCredits = this._flowCtrl.getCredits(flowId);
|
|
9678
|
+
const needsRefill = this._flowCtrl.needsRefill(flowId);
|
|
9679
|
+
logger$$.debug('maybe_emit_credit_check', {
|
|
9680
|
+
connector_id: this._connectorFlowId,
|
|
9681
|
+
flow_id: flowId,
|
|
9682
|
+
trace_id: traceId ?? null,
|
|
9683
|
+
remaining_credits: remainingCredits,
|
|
9684
|
+
low_watermark: this._flowCtrl instanceof FlowController
|
|
9685
|
+
? this._flowCtrl.lowWatermark
|
|
9686
|
+
: null,
|
|
9687
|
+
initial_window: this._initialWindow,
|
|
9688
|
+
needs_refill: needsRefill,
|
|
9689
|
+
});
|
|
9690
|
+
if (!needsRefill) {
|
|
9688
9691
|
return;
|
|
9689
9692
|
}
|
|
9690
9693
|
const delta = this._initialWindow;
|
|
9691
9694
|
this._flowCtrl.addCredits(flowId, delta);
|
|
9695
|
+
logger$$.debug('maybe_emit_credit_emit', {
|
|
9696
|
+
connector_id: this._connectorFlowId,
|
|
9697
|
+
flow_id: flowId,
|
|
9698
|
+
trace_id: traceId ?? null,
|
|
9699
|
+
emitted_credits: delta,
|
|
9700
|
+
post_emit_balance: this._flowCtrl.getCredits(flowId),
|
|
9701
|
+
});
|
|
9692
9702
|
const ackEnv = createFameEnvelope({
|
|
9693
9703
|
...(traceId && { traceId }),
|
|
9694
9704
|
flowId,
|
|
@@ -9700,7 +9710,25 @@ class BaseAsyncConnector extends TaskSpawner {
|
|
|
9700
9710
|
},
|
|
9701
9711
|
flags: FlowFlags.ACK,
|
|
9702
9712
|
});
|
|
9703
|
-
|
|
9713
|
+
try {
|
|
9714
|
+
await this.send(ackEnv);
|
|
9715
|
+
logger$$.debug('maybe_emit_credit_sent', {
|
|
9716
|
+
connector_id: this._connectorFlowId,
|
|
9717
|
+
flow_id: flowId,
|
|
9718
|
+
trace_id: traceId ?? null,
|
|
9719
|
+
credits_acknowledged: delta,
|
|
9720
|
+
});
|
|
9721
|
+
}
|
|
9722
|
+
catch (error) {
|
|
9723
|
+
logger$$.error('maybe_emit_credit_send_failed', {
|
|
9724
|
+
connector_id: this._connectorFlowId,
|
|
9725
|
+
flow_id: flowId,
|
|
9726
|
+
trace_id: traceId ?? null,
|
|
9727
|
+
credits_attempted: delta,
|
|
9728
|
+
error: error instanceof Error ? error.message : String(error),
|
|
9729
|
+
});
|
|
9730
|
+
throw error;
|
|
9731
|
+
}
|
|
9704
9732
|
}
|
|
9705
9733
|
// ---------------------------------------------------------------------
|
|
9706
9734
|
// Shutdown Management
|
|
@@ -19979,9 +20007,6 @@ class WebSocketConnector extends BaseAsyncConnector {
|
|
|
19979
20007
|
// Browser WebSocket or Node.js ws client
|
|
19980
20008
|
this._websocket.send(data);
|
|
19981
20009
|
}
|
|
19982
|
-
logger$H.debug('websocket_sent_bytes', {
|
|
19983
|
-
byte_length: data.length,
|
|
19984
|
-
});
|
|
19985
20010
|
}
|
|
19986
20011
|
catch (error) {
|
|
19987
20012
|
// Handle WebSocket disconnection errors
|
|
@@ -509,11 +509,31 @@ class BaseAsyncConnector extends task_spawner_js_1.TaskSpawner {
|
|
|
509
509
|
* Emit credit update if flow control needs refill
|
|
510
510
|
*/
|
|
511
511
|
async _maybeEmitCredit(flowId, traceId) {
|
|
512
|
-
|
|
512
|
+
const remainingCredits = this._flowCtrl.getCredits(flowId);
|
|
513
|
+
const needsRefill = this._flowCtrl.needsRefill(flowId);
|
|
514
|
+
logger.debug('maybe_emit_credit_check', {
|
|
515
|
+
connector_id: this._connectorFlowId,
|
|
516
|
+
flow_id: flowId,
|
|
517
|
+
trace_id: traceId ?? null,
|
|
518
|
+
remaining_credits: remainingCredits,
|
|
519
|
+
low_watermark: this._flowCtrl instanceof flow_controller_js_1.FlowController
|
|
520
|
+
? this._flowCtrl.lowWatermark
|
|
521
|
+
: null,
|
|
522
|
+
initial_window: this._initialWindow,
|
|
523
|
+
needs_refill: needsRefill,
|
|
524
|
+
});
|
|
525
|
+
if (!needsRefill) {
|
|
513
526
|
return;
|
|
514
527
|
}
|
|
515
528
|
const delta = this._initialWindow;
|
|
516
529
|
this._flowCtrl.addCredits(flowId, delta);
|
|
530
|
+
logger.debug('maybe_emit_credit_emit', {
|
|
531
|
+
connector_id: this._connectorFlowId,
|
|
532
|
+
flow_id: flowId,
|
|
533
|
+
trace_id: traceId ?? null,
|
|
534
|
+
emitted_credits: delta,
|
|
535
|
+
post_emit_balance: this._flowCtrl.getCredits(flowId),
|
|
536
|
+
});
|
|
517
537
|
const ackEnv = (0, core_1.createFameEnvelope)({
|
|
518
538
|
...(traceId && { traceId }),
|
|
519
539
|
flowId,
|
|
@@ -525,7 +545,25 @@ class BaseAsyncConnector extends task_spawner_js_1.TaskSpawner {
|
|
|
525
545
|
},
|
|
526
546
|
flags: core_1.FlowFlags.ACK,
|
|
527
547
|
});
|
|
528
|
-
|
|
548
|
+
try {
|
|
549
|
+
await this.send(ackEnv);
|
|
550
|
+
logger.debug('maybe_emit_credit_sent', {
|
|
551
|
+
connector_id: this._connectorFlowId,
|
|
552
|
+
flow_id: flowId,
|
|
553
|
+
trace_id: traceId ?? null,
|
|
554
|
+
credits_acknowledged: delta,
|
|
555
|
+
});
|
|
556
|
+
}
|
|
557
|
+
catch (error) {
|
|
558
|
+
logger.error('maybe_emit_credit_send_failed', {
|
|
559
|
+
connector_id: this._connectorFlowId,
|
|
560
|
+
flow_id: flowId,
|
|
561
|
+
trace_id: traceId ?? null,
|
|
562
|
+
credits_attempted: delta,
|
|
563
|
+
error: error instanceof Error ? error.message : String(error),
|
|
564
|
+
});
|
|
565
|
+
throw error;
|
|
566
|
+
}
|
|
529
567
|
}
|
|
530
568
|
// ---------------------------------------------------------------------
|
|
531
569
|
// Shutdown Management
|
|
@@ -143,9 +143,6 @@ class WebSocketConnector extends base_async_connector_js_1.BaseAsyncConnector {
|
|
|
143
143
|
// Browser WebSocket or Node.js ws client
|
|
144
144
|
this._websocket.send(data);
|
|
145
145
|
}
|
|
146
|
-
logger.debug('websocket_sent_bytes', {
|
|
147
|
-
byte_length: data.length,
|
|
148
|
-
});
|
|
149
146
|
}
|
|
150
147
|
catch (error) {
|
|
151
148
|
// Handle WebSocket disconnection errors
|
|
@@ -1,38 +1,28 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
// import { getLogger } from './logging.js';
|
|
3
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
3
|
exports.AsyncLock = void 0;
|
|
5
4
|
exports.withLock = withLock;
|
|
6
|
-
// const logger = getLogger('naylence.fame.util.lock');
|
|
7
5
|
class AsyncLock {
|
|
8
6
|
constructor() {
|
|
9
|
-
this.
|
|
7
|
+
this.tail = Promise.resolve();
|
|
10
8
|
}
|
|
11
|
-
async
|
|
12
|
-
const currentQueue = this.queue;
|
|
9
|
+
async runExclusive(operation) {
|
|
13
10
|
let release;
|
|
14
|
-
const
|
|
11
|
+
const next = new Promise((resolve) => {
|
|
15
12
|
release = resolve;
|
|
16
13
|
});
|
|
17
|
-
|
|
18
|
-
this.
|
|
19
|
-
|
|
20
|
-
// logger.debug('waiting_for_lock');
|
|
21
|
-
await currentQueue;
|
|
22
|
-
// logger.debug('lock_acquired');
|
|
14
|
+
const previous = this.tail;
|
|
15
|
+
this.tail = previous.then(() => next, () => next);
|
|
16
|
+
await previous;
|
|
23
17
|
try {
|
|
24
|
-
return await
|
|
18
|
+
return await operation();
|
|
25
19
|
}
|
|
26
20
|
finally {
|
|
27
21
|
release();
|
|
28
|
-
// logger.debug('lock_released');
|
|
29
22
|
}
|
|
30
23
|
}
|
|
31
|
-
async runExclusive(task) {
|
|
32
|
-
return this.acquire(task);
|
|
33
|
-
}
|
|
34
24
|
}
|
|
35
25
|
exports.AsyncLock = AsyncLock;
|
|
36
26
|
async function withLock(lock, operation) {
|
|
37
|
-
return await lock.
|
|
27
|
+
return await lock.runExclusive(operation);
|
|
38
28
|
}
|
package/dist/cjs/version.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
// This file is auto-generated during build - do not edit manually
|
|
3
|
-
// Generated from package.json version: 0.3.5-test.
|
|
3
|
+
// Generated from package.json version: 0.3.5-test.959
|
|
4
4
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
5
|
exports.VERSION = void 0;
|
|
6
6
|
/**
|
|
7
7
|
* The package version, injected at build time.
|
|
8
8
|
* @internal
|
|
9
9
|
*/
|
|
10
|
-
exports.VERSION = '0.3.5-test.
|
|
10
|
+
exports.VERSION = '0.3.5-test.959';
|
|
@@ -505,11 +505,31 @@ export class BaseAsyncConnector extends TaskSpawner {
|
|
|
505
505
|
* Emit credit update if flow control needs refill
|
|
506
506
|
*/
|
|
507
507
|
async _maybeEmitCredit(flowId, traceId) {
|
|
508
|
-
|
|
508
|
+
const remainingCredits = this._flowCtrl.getCredits(flowId);
|
|
509
|
+
const needsRefill = this._flowCtrl.needsRefill(flowId);
|
|
510
|
+
logger.debug('maybe_emit_credit_check', {
|
|
511
|
+
connector_id: this._connectorFlowId,
|
|
512
|
+
flow_id: flowId,
|
|
513
|
+
trace_id: traceId ?? null,
|
|
514
|
+
remaining_credits: remainingCredits,
|
|
515
|
+
low_watermark: this._flowCtrl instanceof FlowController
|
|
516
|
+
? this._flowCtrl.lowWatermark
|
|
517
|
+
: null,
|
|
518
|
+
initial_window: this._initialWindow,
|
|
519
|
+
needs_refill: needsRefill,
|
|
520
|
+
});
|
|
521
|
+
if (!needsRefill) {
|
|
509
522
|
return;
|
|
510
523
|
}
|
|
511
524
|
const delta = this._initialWindow;
|
|
512
525
|
this._flowCtrl.addCredits(flowId, delta);
|
|
526
|
+
logger.debug('maybe_emit_credit_emit', {
|
|
527
|
+
connector_id: this._connectorFlowId,
|
|
528
|
+
flow_id: flowId,
|
|
529
|
+
trace_id: traceId ?? null,
|
|
530
|
+
emitted_credits: delta,
|
|
531
|
+
post_emit_balance: this._flowCtrl.getCredits(flowId),
|
|
532
|
+
});
|
|
513
533
|
const ackEnv = createFameEnvelope({
|
|
514
534
|
...(traceId && { traceId }),
|
|
515
535
|
flowId,
|
|
@@ -521,7 +541,25 @@ export class BaseAsyncConnector extends TaskSpawner {
|
|
|
521
541
|
},
|
|
522
542
|
flags: FlowFlags.ACK,
|
|
523
543
|
});
|
|
524
|
-
|
|
544
|
+
try {
|
|
545
|
+
await this.send(ackEnv);
|
|
546
|
+
logger.debug('maybe_emit_credit_sent', {
|
|
547
|
+
connector_id: this._connectorFlowId,
|
|
548
|
+
flow_id: flowId,
|
|
549
|
+
trace_id: traceId ?? null,
|
|
550
|
+
credits_acknowledged: delta,
|
|
551
|
+
});
|
|
552
|
+
}
|
|
553
|
+
catch (error) {
|
|
554
|
+
logger.error('maybe_emit_credit_send_failed', {
|
|
555
|
+
connector_id: this._connectorFlowId,
|
|
556
|
+
flow_id: flowId,
|
|
557
|
+
trace_id: traceId ?? null,
|
|
558
|
+
credits_attempted: delta,
|
|
559
|
+
error: error instanceof Error ? error.message : String(error),
|
|
560
|
+
});
|
|
561
|
+
throw error;
|
|
562
|
+
}
|
|
525
563
|
}
|
|
526
564
|
// ---------------------------------------------------------------------
|
|
527
565
|
// Shutdown Management
|
|
@@ -140,9 +140,6 @@ export class WebSocketConnector extends BaseAsyncConnector {
|
|
|
140
140
|
// Browser WebSocket or Node.js ws client
|
|
141
141
|
this._websocket.send(data);
|
|
142
142
|
}
|
|
143
|
-
logger.debug('websocket_sent_bytes', {
|
|
144
|
-
byte_length: data.length,
|
|
145
|
-
});
|
|
146
143
|
}
|
|
147
144
|
catch (error) {
|
|
148
145
|
// Handle WebSocket disconnection errors
|
|
@@ -1,33 +1,23 @@
|
|
|
1
|
-
// import { getLogger } from './logging.js';
|
|
2
|
-
// const logger = getLogger('naylence.fame.util.lock');
|
|
3
1
|
export class AsyncLock {
|
|
4
2
|
constructor() {
|
|
5
|
-
this.
|
|
3
|
+
this.tail = Promise.resolve();
|
|
6
4
|
}
|
|
7
|
-
async
|
|
8
|
-
const currentQueue = this.queue;
|
|
5
|
+
async runExclusive(operation) {
|
|
9
6
|
let release;
|
|
10
|
-
const
|
|
7
|
+
const next = new Promise((resolve) => {
|
|
11
8
|
release = resolve;
|
|
12
9
|
});
|
|
13
|
-
|
|
14
|
-
this.
|
|
15
|
-
|
|
16
|
-
// logger.debug('waiting_for_lock');
|
|
17
|
-
await currentQueue;
|
|
18
|
-
// logger.debug('lock_acquired');
|
|
10
|
+
const previous = this.tail;
|
|
11
|
+
this.tail = previous.then(() => next, () => next);
|
|
12
|
+
await previous;
|
|
19
13
|
try {
|
|
20
|
-
return await
|
|
14
|
+
return await operation();
|
|
21
15
|
}
|
|
22
16
|
finally {
|
|
23
17
|
release();
|
|
24
|
-
// logger.debug('lock_released');
|
|
25
18
|
}
|
|
26
19
|
}
|
|
27
|
-
async runExclusive(task) {
|
|
28
|
-
return this.acquire(task);
|
|
29
|
-
}
|
|
30
20
|
}
|
|
31
21
|
export async function withLock(lock, operation) {
|
|
32
|
-
return await lock.
|
|
22
|
+
return await lock.runExclusive(operation);
|
|
33
23
|
}
|
package/dist/esm/version.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// This file is auto-generated during build - do not edit manually
|
|
2
|
-
// Generated from package.json version: 0.3.5-test.
|
|
2
|
+
// Generated from package.json version: 0.3.5-test.959
|
|
3
3
|
/**
|
|
4
4
|
* The package version, injected at build time.
|
|
5
5
|
* @internal
|
|
6
6
|
*/
|
|
7
|
-
export const VERSION = '0.3.5-test.
|
|
7
|
+
export const VERSION = '0.3.5-test.959';
|
package/dist/node/index.cjs
CHANGED
|
@@ -14,12 +14,12 @@ var fastify = require('fastify');
|
|
|
14
14
|
var websocketPlugin = require('@fastify/websocket');
|
|
15
15
|
|
|
16
16
|
// This file is auto-generated during build - do not edit manually
|
|
17
|
-
// Generated from package.json version: 0.3.5-test.
|
|
17
|
+
// Generated from package.json version: 0.3.5-test.959
|
|
18
18
|
/**
|
|
19
19
|
* The package version, injected at build time.
|
|
20
20
|
* @internal
|
|
21
21
|
*/
|
|
22
|
-
const VERSION = '0.3.5-test.
|
|
22
|
+
const VERSION = '0.3.5-test.959';
|
|
23
23
|
|
|
24
24
|
/**
|
|
25
25
|
* Fame protocol specific error classes with WebSocket close codes and proper inheritance.
|
|
@@ -1274,38 +1274,28 @@ class TaskSpawner {
|
|
|
1274
1274
|
}
|
|
1275
1275
|
}
|
|
1276
1276
|
|
|
1277
|
-
// import { getLogger } from './logging.js';
|
|
1278
|
-
// const logger = getLogger('naylence.fame.util.lock');
|
|
1279
1277
|
class AsyncLock {
|
|
1280
1278
|
constructor() {
|
|
1281
|
-
this.
|
|
1279
|
+
this.tail = Promise.resolve();
|
|
1282
1280
|
}
|
|
1283
|
-
async
|
|
1284
|
-
const currentQueue = this.queue;
|
|
1281
|
+
async runExclusive(operation) {
|
|
1285
1282
|
let release;
|
|
1286
|
-
const
|
|
1283
|
+
const next = new Promise((resolve) => {
|
|
1287
1284
|
release = resolve;
|
|
1288
1285
|
});
|
|
1289
|
-
|
|
1290
|
-
this.
|
|
1291
|
-
|
|
1292
|
-
// logger.debug('waiting_for_lock');
|
|
1293
|
-
await currentQueue;
|
|
1294
|
-
// logger.debug('lock_acquired');
|
|
1286
|
+
const previous = this.tail;
|
|
1287
|
+
this.tail = previous.then(() => next, () => next);
|
|
1288
|
+
await previous;
|
|
1295
1289
|
try {
|
|
1296
|
-
return await
|
|
1290
|
+
return await operation();
|
|
1297
1291
|
}
|
|
1298
1292
|
finally {
|
|
1299
1293
|
release();
|
|
1300
|
-
// logger.debug('lock_released');
|
|
1301
1294
|
}
|
|
1302
1295
|
}
|
|
1303
|
-
async runExclusive(task) {
|
|
1304
|
-
return this.acquire(task);
|
|
1305
|
-
}
|
|
1306
1296
|
}
|
|
1307
1297
|
async function withLock(lock, operation) {
|
|
1308
|
-
return await lock.
|
|
1298
|
+
return await lock.runExclusive(operation);
|
|
1309
1299
|
}
|
|
1310
1300
|
|
|
1311
1301
|
/**
|
|
@@ -9602,11 +9592,31 @@ class BaseAsyncConnector extends TaskSpawner {
|
|
|
9602
9592
|
* Emit credit update if flow control needs refill
|
|
9603
9593
|
*/
|
|
9604
9594
|
async _maybeEmitCredit(flowId, traceId) {
|
|
9605
|
-
|
|
9595
|
+
const remainingCredits = this._flowCtrl.getCredits(flowId);
|
|
9596
|
+
const needsRefill = this._flowCtrl.needsRefill(flowId);
|
|
9597
|
+
logger$$.debug('maybe_emit_credit_check', {
|
|
9598
|
+
connector_id: this._connectorFlowId,
|
|
9599
|
+
flow_id: flowId,
|
|
9600
|
+
trace_id: traceId ?? null,
|
|
9601
|
+
remaining_credits: remainingCredits,
|
|
9602
|
+
low_watermark: this._flowCtrl instanceof FlowController
|
|
9603
|
+
? this._flowCtrl.lowWatermark
|
|
9604
|
+
: null,
|
|
9605
|
+
initial_window: this._initialWindow,
|
|
9606
|
+
needs_refill: needsRefill,
|
|
9607
|
+
});
|
|
9608
|
+
if (!needsRefill) {
|
|
9606
9609
|
return;
|
|
9607
9610
|
}
|
|
9608
9611
|
const delta = this._initialWindow;
|
|
9609
9612
|
this._flowCtrl.addCredits(flowId, delta);
|
|
9613
|
+
logger$$.debug('maybe_emit_credit_emit', {
|
|
9614
|
+
connector_id: this._connectorFlowId,
|
|
9615
|
+
flow_id: flowId,
|
|
9616
|
+
trace_id: traceId ?? null,
|
|
9617
|
+
emitted_credits: delta,
|
|
9618
|
+
post_emit_balance: this._flowCtrl.getCredits(flowId),
|
|
9619
|
+
});
|
|
9610
9620
|
const ackEnv = core.createFameEnvelope({
|
|
9611
9621
|
...(traceId && { traceId }),
|
|
9612
9622
|
flowId,
|
|
@@ -9618,7 +9628,25 @@ class BaseAsyncConnector extends TaskSpawner {
|
|
|
9618
9628
|
},
|
|
9619
9629
|
flags: core.FlowFlags.ACK,
|
|
9620
9630
|
});
|
|
9621
|
-
|
|
9631
|
+
try {
|
|
9632
|
+
await this.send(ackEnv);
|
|
9633
|
+
logger$$.debug('maybe_emit_credit_sent', {
|
|
9634
|
+
connector_id: this._connectorFlowId,
|
|
9635
|
+
flow_id: flowId,
|
|
9636
|
+
trace_id: traceId ?? null,
|
|
9637
|
+
credits_acknowledged: delta,
|
|
9638
|
+
});
|
|
9639
|
+
}
|
|
9640
|
+
catch (error) {
|
|
9641
|
+
logger$$.error('maybe_emit_credit_send_failed', {
|
|
9642
|
+
connector_id: this._connectorFlowId,
|
|
9643
|
+
flow_id: flowId,
|
|
9644
|
+
trace_id: traceId ?? null,
|
|
9645
|
+
credits_attempted: delta,
|
|
9646
|
+
error: error instanceof Error ? error.message : String(error),
|
|
9647
|
+
});
|
|
9648
|
+
throw error;
|
|
9649
|
+
}
|
|
9622
9650
|
}
|
|
9623
9651
|
// ---------------------------------------------------------------------
|
|
9624
9652
|
// Shutdown Management
|
|
@@ -19897,9 +19925,6 @@ class WebSocketConnector extends BaseAsyncConnector {
|
|
|
19897
19925
|
// Browser WebSocket or Node.js ws client
|
|
19898
19926
|
this._websocket.send(data);
|
|
19899
19927
|
}
|
|
19900
|
-
logger$H.debug('websocket_sent_bytes', {
|
|
19901
|
-
byte_length: data.length,
|
|
19902
|
-
});
|
|
19903
19928
|
}
|
|
19904
19929
|
catch (error) {
|
|
19905
19930
|
// Handle WebSocket disconnection errors
|
package/dist/node/index.mjs
CHANGED
|
@@ -13,12 +13,12 @@ import fastify from 'fastify';
|
|
|
13
13
|
import websocketPlugin from '@fastify/websocket';
|
|
14
14
|
|
|
15
15
|
// This file is auto-generated during build - do not edit manually
|
|
16
|
-
// Generated from package.json version: 0.3.5-test.
|
|
16
|
+
// Generated from package.json version: 0.3.5-test.959
|
|
17
17
|
/**
|
|
18
18
|
* The package version, injected at build time.
|
|
19
19
|
* @internal
|
|
20
20
|
*/
|
|
21
|
-
const VERSION = '0.3.5-test.
|
|
21
|
+
const VERSION = '0.3.5-test.959';
|
|
22
22
|
|
|
23
23
|
/**
|
|
24
24
|
* Fame protocol specific error classes with WebSocket close codes and proper inheritance.
|
|
@@ -1273,38 +1273,28 @@ class TaskSpawner {
|
|
|
1273
1273
|
}
|
|
1274
1274
|
}
|
|
1275
1275
|
|
|
1276
|
-
// import { getLogger } from './logging.js';
|
|
1277
|
-
// const logger = getLogger('naylence.fame.util.lock');
|
|
1278
1276
|
class AsyncLock {
|
|
1279
1277
|
constructor() {
|
|
1280
|
-
this.
|
|
1278
|
+
this.tail = Promise.resolve();
|
|
1281
1279
|
}
|
|
1282
|
-
async
|
|
1283
|
-
const currentQueue = this.queue;
|
|
1280
|
+
async runExclusive(operation) {
|
|
1284
1281
|
let release;
|
|
1285
|
-
const
|
|
1282
|
+
const next = new Promise((resolve) => {
|
|
1286
1283
|
release = resolve;
|
|
1287
1284
|
});
|
|
1288
|
-
|
|
1289
|
-
this.
|
|
1290
|
-
|
|
1291
|
-
// logger.debug('waiting_for_lock');
|
|
1292
|
-
await currentQueue;
|
|
1293
|
-
// logger.debug('lock_acquired');
|
|
1285
|
+
const previous = this.tail;
|
|
1286
|
+
this.tail = previous.then(() => next, () => next);
|
|
1287
|
+
await previous;
|
|
1294
1288
|
try {
|
|
1295
|
-
return await
|
|
1289
|
+
return await operation();
|
|
1296
1290
|
}
|
|
1297
1291
|
finally {
|
|
1298
1292
|
release();
|
|
1299
|
-
// logger.debug('lock_released');
|
|
1300
1293
|
}
|
|
1301
1294
|
}
|
|
1302
|
-
async runExclusive(task) {
|
|
1303
|
-
return this.acquire(task);
|
|
1304
|
-
}
|
|
1305
1295
|
}
|
|
1306
1296
|
async function withLock(lock, operation) {
|
|
1307
|
-
return await lock.
|
|
1297
|
+
return await lock.runExclusive(operation);
|
|
1308
1298
|
}
|
|
1309
1299
|
|
|
1310
1300
|
/**
|
|
@@ -9601,11 +9591,31 @@ class BaseAsyncConnector extends TaskSpawner {
|
|
|
9601
9591
|
* Emit credit update if flow control needs refill
|
|
9602
9592
|
*/
|
|
9603
9593
|
async _maybeEmitCredit(flowId, traceId) {
|
|
9604
|
-
|
|
9594
|
+
const remainingCredits = this._flowCtrl.getCredits(flowId);
|
|
9595
|
+
const needsRefill = this._flowCtrl.needsRefill(flowId);
|
|
9596
|
+
logger$$.debug('maybe_emit_credit_check', {
|
|
9597
|
+
connector_id: this._connectorFlowId,
|
|
9598
|
+
flow_id: flowId,
|
|
9599
|
+
trace_id: traceId ?? null,
|
|
9600
|
+
remaining_credits: remainingCredits,
|
|
9601
|
+
low_watermark: this._flowCtrl instanceof FlowController
|
|
9602
|
+
? this._flowCtrl.lowWatermark
|
|
9603
|
+
: null,
|
|
9604
|
+
initial_window: this._initialWindow,
|
|
9605
|
+
needs_refill: needsRefill,
|
|
9606
|
+
});
|
|
9607
|
+
if (!needsRefill) {
|
|
9605
9608
|
return;
|
|
9606
9609
|
}
|
|
9607
9610
|
const delta = this._initialWindow;
|
|
9608
9611
|
this._flowCtrl.addCredits(flowId, delta);
|
|
9612
|
+
logger$$.debug('maybe_emit_credit_emit', {
|
|
9613
|
+
connector_id: this._connectorFlowId,
|
|
9614
|
+
flow_id: flowId,
|
|
9615
|
+
trace_id: traceId ?? null,
|
|
9616
|
+
emitted_credits: delta,
|
|
9617
|
+
post_emit_balance: this._flowCtrl.getCredits(flowId),
|
|
9618
|
+
});
|
|
9609
9619
|
const ackEnv = createFameEnvelope({
|
|
9610
9620
|
...(traceId && { traceId }),
|
|
9611
9621
|
flowId,
|
|
@@ -9617,7 +9627,25 @@ class BaseAsyncConnector extends TaskSpawner {
|
|
|
9617
9627
|
},
|
|
9618
9628
|
flags: FlowFlags.ACK,
|
|
9619
9629
|
});
|
|
9620
|
-
|
|
9630
|
+
try {
|
|
9631
|
+
await this.send(ackEnv);
|
|
9632
|
+
logger$$.debug('maybe_emit_credit_sent', {
|
|
9633
|
+
connector_id: this._connectorFlowId,
|
|
9634
|
+
flow_id: flowId,
|
|
9635
|
+
trace_id: traceId ?? null,
|
|
9636
|
+
credits_acknowledged: delta,
|
|
9637
|
+
});
|
|
9638
|
+
}
|
|
9639
|
+
catch (error) {
|
|
9640
|
+
logger$$.error('maybe_emit_credit_send_failed', {
|
|
9641
|
+
connector_id: this._connectorFlowId,
|
|
9642
|
+
flow_id: flowId,
|
|
9643
|
+
trace_id: traceId ?? null,
|
|
9644
|
+
credits_attempted: delta,
|
|
9645
|
+
error: error instanceof Error ? error.message : String(error),
|
|
9646
|
+
});
|
|
9647
|
+
throw error;
|
|
9648
|
+
}
|
|
9621
9649
|
}
|
|
9622
9650
|
// ---------------------------------------------------------------------
|
|
9623
9651
|
// Shutdown Management
|
|
@@ -19896,9 +19924,6 @@ class WebSocketConnector extends BaseAsyncConnector {
|
|
|
19896
19924
|
// Browser WebSocket or Node.js ws client
|
|
19897
19925
|
this._websocket.send(data);
|
|
19898
19926
|
}
|
|
19899
|
-
logger$H.debug('websocket_sent_bytes', {
|
|
19900
|
-
byte_length: data.length,
|
|
19901
|
-
});
|
|
19902
19927
|
}
|
|
19903
19928
|
catch (error) {
|
|
19904
19929
|
// Handle WebSocket disconnection errors
|
package/dist/node/node.cjs
CHANGED
|
@@ -2522,11 +2522,31 @@ class BaseAsyncConnector extends TaskSpawner {
|
|
|
2522
2522
|
* Emit credit update if flow control needs refill
|
|
2523
2523
|
*/
|
|
2524
2524
|
async _maybeEmitCredit(flowId, traceId) {
|
|
2525
|
-
|
|
2525
|
+
const remainingCredits = this._flowCtrl.getCredits(flowId);
|
|
2526
|
+
const needsRefill = this._flowCtrl.needsRefill(flowId);
|
|
2527
|
+
logger$1f.debug('maybe_emit_credit_check', {
|
|
2528
|
+
connector_id: this._connectorFlowId,
|
|
2529
|
+
flow_id: flowId,
|
|
2530
|
+
trace_id: traceId ?? null,
|
|
2531
|
+
remaining_credits: remainingCredits,
|
|
2532
|
+
low_watermark: this._flowCtrl instanceof FlowController
|
|
2533
|
+
? this._flowCtrl.lowWatermark
|
|
2534
|
+
: null,
|
|
2535
|
+
initial_window: this._initialWindow,
|
|
2536
|
+
needs_refill: needsRefill,
|
|
2537
|
+
});
|
|
2538
|
+
if (!needsRefill) {
|
|
2526
2539
|
return;
|
|
2527
2540
|
}
|
|
2528
2541
|
const delta = this._initialWindow;
|
|
2529
2542
|
this._flowCtrl.addCredits(flowId, delta);
|
|
2543
|
+
logger$1f.debug('maybe_emit_credit_emit', {
|
|
2544
|
+
connector_id: this._connectorFlowId,
|
|
2545
|
+
flow_id: flowId,
|
|
2546
|
+
trace_id: traceId ?? null,
|
|
2547
|
+
emitted_credits: delta,
|
|
2548
|
+
post_emit_balance: this._flowCtrl.getCredits(flowId),
|
|
2549
|
+
});
|
|
2530
2550
|
const ackEnv = core.createFameEnvelope({
|
|
2531
2551
|
...(traceId && { traceId }),
|
|
2532
2552
|
flowId,
|
|
@@ -2538,7 +2558,25 @@ class BaseAsyncConnector extends TaskSpawner {
|
|
|
2538
2558
|
},
|
|
2539
2559
|
flags: core.FlowFlags.ACK,
|
|
2540
2560
|
});
|
|
2541
|
-
|
|
2561
|
+
try {
|
|
2562
|
+
await this.send(ackEnv);
|
|
2563
|
+
logger$1f.debug('maybe_emit_credit_sent', {
|
|
2564
|
+
connector_id: this._connectorFlowId,
|
|
2565
|
+
flow_id: flowId,
|
|
2566
|
+
trace_id: traceId ?? null,
|
|
2567
|
+
credits_acknowledged: delta,
|
|
2568
|
+
});
|
|
2569
|
+
}
|
|
2570
|
+
catch (error) {
|
|
2571
|
+
logger$1f.error('maybe_emit_credit_send_failed', {
|
|
2572
|
+
connector_id: this._connectorFlowId,
|
|
2573
|
+
flow_id: flowId,
|
|
2574
|
+
trace_id: traceId ?? null,
|
|
2575
|
+
credits_attempted: delta,
|
|
2576
|
+
error: error instanceof Error ? error.message : String(error),
|
|
2577
|
+
});
|
|
2578
|
+
throw error;
|
|
2579
|
+
}
|
|
2542
2580
|
}
|
|
2543
2581
|
// ---------------------------------------------------------------------
|
|
2544
2582
|
// Shutdown Management
|
|
@@ -2789,9 +2827,6 @@ class WebSocketConnector extends BaseAsyncConnector {
|
|
|
2789
2827
|
// Browser WebSocket or Node.js ws client
|
|
2790
2828
|
this._websocket.send(data);
|
|
2791
2829
|
}
|
|
2792
|
-
logger$1e.debug('websocket_sent_bytes', {
|
|
2793
|
-
byte_length: data.length,
|
|
2794
|
-
});
|
|
2795
2830
|
}
|
|
2796
2831
|
catch (error) {
|
|
2797
2832
|
// Handle WebSocket disconnection errors
|
|
@@ -5120,38 +5155,28 @@ class EncryptedStorageProviderBase {
|
|
|
5120
5155
|
}
|
|
5121
5156
|
}
|
|
5122
5157
|
|
|
5123
|
-
// import { getLogger } from './logging.js';
|
|
5124
|
-
// const logger = getLogger('naylence.fame.util.lock');
|
|
5125
5158
|
class AsyncLock {
|
|
5126
5159
|
constructor() {
|
|
5127
|
-
this.
|
|
5160
|
+
this.tail = Promise.resolve();
|
|
5128
5161
|
}
|
|
5129
|
-
async
|
|
5130
|
-
const currentQueue = this.queue;
|
|
5162
|
+
async runExclusive(operation) {
|
|
5131
5163
|
let release;
|
|
5132
|
-
const
|
|
5164
|
+
const next = new Promise((resolve) => {
|
|
5133
5165
|
release = resolve;
|
|
5134
5166
|
});
|
|
5135
|
-
|
|
5136
|
-
this.
|
|
5137
|
-
|
|
5138
|
-
// logger.debug('waiting_for_lock');
|
|
5139
|
-
await currentQueue;
|
|
5140
|
-
// logger.debug('lock_acquired');
|
|
5167
|
+
const previous = this.tail;
|
|
5168
|
+
this.tail = previous.then(() => next, () => next);
|
|
5169
|
+
await previous;
|
|
5141
5170
|
try {
|
|
5142
|
-
return await
|
|
5171
|
+
return await operation();
|
|
5143
5172
|
}
|
|
5144
5173
|
finally {
|
|
5145
5174
|
release();
|
|
5146
|
-
// logger.debug('lock_released');
|
|
5147
5175
|
}
|
|
5148
5176
|
}
|
|
5149
|
-
async runExclusive(task) {
|
|
5150
|
-
return this.acquire(task);
|
|
5151
|
-
}
|
|
5152
5177
|
}
|
|
5153
5178
|
async function withLock(lock, operation) {
|
|
5154
|
-
return await lock.
|
|
5179
|
+
return await lock.runExclusive(operation);
|
|
5155
5180
|
}
|
|
5156
5181
|
|
|
5157
5182
|
const logger$1b = getLogger('naylence.fame.storage.sqlite_storage_provider');
|
|
@@ -5538,12 +5563,12 @@ for (const [name, config] of Object.entries(SQLITE_PROFILES)) {
|
|
|
5538
5563
|
}
|
|
5539
5564
|
|
|
5540
5565
|
// This file is auto-generated during build - do not edit manually
|
|
5541
|
-
// Generated from package.json version: 0.3.5-test.
|
|
5566
|
+
// Generated from package.json version: 0.3.5-test.959
|
|
5542
5567
|
/**
|
|
5543
5568
|
* The package version, injected at build time.
|
|
5544
5569
|
* @internal
|
|
5545
5570
|
*/
|
|
5546
|
-
const VERSION = '0.3.5-test.
|
|
5571
|
+
const VERSION = '0.3.5-test.959';
|
|
5547
5572
|
|
|
5548
5573
|
/**
|
|
5549
5574
|
* Fame errors module - Fame protocol specific error classes
|
package/dist/node/node.mjs
CHANGED
|
@@ -2521,11 +2521,31 @@ class BaseAsyncConnector extends TaskSpawner {
|
|
|
2521
2521
|
* Emit credit update if flow control needs refill
|
|
2522
2522
|
*/
|
|
2523
2523
|
async _maybeEmitCredit(flowId, traceId) {
|
|
2524
|
-
|
|
2524
|
+
const remainingCredits = this._flowCtrl.getCredits(flowId);
|
|
2525
|
+
const needsRefill = this._flowCtrl.needsRefill(flowId);
|
|
2526
|
+
logger$1f.debug('maybe_emit_credit_check', {
|
|
2527
|
+
connector_id: this._connectorFlowId,
|
|
2528
|
+
flow_id: flowId,
|
|
2529
|
+
trace_id: traceId ?? null,
|
|
2530
|
+
remaining_credits: remainingCredits,
|
|
2531
|
+
low_watermark: this._flowCtrl instanceof FlowController
|
|
2532
|
+
? this._flowCtrl.lowWatermark
|
|
2533
|
+
: null,
|
|
2534
|
+
initial_window: this._initialWindow,
|
|
2535
|
+
needs_refill: needsRefill,
|
|
2536
|
+
});
|
|
2537
|
+
if (!needsRefill) {
|
|
2525
2538
|
return;
|
|
2526
2539
|
}
|
|
2527
2540
|
const delta = this._initialWindow;
|
|
2528
2541
|
this._flowCtrl.addCredits(flowId, delta);
|
|
2542
|
+
logger$1f.debug('maybe_emit_credit_emit', {
|
|
2543
|
+
connector_id: this._connectorFlowId,
|
|
2544
|
+
flow_id: flowId,
|
|
2545
|
+
trace_id: traceId ?? null,
|
|
2546
|
+
emitted_credits: delta,
|
|
2547
|
+
post_emit_balance: this._flowCtrl.getCredits(flowId),
|
|
2548
|
+
});
|
|
2529
2549
|
const ackEnv = createFameEnvelope({
|
|
2530
2550
|
...(traceId && { traceId }),
|
|
2531
2551
|
flowId,
|
|
@@ -2537,7 +2557,25 @@ class BaseAsyncConnector extends TaskSpawner {
|
|
|
2537
2557
|
},
|
|
2538
2558
|
flags: FlowFlags.ACK,
|
|
2539
2559
|
});
|
|
2540
|
-
|
|
2560
|
+
try {
|
|
2561
|
+
await this.send(ackEnv);
|
|
2562
|
+
logger$1f.debug('maybe_emit_credit_sent', {
|
|
2563
|
+
connector_id: this._connectorFlowId,
|
|
2564
|
+
flow_id: flowId,
|
|
2565
|
+
trace_id: traceId ?? null,
|
|
2566
|
+
credits_acknowledged: delta,
|
|
2567
|
+
});
|
|
2568
|
+
}
|
|
2569
|
+
catch (error) {
|
|
2570
|
+
logger$1f.error('maybe_emit_credit_send_failed', {
|
|
2571
|
+
connector_id: this._connectorFlowId,
|
|
2572
|
+
flow_id: flowId,
|
|
2573
|
+
trace_id: traceId ?? null,
|
|
2574
|
+
credits_attempted: delta,
|
|
2575
|
+
error: error instanceof Error ? error.message : String(error),
|
|
2576
|
+
});
|
|
2577
|
+
throw error;
|
|
2578
|
+
}
|
|
2541
2579
|
}
|
|
2542
2580
|
// ---------------------------------------------------------------------
|
|
2543
2581
|
// Shutdown Management
|
|
@@ -2788,9 +2826,6 @@ class WebSocketConnector extends BaseAsyncConnector {
|
|
|
2788
2826
|
// Browser WebSocket or Node.js ws client
|
|
2789
2827
|
this._websocket.send(data);
|
|
2790
2828
|
}
|
|
2791
|
-
logger$1e.debug('websocket_sent_bytes', {
|
|
2792
|
-
byte_length: data.length,
|
|
2793
|
-
});
|
|
2794
2829
|
}
|
|
2795
2830
|
catch (error) {
|
|
2796
2831
|
// Handle WebSocket disconnection errors
|
|
@@ -5119,38 +5154,28 @@ class EncryptedStorageProviderBase {
|
|
|
5119
5154
|
}
|
|
5120
5155
|
}
|
|
5121
5156
|
|
|
5122
|
-
// import { getLogger } from './logging.js';
|
|
5123
|
-
// const logger = getLogger('naylence.fame.util.lock');
|
|
5124
5157
|
class AsyncLock {
|
|
5125
5158
|
constructor() {
|
|
5126
|
-
this.
|
|
5159
|
+
this.tail = Promise.resolve();
|
|
5127
5160
|
}
|
|
5128
|
-
async
|
|
5129
|
-
const currentQueue = this.queue;
|
|
5161
|
+
async runExclusive(operation) {
|
|
5130
5162
|
let release;
|
|
5131
|
-
const
|
|
5163
|
+
const next = new Promise((resolve) => {
|
|
5132
5164
|
release = resolve;
|
|
5133
5165
|
});
|
|
5134
|
-
|
|
5135
|
-
this.
|
|
5136
|
-
|
|
5137
|
-
// logger.debug('waiting_for_lock');
|
|
5138
|
-
await currentQueue;
|
|
5139
|
-
// logger.debug('lock_acquired');
|
|
5166
|
+
const previous = this.tail;
|
|
5167
|
+
this.tail = previous.then(() => next, () => next);
|
|
5168
|
+
await previous;
|
|
5140
5169
|
try {
|
|
5141
|
-
return await
|
|
5170
|
+
return await operation();
|
|
5142
5171
|
}
|
|
5143
5172
|
finally {
|
|
5144
5173
|
release();
|
|
5145
|
-
// logger.debug('lock_released');
|
|
5146
5174
|
}
|
|
5147
5175
|
}
|
|
5148
|
-
async runExclusive(task) {
|
|
5149
|
-
return this.acquire(task);
|
|
5150
|
-
}
|
|
5151
5176
|
}
|
|
5152
5177
|
async function withLock(lock, operation) {
|
|
5153
|
-
return await lock.
|
|
5178
|
+
return await lock.runExclusive(operation);
|
|
5154
5179
|
}
|
|
5155
5180
|
|
|
5156
5181
|
const logger$1b = getLogger('naylence.fame.storage.sqlite_storage_provider');
|
|
@@ -5537,12 +5562,12 @@ for (const [name, config] of Object.entries(SQLITE_PROFILES)) {
|
|
|
5537
5562
|
}
|
|
5538
5563
|
|
|
5539
5564
|
// This file is auto-generated during build - do not edit manually
|
|
5540
|
-
// Generated from package.json version: 0.3.5-test.
|
|
5565
|
+
// Generated from package.json version: 0.3.5-test.959
|
|
5541
5566
|
/**
|
|
5542
5567
|
* The package version, injected at build time.
|
|
5543
5568
|
* @internal
|
|
5544
5569
|
*/
|
|
5545
|
-
const VERSION = '0.3.5-test.
|
|
5570
|
+
const VERSION = '0.3.5-test.959';
|
|
5546
5571
|
|
|
5547
5572
|
/**
|
|
5548
5573
|
* Fame errors module - Fame protocol specific error classes
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
export declare class AsyncLock {
|
|
2
|
-
private
|
|
3
|
-
|
|
4
|
-
runExclusive<T>(task: () => Promise<T> | T): Promise<T>;
|
|
2
|
+
private tail;
|
|
3
|
+
runExclusive<T>(operation: () => Promise<T> | T): Promise<T>;
|
|
5
4
|
}
|
|
6
5
|
export declare function withLock<T>(lock: AsyncLock, operation: () => Promise<T> | T): Promise<T>;
|
package/dist/types/version.d.ts
CHANGED