@naylence/runtime 0.3.5-test.958 → 0.3.5-test.960
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 +76 -25
- package/dist/browser/index.mjs +76 -25
- package/dist/cjs/naylence/fame/connector/base-async-connector.js +40 -2
- package/dist/cjs/naylence/fame/connector/broadcast-channel-connector.browser.js +26 -0
- 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/broadcast-channel-connector.browser.js +26 -0
- 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 +76 -25
- package/dist/node/index.mjs +76 -25
- package/dist/node/node.cjs +76 -25
- package/dist/node/node.mjs +76 -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/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.960
|
|
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.960';
|
|
5546
5571
|
|
|
5547
5572
|
/**
|
|
5548
5573
|
* Fame errors module - Fame protocol specific error classes
|
|
@@ -11888,6 +11913,14 @@ let BroadcastChannelConnector$2 = class BroadcastChannelConnector extends BaseAs
|
|
|
11888
11913
|
const normalizedSenderId = typeof senderId === 'string' && senderId.length > 0
|
|
11889
11914
|
? senderId
|
|
11890
11915
|
: undefined;
|
|
11916
|
+
logger$10.debug('broadcast_channel_duplicate_ack_check', {
|
|
11917
|
+
channel: this.channelName,
|
|
11918
|
+
connector_id: this.connectorId,
|
|
11919
|
+
sender_id: normalizedSenderId ?? null,
|
|
11920
|
+
dedup_key: dedupKey,
|
|
11921
|
+
source: 'listener',
|
|
11922
|
+
cache_entries: this.seenAckKeys.size,
|
|
11923
|
+
});
|
|
11891
11924
|
return this._checkDuplicateAck(dedupKey, normalizedSenderId);
|
|
11892
11925
|
}
|
|
11893
11926
|
_shouldSkipDuplicateAckFromInboxItem(item) {
|
|
@@ -11910,6 +11943,14 @@ let BroadcastChannelConnector$2 = class BroadcastChannelConnector extends BaseAs
|
|
|
11910
11943
|
return false;
|
|
11911
11944
|
}
|
|
11912
11945
|
const senderId = this._extractSenderIdFromInboxItem(item);
|
|
11946
|
+
logger$10.debug('broadcast_channel_duplicate_ack_check', {
|
|
11947
|
+
channel: this.channelName,
|
|
11948
|
+
connector_id: this.connectorId,
|
|
11949
|
+
sender_id: senderId ?? null,
|
|
11950
|
+
dedup_key: dedupKey,
|
|
11951
|
+
source: 'inbox_item',
|
|
11952
|
+
cache_entries: this.seenAckKeys.size,
|
|
11953
|
+
});
|
|
11913
11954
|
return this._checkDuplicateAck(dedupKey, senderId);
|
|
11914
11955
|
}
|
|
11915
11956
|
_checkDuplicateAck(dedupKey, senderId) {
|
|
@@ -11921,11 +11962,21 @@ let BroadcastChannelConnector$2 = class BroadcastChannelConnector extends BaseAs
|
|
|
11921
11962
|
connector_id: this.connectorId,
|
|
11922
11963
|
sender_id: senderId ?? null,
|
|
11923
11964
|
dedup_key: dedupKey,
|
|
11965
|
+
age_ms: now - lastSeen,
|
|
11966
|
+
ttl_ms: this.ackDedupTtlMs,
|
|
11967
|
+
cache_entries: this.seenAckKeys.size,
|
|
11924
11968
|
});
|
|
11925
11969
|
return true;
|
|
11926
11970
|
}
|
|
11927
11971
|
this.seenAckKeys.set(dedupKey, now);
|
|
11928
11972
|
this.seenAckOrder.push(dedupKey);
|
|
11973
|
+
logger$10.debug('broadcast_channel_duplicate_ack_recorded', {
|
|
11974
|
+
channel: this.channelName,
|
|
11975
|
+
connector_id: this.connectorId,
|
|
11976
|
+
sender_id: senderId ?? null,
|
|
11977
|
+
dedup_key: dedupKey,
|
|
11978
|
+
cache_entries: this.seenAckKeys.size,
|
|
11979
|
+
});
|
|
11929
11980
|
this._trimSeenAcks(now);
|
|
11930
11981
|
return false;
|
|
11931
11982
|
}
|
|
@@ -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