@naylence/runtime 0.4.1 → 0.4.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/dist/browser/index.cjs +367 -396
- package/dist/browser/index.mjs +367 -396
- package/dist/cjs/naylence/fame/node/default-node-identity-policy.js +9 -41
- package/dist/cjs/version.js +2 -2
- package/dist/esm/naylence/fame/node/default-node-identity-policy.js +9 -41
- package/dist/esm/version.js +2 -2
- package/dist/node/index.cjs +367 -396
- package/dist/node/index.mjs +367 -396
- package/dist/node/node.cjs +389 -418
- package/dist/node/node.mjs +389 -418
- package/dist/types/naylence/fame/node/default-node-identity-policy.d.ts +6 -0
- package/dist/types/version.d.ts +1 -1
- package/package.json +1 -1
package/dist/browser/index.cjs
CHANGED
|
@@ -525,12 +525,12 @@ async function ensureRuntimeFactoriesRegistered(registry = factory.Registry) {
|
|
|
525
525
|
}
|
|
526
526
|
|
|
527
527
|
// This file is auto-generated during build - do not edit manually
|
|
528
|
-
// Generated from package.json version: 0.4.
|
|
528
|
+
// Generated from package.json version: 0.4.2
|
|
529
529
|
/**
|
|
530
530
|
* The package version, injected at build time.
|
|
531
531
|
* @internal
|
|
532
532
|
*/
|
|
533
|
-
const VERSION = '0.4.
|
|
533
|
+
const VERSION = '0.4.2';
|
|
534
534
|
|
|
535
535
|
let initialized = false;
|
|
536
536
|
const runtimePlugin = {
|
|
@@ -1375,7 +1375,7 @@ class TaskCancelledError extends Error {
|
|
|
1375
1375
|
* Provides functionality similar to Python's asyncio TaskSpawner with proper
|
|
1376
1376
|
* error handling, cancellation, and graceful shutdown capabilities.
|
|
1377
1377
|
*/
|
|
1378
|
-
const logger$
|
|
1378
|
+
const logger$1k = getLogger('naylence.fame.util.task_spawner');
|
|
1379
1379
|
function firstDefined(source, keys) {
|
|
1380
1380
|
for (const key of keys) {
|
|
1381
1381
|
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
@@ -1536,7 +1536,7 @@ class TaskSpawner {
|
|
|
1536
1536
|
const taskId = `task-${++this._taskCounter}`;
|
|
1537
1537
|
const taskName = normalizedOptions.name || `unnamed-${taskId}`;
|
|
1538
1538
|
const timeout = normalizedOptions.timeout ?? this._config.defaultTimeout;
|
|
1539
|
-
logger$
|
|
1539
|
+
logger$1k.debug('starting_background_task', {
|
|
1540
1540
|
task_name: taskName,
|
|
1541
1541
|
task_id: taskId,
|
|
1542
1542
|
});
|
|
@@ -1553,7 +1553,7 @@ class TaskSpawner {
|
|
|
1553
1553
|
task.promise
|
|
1554
1554
|
.then(() => {
|
|
1555
1555
|
if (!this._suppressCompletionLogging) {
|
|
1556
|
-
logger$
|
|
1556
|
+
logger$1k.debug('task_completed_successfully', {
|
|
1557
1557
|
task_name: taskName,
|
|
1558
1558
|
task_id: taskId,
|
|
1559
1559
|
duration_ms: Date.now() - task.startTime,
|
|
@@ -1607,7 +1607,7 @@ class TaskSpawner {
|
|
|
1607
1607
|
error.name === 'AbortError' ||
|
|
1608
1608
|
error.message === 'Task cancelled' ||
|
|
1609
1609
|
error.message === 'Aborted') {
|
|
1610
|
-
logger$
|
|
1610
|
+
logger$1k.debug('task_cancelled', {
|
|
1611
1611
|
task_name: taskName,
|
|
1612
1612
|
note: 'Task cancelled as requested',
|
|
1613
1613
|
});
|
|
@@ -1615,7 +1615,7 @@ class TaskSpawner {
|
|
|
1615
1615
|
}
|
|
1616
1616
|
// Handle timeout
|
|
1617
1617
|
if (error instanceof TaskTimeoutError) {
|
|
1618
|
-
logger$
|
|
1618
|
+
logger$1k.warning('task_timed_out', {
|
|
1619
1619
|
task_name: taskName,
|
|
1620
1620
|
error: error.message,
|
|
1621
1621
|
});
|
|
@@ -1627,7 +1627,7 @@ class TaskSpawner {
|
|
|
1627
1627
|
// Handle known WebSocket shutdown race condition (similar to Python version)
|
|
1628
1628
|
if (error.message.includes("await wasn't used with future") ||
|
|
1629
1629
|
error.message.includes('WebSocket closed during receive')) {
|
|
1630
|
-
logger$
|
|
1630
|
+
logger$1k.debug('task_shutdown_race_condition_handled', {
|
|
1631
1631
|
task_name: taskName,
|
|
1632
1632
|
note: 'Normal WebSocket close timing during shutdown - not an error',
|
|
1633
1633
|
});
|
|
@@ -1637,7 +1637,7 @@ class TaskSpawner {
|
|
|
1637
1637
|
if (error.name === 'FameTransportClose' ||
|
|
1638
1638
|
error.message.includes('normal closure') ||
|
|
1639
1639
|
error.message.includes('Connection closed')) {
|
|
1640
|
-
logger$
|
|
1640
|
+
logger$1k.debug('task_shutdown_completed_normally', {
|
|
1641
1641
|
task_name: taskName,
|
|
1642
1642
|
note: 'Task closed normally during shutdown',
|
|
1643
1643
|
});
|
|
@@ -1645,7 +1645,7 @@ class TaskSpawner {
|
|
|
1645
1645
|
}
|
|
1646
1646
|
// Handle PKCE redirect "errors" as info
|
|
1647
1647
|
if (error.name === 'OAuth2PkceRedirectInitiatedError') {
|
|
1648
|
-
logger$
|
|
1648
|
+
logger$1k.debug('background_task_redirecting', {
|
|
1649
1649
|
task_name: taskName,
|
|
1650
1650
|
note: 'Task interrupted for PKCE redirect',
|
|
1651
1651
|
});
|
|
@@ -1658,14 +1658,14 @@ class TaskSpawner {
|
|
|
1658
1658
|
// Log retriable errors as warnings (they'll be retried by upstream logic)
|
|
1659
1659
|
// Log non-retriable errors as errors (fatal failures)
|
|
1660
1660
|
if (isRetriableError) {
|
|
1661
|
-
logger$
|
|
1661
|
+
logger$1k.warning('background_task_failed', {
|
|
1662
1662
|
task_name: taskName,
|
|
1663
1663
|
error: error.message,
|
|
1664
1664
|
retriable: true,
|
|
1665
1665
|
});
|
|
1666
1666
|
}
|
|
1667
1667
|
else {
|
|
1668
|
-
logger$
|
|
1668
|
+
logger$1k.error('background_task_failed', {
|
|
1669
1669
|
task_name: taskName,
|
|
1670
1670
|
error: error.message,
|
|
1671
1671
|
stack: error.stack,
|
|
@@ -1684,11 +1684,11 @@ class TaskSpawner {
|
|
|
1684
1684
|
async shutdownTasks(options = {}) {
|
|
1685
1685
|
const { gracePeriod, cancelHanging, joinTimeout } = normalizeShutdownOptions(options);
|
|
1686
1686
|
if (this._tasks.size === 0) {
|
|
1687
|
-
logger$
|
|
1687
|
+
logger$1k.debug('shutdown_tasks_no_tasks_to_shutdown');
|
|
1688
1688
|
return;
|
|
1689
1689
|
}
|
|
1690
1690
|
this._suppressCompletionLogging = true;
|
|
1691
|
-
logger$
|
|
1691
|
+
logger$1k.debug('shutting_down_tasks', {
|
|
1692
1692
|
task_count: this._tasks.size,
|
|
1693
1693
|
task_names: Array.from(this._tasks.values()).map((t) => t.name),
|
|
1694
1694
|
grace_period_ms: gracePeriod,
|
|
@@ -1703,7 +1703,7 @@ class TaskSpawner {
|
|
|
1703
1703
|
if (cancelHanging) {
|
|
1704
1704
|
const stillRunning = tasks.filter((task) => task.getState() === TaskState.RUNNING && !completed.has(task));
|
|
1705
1705
|
if (stillRunning.length > 0) {
|
|
1706
|
-
logger$
|
|
1706
|
+
logger$1k.debug('tasks_did_not_complete_within_grace_period', {
|
|
1707
1707
|
hanging_count: stillRunning.length,
|
|
1708
1708
|
});
|
|
1709
1709
|
// Wait for them to finish with individual timeouts
|
|
@@ -1713,7 +1713,7 @@ class TaskSpawner {
|
|
|
1713
1713
|
}
|
|
1714
1714
|
catch (error) {
|
|
1715
1715
|
if (error instanceof TaskTimeoutError) {
|
|
1716
|
-
logger$
|
|
1716
|
+
logger$1k.warning('task_did_not_shutdown', {
|
|
1717
1717
|
task_name: task.name || task.id,
|
|
1718
1718
|
join_timeout_ms: joinTimeout,
|
|
1719
1719
|
});
|
|
@@ -1724,7 +1724,7 @@ class TaskSpawner {
|
|
|
1724
1724
|
}
|
|
1725
1725
|
else if (!(error instanceof TaskCancelledError)) {
|
|
1726
1726
|
/* istanbul ignore next - unreachable defensive branch */
|
|
1727
|
-
logger$
|
|
1727
|
+
logger$1k.error('task_raised_during_cancellation', {
|
|
1728
1728
|
task_name: task.name || task.id,
|
|
1729
1729
|
error: error instanceof Error ? error.message : String(error),
|
|
1730
1730
|
});
|
|
@@ -2861,7 +2861,7 @@ async function safeImport(loader, dependencyNameOrOptions, maybeOptions) {
|
|
|
2861
2861
|
* condition/promise and ensure at most one notifier coroutine exists for a
|
|
2862
2862
|
* flow at any time.
|
|
2863
2863
|
*/
|
|
2864
|
-
const logger$
|
|
2864
|
+
const logger$1j = getLogger('naylence.fame.flow.flow_controller');
|
|
2865
2865
|
/**
|
|
2866
2866
|
* Simple condition variable implementation for TypeScript/Node.js
|
|
2867
2867
|
* Similar to Python's asyncio.Condition
|
|
@@ -2995,7 +2995,7 @@ class FlowController {
|
|
|
2995
2995
|
const newBalance = Math.max(0, Math.min(this.initialWindow, prev + delta));
|
|
2996
2996
|
this.credits.set(flowId, newBalance);
|
|
2997
2997
|
const crossedZero = prev <= 0 && newBalance > 0;
|
|
2998
|
-
logger$
|
|
2998
|
+
logger$1j.debug('flow_controller_add_credits', {
|
|
2999
2999
|
flow_id: flowId,
|
|
3000
3000
|
delta,
|
|
3001
3001
|
prev_balance: prev,
|
|
@@ -3015,12 +3015,12 @@ class FlowController {
|
|
|
3015
3015
|
async acquire(flowId) {
|
|
3016
3016
|
this.ensureFlow(flowId);
|
|
3017
3017
|
const condition = this.conditions.get(flowId);
|
|
3018
|
-
logger$
|
|
3018
|
+
logger$1j.debug('flow_controller_acquire_attempt', {
|
|
3019
3019
|
flow_id: flowId,
|
|
3020
3020
|
current_balance: this.credits.get(flowId),
|
|
3021
3021
|
});
|
|
3022
3022
|
while (this.credits.get(flowId) <= 0) {
|
|
3023
|
-
logger$
|
|
3023
|
+
logger$1j.debug('flow_controller_waiting_for_credits', {
|
|
3024
3024
|
flow_id: flowId,
|
|
3025
3025
|
current_balance: this.credits.get(flowId),
|
|
3026
3026
|
});
|
|
@@ -3028,12 +3028,12 @@ class FlowController {
|
|
|
3028
3028
|
}
|
|
3029
3029
|
const newBalance = this.credits.get(flowId) - 1;
|
|
3030
3030
|
this.credits.set(flowId, newBalance);
|
|
3031
|
-
logger$
|
|
3031
|
+
logger$1j.debug('flow_controller_acquire_success', {
|
|
3032
3032
|
flow_id: flowId,
|
|
3033
3033
|
new_balance: newBalance,
|
|
3034
3034
|
});
|
|
3035
3035
|
if (newBalance <= this.lowWatermark) {
|
|
3036
|
-
logger$
|
|
3036
|
+
logger$1j.debug('flow_controller_acquire_below_low_watermark', {
|
|
3037
3037
|
flow_id: flowId,
|
|
3038
3038
|
low_watermark: this.lowWatermark,
|
|
3039
3039
|
});
|
|
@@ -3057,7 +3057,7 @@ class FlowController {
|
|
|
3057
3057
|
const current = this.credits.get(flowId);
|
|
3058
3058
|
const remaining = Math.max(current - credits, 0);
|
|
3059
3059
|
this.credits.set(flowId, remaining);
|
|
3060
|
-
logger$
|
|
3060
|
+
logger$1j.debug('flow_controller_consume', {
|
|
3061
3061
|
flow_id: flowId,
|
|
3062
3062
|
requested: credits,
|
|
3063
3063
|
prev_balance: current,
|
|
@@ -3083,7 +3083,7 @@ class FlowController {
|
|
|
3083
3083
|
this.windowIds.delete(flowId);
|
|
3084
3084
|
this.credits.set(flowId, this.initialWindow);
|
|
3085
3085
|
this.wakeWaiters(flowId);
|
|
3086
|
-
logger$
|
|
3086
|
+
logger$1j.debug('flow_controller_flow_reset', {
|
|
3087
3087
|
flow_id: flowId,
|
|
3088
3088
|
reset_balance: this.initialWindow,
|
|
3089
3089
|
});
|
|
@@ -3371,7 +3371,7 @@ class InMemoryBinding {
|
|
|
3371
3371
|
* TypeScript port of Python's InMemoryFanoutBroker that extends TaskSpawner
|
|
3372
3372
|
* to manage multiple WriteChannel subscribers with concurrent message distribution.
|
|
3373
3373
|
*/
|
|
3374
|
-
const logger$
|
|
3374
|
+
const logger$1i = getLogger('naylence.fame.channel.in_memory.in_memory_fanout_broker');
|
|
3375
3375
|
// Sentinel object for shutdown signaling
|
|
3376
3376
|
const SENTINEL = Symbol('fanout-broker-sentinel');
|
|
3377
3377
|
function isCloseable(obj) {
|
|
@@ -3424,7 +3424,7 @@ class InMemoryFanoutBroker extends TaskSpawner {
|
|
|
3424
3424
|
}
|
|
3425
3425
|
catch (error) {
|
|
3426
3426
|
// Ignore errors when sending sentinel (sink might be closed)
|
|
3427
|
-
logger$
|
|
3427
|
+
logger$1i.debug('error_sending_sentinel', {
|
|
3428
3428
|
error: error.message,
|
|
3429
3429
|
});
|
|
3430
3430
|
}
|
|
@@ -3438,7 +3438,7 @@ class InMemoryFanoutBroker extends TaskSpawner {
|
|
|
3438
3438
|
await sub.close();
|
|
3439
3439
|
}
|
|
3440
3440
|
catch (error) {
|
|
3441
|
-
logger$
|
|
3441
|
+
logger$1i.error('error_closing_subscriber', {
|
|
3442
3442
|
subscriber: sub.toString(),
|
|
3443
3443
|
error: error.message,
|
|
3444
3444
|
});
|
|
@@ -3478,7 +3478,7 @@ class InMemoryFanoutBroker extends TaskSpawner {
|
|
|
3478
3478
|
[envelope, context] = core.extractEnvelopeAndContext(msg);
|
|
3479
3479
|
}
|
|
3480
3480
|
catch (error) {
|
|
3481
|
-
logger$
|
|
3481
|
+
logger$1i.debug('failed_to_extract_envelope', {
|
|
3482
3482
|
error: error.message,
|
|
3483
3483
|
});
|
|
3484
3484
|
continue;
|
|
@@ -3500,7 +3500,7 @@ class InMemoryFanoutBroker extends TaskSpawner {
|
|
|
3500
3500
|
await sub.send(messageToSend);
|
|
3501
3501
|
}
|
|
3502
3502
|
catch (error) {
|
|
3503
|
-
logger$
|
|
3503
|
+
logger$1i.error('error_sending_to_subscriber', {
|
|
3504
3504
|
subscriber: sub.toString(),
|
|
3505
3505
|
error: error.message,
|
|
3506
3506
|
action: 'unsubscribing',
|
|
@@ -3516,7 +3516,7 @@ class InMemoryFanoutBroker extends TaskSpawner {
|
|
|
3516
3516
|
}
|
|
3517
3517
|
catch (error) {
|
|
3518
3518
|
// Critical broker-level error: log and back off, but keep the loop running
|
|
3519
|
-
logger$
|
|
3519
|
+
logger$1i.critical('receive_loop_failed_unexpectedly', {
|
|
3520
3520
|
error: error.message,
|
|
3521
3521
|
stack: error.stack,
|
|
3522
3522
|
});
|
|
@@ -5192,7 +5192,7 @@ function normalizeResponseType(value) {
|
|
|
5192
5192
|
return value;
|
|
5193
5193
|
}
|
|
5194
5194
|
|
|
5195
|
-
const logger$
|
|
5195
|
+
const logger$1h = getLogger('naylence.fame.node.binding_manager');
|
|
5196
5196
|
const SYSTEM_INBOX$3 = '__sys__';
|
|
5197
5197
|
const DEFAULT_ACK_TIMEOUT_MS = 20000;
|
|
5198
5198
|
class BindingStoreEntryRecord {
|
|
@@ -5278,7 +5278,7 @@ class BindingManager {
|
|
|
5278
5278
|
if (!this.bindings.has(key)) {
|
|
5279
5279
|
const binding = this.bindingFactory(new core.FameAddress(key));
|
|
5280
5280
|
this.bindings.set(key, binding);
|
|
5281
|
-
logger$
|
|
5281
|
+
logger$1h.debug('restored_binding', { address: key });
|
|
5282
5282
|
}
|
|
5283
5283
|
}
|
|
5284
5284
|
if (!this.hasUpstream) {
|
|
@@ -5288,13 +5288,13 @@ class BindingManager {
|
|
|
5288
5288
|
await this.readvertiseCapabilitiesUpstream();
|
|
5289
5289
|
}
|
|
5290
5290
|
async bind(participant, capabilities) {
|
|
5291
|
-
logger$
|
|
5291
|
+
logger$1h.debug('binding_participant', { participant });
|
|
5292
5292
|
const { prefixAddress, addresses, propagateAddress, capabilityAddress } = this.computeBindingAddresses(participant);
|
|
5293
5293
|
for (const address of addresses) {
|
|
5294
5294
|
if (!this.bindings.has(address)) {
|
|
5295
5295
|
const binding = this.bindingFactory(new core.FameAddress(address));
|
|
5296
5296
|
this.bindings.set(address, binding);
|
|
5297
|
-
logger$
|
|
5297
|
+
logger$1h.debug('bound_address', { address, participant });
|
|
5298
5298
|
}
|
|
5299
5299
|
}
|
|
5300
5300
|
let propagatedAddress = null;
|
|
@@ -5323,7 +5323,7 @@ class BindingManager {
|
|
|
5323
5323
|
await this.unbindAddressUpstream(propagatedAddress);
|
|
5324
5324
|
}
|
|
5325
5325
|
catch (rollbackError) {
|
|
5326
|
-
logger$
|
|
5326
|
+
logger$1h.error('bind_rollback_failed', {
|
|
5327
5327
|
address: propagatedAddress.toString(),
|
|
5328
5328
|
error: rollbackError.message,
|
|
5329
5329
|
});
|
|
@@ -5342,7 +5342,7 @@ class BindingManager {
|
|
|
5342
5342
|
physicalPath: null,
|
|
5343
5343
|
});
|
|
5344
5344
|
}
|
|
5345
|
-
logger$
|
|
5345
|
+
logger$1h.debug('bind_success', {
|
|
5346
5346
|
participant,
|
|
5347
5347
|
address: prefixAddress.toString(),
|
|
5348
5348
|
capabilities,
|
|
@@ -5378,7 +5378,7 @@ class BindingManager {
|
|
|
5378
5378
|
await this.bindingStore.delete(address);
|
|
5379
5379
|
}
|
|
5380
5380
|
}
|
|
5381
|
-
logger$
|
|
5381
|
+
logger$1h.debug('unbind_success', {
|
|
5382
5382
|
participant,
|
|
5383
5383
|
address: prefixAddress.toString(),
|
|
5384
5384
|
totalBindings: this.bindings.size,
|
|
@@ -5408,7 +5408,7 @@ class BindingManager {
|
|
|
5408
5408
|
await this.bindAddressUpstream(new core.FameAddress(address));
|
|
5409
5409
|
}
|
|
5410
5410
|
catch (error) {
|
|
5411
|
-
logger$
|
|
5411
|
+
logger$1h.error('rebind_failed', {
|
|
5412
5412
|
address,
|
|
5413
5413
|
error: error.message,
|
|
5414
5414
|
});
|
|
@@ -5427,7 +5427,7 @@ class BindingManager {
|
|
|
5427
5427
|
await this.advertiseCapabilities(new core.FameAddress(address), Array.from(capabilities));
|
|
5428
5428
|
}
|
|
5429
5429
|
catch (error) {
|
|
5430
|
-
logger$
|
|
5430
|
+
logger$1h.error('capability_replay_failed', {
|
|
5431
5431
|
address,
|
|
5432
5432
|
error: error.message,
|
|
5433
5433
|
});
|
|
@@ -5694,7 +5694,7 @@ class BindingManager {
|
|
|
5694
5694
|
}
|
|
5695
5695
|
}
|
|
5696
5696
|
|
|
5697
|
-
const logger$
|
|
5697
|
+
const logger$1g = getLogger('naylence.fame.node.response_context_manager');
|
|
5698
5698
|
function cloneSecurityContext(source) {
|
|
5699
5699
|
if (!source) {
|
|
5700
5700
|
return undefined;
|
|
@@ -5722,7 +5722,7 @@ class ResponseContextManager {
|
|
|
5722
5722
|
security: responseSecurity,
|
|
5723
5723
|
expectedResponseType: core.FameResponseType.NONE,
|
|
5724
5724
|
};
|
|
5725
|
-
logger$
|
|
5725
|
+
logger$1g.debug('created_response_context', {
|
|
5726
5726
|
request_id: requestEnvelope.id,
|
|
5727
5727
|
inherited_crypto_level: responseSecurity?.inboundCryptoLevel ?? null,
|
|
5728
5728
|
channel_id: responseSecurity?.cryptoChannelId ?? null,
|
|
@@ -5742,14 +5742,14 @@ class ResponseContextManager {
|
|
|
5742
5742
|
responseContext.fromSystemId = this.getId();
|
|
5743
5743
|
}
|
|
5744
5744
|
// Envelope-level metadata is intentionally omitted to defer to context usage.
|
|
5745
|
-
logger$
|
|
5745
|
+
logger$1g.debug('ensured_response_metadata', {
|
|
5746
5746
|
response_id: responseEnvelope.id,
|
|
5747
5747
|
request_id: requestEnvelope.id,
|
|
5748
5748
|
});
|
|
5749
5749
|
}
|
|
5750
5750
|
}
|
|
5751
5751
|
|
|
5752
|
-
const logger$
|
|
5752
|
+
const logger$1f = getLogger('naylence.fame.node.streaming_response_handler');
|
|
5753
5753
|
function isObject(value) {
|
|
5754
5754
|
return typeof value === 'object' && value !== null;
|
|
5755
5755
|
}
|
|
@@ -5868,12 +5868,12 @@ class StreamingResponseHandler {
|
|
|
5868
5868
|
}
|
|
5869
5869
|
async handleStreamingFameMessageResponses(responses, requestEnvelope, requestContext) {
|
|
5870
5870
|
const asyncResponses = toAsyncIterable(responses);
|
|
5871
|
-
logger$
|
|
5871
|
+
logger$1f.debug('handling_streaming_fame_message_responses', {
|
|
5872
5872
|
request_id: requestEnvelope.id,
|
|
5873
5873
|
});
|
|
5874
5874
|
for await (const response of asyncResponses) {
|
|
5875
5875
|
if (!response?.envelope) {
|
|
5876
|
-
logger$
|
|
5876
|
+
logger$1f.warning('invalid_streaming_response_type', {
|
|
5877
5877
|
request_id: requestEnvelope.id,
|
|
5878
5878
|
actual_type: typeof response,
|
|
5879
5879
|
});
|
|
@@ -5887,7 +5887,7 @@ class StreamingResponseHandler {
|
|
|
5887
5887
|
}
|
|
5888
5888
|
async handleStreamingResponse(result, requestEnvelope, requestContext, replyTo, requestId) {
|
|
5889
5889
|
const iterable = toAsyncIterable(result);
|
|
5890
|
-
logger$
|
|
5890
|
+
logger$1f.debug('handling_streaming_response', {
|
|
5891
5891
|
request_id: requestId,
|
|
5892
5892
|
reply_to: replyTo,
|
|
5893
5893
|
});
|
|
@@ -5898,7 +5898,7 @@ class StreamingResponseHandler {
|
|
|
5898
5898
|
await this.sendRpcResponse(null, requestEnvelope, requestContext, replyTo, requestId);
|
|
5899
5899
|
}
|
|
5900
5900
|
catch (error) {
|
|
5901
|
-
logger$
|
|
5901
|
+
logger$1f.error('streaming_response_handler_error', {
|
|
5902
5902
|
request_id: requestId,
|
|
5903
5903
|
error: error instanceof Error ? error.message : String(error),
|
|
5904
5904
|
});
|
|
@@ -5925,7 +5925,7 @@ class StreamingResponseHandler {
|
|
|
5925
5925
|
});
|
|
5926
5926
|
const responseContext = this.responseContextManager.createResponseContext(requestEnvelope, requestContext);
|
|
5927
5927
|
this.responseContextManager.ensureResponseMetadata(responseEnvelope, requestEnvelope, responseContext);
|
|
5928
|
-
logger$
|
|
5928
|
+
logger$1f.debug('sending_streaming_rpc_response', {
|
|
5929
5929
|
request_id: requestId,
|
|
5930
5930
|
response_envelope_id: responseEnvelope.id,
|
|
5931
5931
|
reply_to: replyTo,
|
|
@@ -5938,7 +5938,7 @@ class StreamingResponseHandler {
|
|
|
5938
5938
|
}
|
|
5939
5939
|
}
|
|
5940
5940
|
|
|
5941
|
-
const logger$
|
|
5941
|
+
const logger$1e = getLogger('naylence.fame.node.channel_polling_manager');
|
|
5942
5942
|
class ChannelPollingManager {
|
|
5943
5943
|
constructor(deliverWrapper, responseContextManager, streamingResponseHandler) {
|
|
5944
5944
|
this.deliverWrapper = deliverWrapper;
|
|
@@ -5946,7 +5946,7 @@ class ChannelPollingManager {
|
|
|
5946
5946
|
this.streamingResponseHandler = streamingResponseHandler;
|
|
5947
5947
|
}
|
|
5948
5948
|
async startPollingLoop(serviceName, channel, handler, stopState, pollTimeoutMs = core.DEFAULT_POLLING_TIMEOUT_MS) {
|
|
5949
|
-
logger$
|
|
5949
|
+
logger$1e.debug('poll_loop_started', {
|
|
5950
5950
|
recipient: serviceName,
|
|
5951
5951
|
});
|
|
5952
5952
|
try {
|
|
@@ -5954,7 +5954,7 @@ class ChannelPollingManager {
|
|
|
5954
5954
|
while (true) {
|
|
5955
5955
|
if (this.isStopRequested(stopState) && !draining) {
|
|
5956
5956
|
draining = true;
|
|
5957
|
-
logger$
|
|
5957
|
+
logger$1e.debug('poll_loop_draining_pending_messages', {
|
|
5958
5958
|
recipient: serviceName,
|
|
5959
5959
|
});
|
|
5960
5960
|
}
|
|
@@ -5964,7 +5964,7 @@ class ChannelPollingManager {
|
|
|
5964
5964
|
}
|
|
5965
5965
|
catch (error) {
|
|
5966
5966
|
if (error instanceof FameTransportClose) {
|
|
5967
|
-
logger$
|
|
5967
|
+
logger$1e.debug('channel_closed', {
|
|
5968
5968
|
recipient: serviceName,
|
|
5969
5969
|
message: error.message,
|
|
5970
5970
|
});
|
|
@@ -5977,7 +5977,7 @@ class ChannelPollingManager {
|
|
|
5977
5977
|
continue;
|
|
5978
5978
|
}
|
|
5979
5979
|
if (error instanceof Error && error.name === 'AbortError') {
|
|
5980
|
-
logger$
|
|
5980
|
+
logger$1e.debug('listener_cancelled', {
|
|
5981
5981
|
recipient: serviceName,
|
|
5982
5982
|
});
|
|
5983
5983
|
throw error;
|
|
@@ -5989,13 +5989,13 @@ class ChannelPollingManager {
|
|
|
5989
5989
|
continue;
|
|
5990
5990
|
}
|
|
5991
5991
|
if (error instanceof Error && error.message === 'Channel is closed') {
|
|
5992
|
-
logger$
|
|
5992
|
+
logger$1e.debug('channel_closed', {
|
|
5993
5993
|
recipient: serviceName,
|
|
5994
5994
|
});
|
|
5995
5995
|
break;
|
|
5996
5996
|
}
|
|
5997
5997
|
if (error instanceof Error && error.name === 'TaskCancelledError') {
|
|
5998
|
-
logger$
|
|
5998
|
+
logger$1e.debug('listener_cancelled', {
|
|
5999
5999
|
recipient: serviceName,
|
|
6000
6000
|
});
|
|
6001
6001
|
throw error;
|
|
@@ -6007,12 +6007,12 @@ class ChannelPollingManager {
|
|
|
6007
6007
|
continue;
|
|
6008
6008
|
}
|
|
6009
6009
|
if (error instanceof Error && error.message.includes('closed')) {
|
|
6010
|
-
logger$
|
|
6010
|
+
logger$1e.debug('channel_closed', {
|
|
6011
6011
|
recipient: serviceName,
|
|
6012
6012
|
});
|
|
6013
6013
|
break;
|
|
6014
6014
|
}
|
|
6015
|
-
logger$
|
|
6015
|
+
logger$1e.error('transport_error', {
|
|
6016
6016
|
recipient: serviceName,
|
|
6017
6017
|
error: error instanceof Error ? error.message : String(error),
|
|
6018
6018
|
});
|
|
@@ -6028,7 +6028,7 @@ class ChannelPollingManager {
|
|
|
6028
6028
|
}
|
|
6029
6029
|
}
|
|
6030
6030
|
finally {
|
|
6031
|
-
logger$
|
|
6031
|
+
logger$1e.debug('poll_loop_exiting', {
|
|
6032
6032
|
recipient: serviceName,
|
|
6033
6033
|
});
|
|
6034
6034
|
}
|
|
@@ -6041,7 +6041,7 @@ class ChannelPollingManager {
|
|
|
6041
6041
|
await this.processHandlerResult(result, envelope, deliveryContext, serviceName);
|
|
6042
6042
|
}
|
|
6043
6043
|
catch (error) {
|
|
6044
|
-
logger$
|
|
6044
|
+
logger$1e.error('handler_crashed', {
|
|
6045
6045
|
recipient: serviceName,
|
|
6046
6046
|
error: error instanceof Error ? error.message : String(error),
|
|
6047
6047
|
});
|
|
@@ -6055,7 +6055,7 @@ class ChannelPollingManager {
|
|
|
6055
6055
|
return;
|
|
6056
6056
|
}
|
|
6057
6057
|
if (this.streamingResponseHandler.isStreamingFameMessageResponse(result)) {
|
|
6058
|
-
logger$
|
|
6058
|
+
logger$1e.debug('handling_streaming_fame_message_responses', {
|
|
6059
6059
|
service_name: serviceName,
|
|
6060
6060
|
envelope_id: envelope.id,
|
|
6061
6061
|
});
|
|
@@ -6063,7 +6063,7 @@ class ChannelPollingManager {
|
|
|
6063
6063
|
}
|
|
6064
6064
|
}
|
|
6065
6065
|
async handleMessageResponse(response, requestEnvelope, requestContext, serviceName) {
|
|
6066
|
-
logger$
|
|
6066
|
+
logger$1e.debug('delivering_envelope_response_message', {
|
|
6067
6067
|
service_name: serviceName,
|
|
6068
6068
|
response_envelope_id: response.envelope.id,
|
|
6069
6069
|
});
|
|
@@ -6083,7 +6083,7 @@ class ChannelPollingManager {
|
|
|
6083
6083
|
}
|
|
6084
6084
|
}
|
|
6085
6085
|
|
|
6086
|
-
const logger$
|
|
6086
|
+
const logger$1d = getLogger('naylence.fame.node.rpc_server_handler');
|
|
6087
6087
|
function isPlainRecord$6(value) {
|
|
6088
6088
|
if (typeof value !== 'object' || value === null) {
|
|
6089
6089
|
return false;
|
|
@@ -6127,13 +6127,13 @@ class RPCServerHandler {
|
|
|
6127
6127
|
}
|
|
6128
6128
|
async handleRpcRequest(envelope, handlerContext, handler, serviceName) {
|
|
6129
6129
|
if (!this.isDataFrame(envelope.frame)) {
|
|
6130
|
-
logger$
|
|
6130
|
+
logger$1d.warning('rpc_request_missing_data_frame', {
|
|
6131
6131
|
service_name: serviceName,
|
|
6132
6132
|
envelope_id: envelope.id,
|
|
6133
6133
|
});
|
|
6134
6134
|
return;
|
|
6135
6135
|
}
|
|
6136
|
-
logger$
|
|
6136
|
+
logger$1d.debug('rpc_request_received', {
|
|
6137
6137
|
service_name: serviceName,
|
|
6138
6138
|
envelope_id: envelope.id,
|
|
6139
6139
|
trace_id: envelope.traceId,
|
|
@@ -6145,7 +6145,7 @@ class RPCServerHandler {
|
|
|
6145
6145
|
request = core.parseRequest(envelope.frame.payload);
|
|
6146
6146
|
params = cloneParams(request.params);
|
|
6147
6147
|
const paramKeys = Object.keys(params);
|
|
6148
|
-
logger$
|
|
6148
|
+
logger$1d.debug('parsed_rpc_request', {
|
|
6149
6149
|
service_name: serviceName,
|
|
6150
6150
|
method: request.method,
|
|
6151
6151
|
request_id: request.id,
|
|
@@ -6154,7 +6154,7 @@ class RPCServerHandler {
|
|
|
6154
6154
|
});
|
|
6155
6155
|
}
|
|
6156
6156
|
catch (error) {
|
|
6157
|
-
logger$
|
|
6157
|
+
logger$1d.warning('request_decode_error', {
|
|
6158
6158
|
service_name: serviceName,
|
|
6159
6159
|
envelope_id: envelope.id,
|
|
6160
6160
|
error: error instanceof Error ? error.message : String(error),
|
|
@@ -6162,7 +6162,7 @@ class RPCServerHandler {
|
|
|
6162
6162
|
return;
|
|
6163
6163
|
}
|
|
6164
6164
|
if (request.id == null) {
|
|
6165
|
-
logger$
|
|
6165
|
+
logger$1d.warning('request_missing_id', {
|
|
6166
6166
|
service_name: serviceName,
|
|
6167
6167
|
envelope_id: envelope.id,
|
|
6168
6168
|
});
|
|
@@ -6170,7 +6170,7 @@ class RPCServerHandler {
|
|
|
6170
6170
|
}
|
|
6171
6171
|
const replyTo = this.resolveReplyTo(envelope, params);
|
|
6172
6172
|
if (!replyTo) {
|
|
6173
|
-
logger$
|
|
6173
|
+
logger$1d.warning('missing_reply_to', {
|
|
6174
6174
|
service_name: serviceName,
|
|
6175
6175
|
envelope_id: envelope.id,
|
|
6176
6176
|
request_id: request.id,
|
|
@@ -6179,13 +6179,13 @@ class RPCServerHandler {
|
|
|
6179
6179
|
}
|
|
6180
6180
|
let handlerResult;
|
|
6181
6181
|
try {
|
|
6182
|
-
logger$
|
|
6182
|
+
logger$1d.debug('calling_rpc_handler', {
|
|
6183
6183
|
service_name: serviceName,
|
|
6184
6184
|
method: request.method,
|
|
6185
6185
|
request_id: request.id,
|
|
6186
6186
|
});
|
|
6187
6187
|
handlerResult = await handler(request.method, params);
|
|
6188
|
-
logger$
|
|
6188
|
+
logger$1d.debug('rpc_handler_returned', {
|
|
6189
6189
|
service_name: serviceName,
|
|
6190
6190
|
method: request.method,
|
|
6191
6191
|
request_id: request.id,
|
|
@@ -6194,7 +6194,7 @@ class RPCServerHandler {
|
|
|
6194
6194
|
});
|
|
6195
6195
|
}
|
|
6196
6196
|
catch (error) {
|
|
6197
|
-
logger$
|
|
6197
|
+
logger$1d.error('rpc_handler_error', {
|
|
6198
6198
|
service_name: serviceName,
|
|
6199
6199
|
request_id: request.id,
|
|
6200
6200
|
envelope_id: envelope.id,
|
|
@@ -6204,7 +6204,7 @@ class RPCServerHandler {
|
|
|
6204
6204
|
return this.createTraditionalResponse(response, request.id, envelope, replyTo, handlerContext, serviceName);
|
|
6205
6205
|
}
|
|
6206
6206
|
if (core.isFameMessageResponse(handlerResult)) {
|
|
6207
|
-
logger$
|
|
6207
|
+
logger$1d.debug('returning_response_message', {
|
|
6208
6208
|
service_name: serviceName,
|
|
6209
6209
|
request_id: request.id,
|
|
6210
6210
|
response_envelope_id: handlerResult.envelope.id,
|
|
@@ -6212,7 +6212,7 @@ class RPCServerHandler {
|
|
|
6212
6212
|
return handlerResult;
|
|
6213
6213
|
}
|
|
6214
6214
|
if (this.streamingResponseHandler.isStreamingResult(handlerResult)) {
|
|
6215
|
-
logger$
|
|
6215
|
+
logger$1d.debug('handling_streaming_response', {
|
|
6216
6216
|
service_name: serviceName,
|
|
6217
6217
|
request_id: request.id,
|
|
6218
6218
|
envelope_id: envelope.id,
|
|
@@ -6241,7 +6241,7 @@ class RPCServerHandler {
|
|
|
6241
6241
|
return null;
|
|
6242
6242
|
}
|
|
6243
6243
|
async createTraditionalResponse(payload, requestId, requestEnvelope, replyTo, handlerContext, serviceName) {
|
|
6244
|
-
logger$
|
|
6244
|
+
logger$1d.debug('creating_traditional_response_envelope', {
|
|
6245
6245
|
service_name: serviceName,
|
|
6246
6246
|
request_id: requestId,
|
|
6247
6247
|
envelope_id: requestEnvelope.id,
|
|
@@ -6265,7 +6265,7 @@ class RPCServerHandler {
|
|
|
6265
6265
|
if (requestEnvelope.id) {
|
|
6266
6266
|
responseContext.meta['response-to-id'] = requestEnvelope.id;
|
|
6267
6267
|
}
|
|
6268
|
-
logger$
|
|
6268
|
+
logger$1d.debug('returning_traditional_response', {
|
|
6269
6269
|
service_name: serviceName,
|
|
6270
6270
|
request_id: requestId,
|
|
6271
6271
|
envelope_id: requestEnvelope.id,
|
|
@@ -6330,7 +6330,7 @@ function normalizeErrorCode(code) {
|
|
|
6330
6330
|
return code;
|
|
6331
6331
|
}
|
|
6332
6332
|
|
|
6333
|
-
const logger$
|
|
6333
|
+
const logger$1c = getLogger('naylence.fame.node.rpc_client_manager');
|
|
6334
6334
|
function isPlainRecord$5(value) {
|
|
6335
6335
|
if (typeof value !== 'object' || value === null) {
|
|
6336
6336
|
return false;
|
|
@@ -6547,7 +6547,7 @@ class RPCClientManager {
|
|
|
6547
6547
|
const metaReason = tracked.meta?.['nack_reason'];
|
|
6548
6548
|
const formattedMessage = formatDeliveryErrorMessage(typeof metaCode === 'string' ? metaCode : 'DELIVERY_ERROR', reason ??
|
|
6549
6549
|
(typeof metaReason === 'string' ? metaReason : undefined));
|
|
6550
|
-
logger$
|
|
6550
|
+
logger$1c.debug('pending_request_rejected_by_delivery_nack', {
|
|
6551
6551
|
envelope_id: envelopeId,
|
|
6552
6552
|
request_id: requestId,
|
|
6553
6553
|
code: typeof metaCode === 'string' ? metaCode : 'DELIVERY_ERROR',
|
|
@@ -6570,7 +6570,7 @@ class RPCClientManager {
|
|
|
6570
6570
|
this.trackerWithEvents.removeEventHandler?.(this.trackerEventHandler);
|
|
6571
6571
|
}
|
|
6572
6572
|
catch (error) {
|
|
6573
|
-
logger$
|
|
6573
|
+
logger$1c.debug('rpc_tracker_handler_remove_failed', {
|
|
6574
6574
|
error: error instanceof Error ? error.message : String(error),
|
|
6575
6575
|
});
|
|
6576
6576
|
}
|
|
@@ -6613,7 +6613,7 @@ class RPCClientManager {
|
|
|
6613
6613
|
this.rpcListenerAddress = await this.listenCallback(recipient, handler);
|
|
6614
6614
|
this.rpcBound = true;
|
|
6615
6615
|
this.boundPhysicalPath = currentPhysicalPath;
|
|
6616
|
-
logger$
|
|
6616
|
+
logger$1c.debug('rpc_reply_listener_bound', {
|
|
6617
6617
|
reply_recipient: recipient,
|
|
6618
6618
|
reply_address: this.rpcReplyAddress?.toString(),
|
|
6619
6619
|
listener_address: this.rpcListenerAddress?.toString(),
|
|
@@ -6707,7 +6707,7 @@ class RPCClientManager {
|
|
|
6707
6707
|
const finalizePromise = this.notifyStreamClosed(envelopeId);
|
|
6708
6708
|
if (finalizePromise) {
|
|
6709
6709
|
finalizePromise.catch((notifyError) => {
|
|
6710
|
-
logger$
|
|
6710
|
+
logger$1c.debug('stream_tracker_finalize_failed', {
|
|
6711
6711
|
request_id: requestId,
|
|
6712
6712
|
envelope_id: envelopeId,
|
|
6713
6713
|
error: notifyError instanceof Error
|
|
@@ -6768,7 +6768,7 @@ class RPCClientManager {
|
|
|
6768
6768
|
return iterator;
|
|
6769
6769
|
}
|
|
6770
6770
|
async sendRpcRequest(requestId, envelope, expectedResponseType, timeoutMs) {
|
|
6771
|
-
logger$
|
|
6771
|
+
logger$1c.debug('sending_rpc_request', {
|
|
6772
6772
|
envp_id: envelope.id,
|
|
6773
6773
|
corr_id: envelope.corrId,
|
|
6774
6774
|
request_id: requestId,
|
|
@@ -6784,7 +6784,7 @@ class RPCClientManager {
|
|
|
6784
6784
|
}
|
|
6785
6785
|
}
|
|
6786
6786
|
catch (error) {
|
|
6787
|
-
logger$
|
|
6787
|
+
logger$1c.warning('delivery_tracker_track_failed', {
|
|
6788
6788
|
request_id: requestId,
|
|
6789
6789
|
error: error instanceof Error ? error.message : String(error),
|
|
6790
6790
|
});
|
|
@@ -6797,14 +6797,14 @@ class RPCClientManager {
|
|
|
6797
6797
|
await this.deliverWrapper()(envelope, context);
|
|
6798
6798
|
}
|
|
6799
6799
|
async handleReplyEnvelope(envelope) {
|
|
6800
|
-
logger$
|
|
6800
|
+
logger$1c.debug('handle_reply_envelope_received', {
|
|
6801
6801
|
envelope_id: envelope.id,
|
|
6802
6802
|
corr_id: envelope.corrId,
|
|
6803
6803
|
frame_type: envelope.frame?.['type'],
|
|
6804
6804
|
});
|
|
6805
6805
|
let requestId = envelope.corrId ?? envelope.id;
|
|
6806
6806
|
if (!requestId) {
|
|
6807
|
-
logger$
|
|
6807
|
+
logger$1c.warning('reply_envelope_missing_corr_id', {
|
|
6808
6808
|
envelope_id: envelope.id,
|
|
6809
6809
|
});
|
|
6810
6810
|
return;
|
|
@@ -6822,12 +6822,12 @@ class RPCClientManager {
|
|
|
6822
6822
|
}
|
|
6823
6823
|
}
|
|
6824
6824
|
if (!entry) {
|
|
6825
|
-
logger$
|
|
6825
|
+
logger$1c.debug('no_pending_request_for_reply', {
|
|
6826
6826
|
request_id: requestId,
|
|
6827
6827
|
});
|
|
6828
6828
|
return;
|
|
6829
6829
|
}
|
|
6830
|
-
logger$
|
|
6830
|
+
logger$1c.debug('handle_reply_envelope', {
|
|
6831
6831
|
envelope_id: envelope.id,
|
|
6832
6832
|
request_id: requestId,
|
|
6833
6833
|
corr_id: envelope.corrId,
|
|
@@ -6840,7 +6840,7 @@ class RPCClientManager {
|
|
|
6840
6840
|
const ackIndicatesSuccess = frame.ok === true ||
|
|
6841
6841
|
(frame.ok === undefined && !frame.code && !frame.reason);
|
|
6842
6842
|
if (ackIndicatesSuccess) {
|
|
6843
|
-
logger$
|
|
6843
|
+
logger$1c.debug('pending_request_delivery_acknowledged', {
|
|
6844
6844
|
request_id: requestId,
|
|
6845
6845
|
envelope_id: envelope.id,
|
|
6846
6846
|
ref_id: frame.refId ?? null,
|
|
@@ -6868,7 +6868,7 @@ class RPCClientManager {
|
|
|
6868
6868
|
entry.timer = null;
|
|
6869
6869
|
}
|
|
6870
6870
|
if (!this.isDataFrame(envelope.frame)) {
|
|
6871
|
-
logger$
|
|
6871
|
+
logger$1c.warning('unexpected_reply_frame_type', {
|
|
6872
6872
|
request_id: requestId,
|
|
6873
6873
|
frame_type: envelope.frame?.['type'],
|
|
6874
6874
|
});
|
|
@@ -6934,7 +6934,7 @@ class RPCClientManager {
|
|
|
6934
6934
|
return;
|
|
6935
6935
|
}
|
|
6936
6936
|
Promise.resolve(this.deliveryTracker.onStreamItem(envelopeId, envelope)).catch((error) => {
|
|
6937
|
-
logger$
|
|
6937
|
+
logger$1c.debug('stream_tracker_push_failed', {
|
|
6938
6938
|
envelope_id: envelopeId,
|
|
6939
6939
|
error: error instanceof Error ? error.message : String(error),
|
|
6940
6940
|
});
|
|
@@ -7049,7 +7049,7 @@ function normalizeMailbox(mailbox) {
|
|
|
7049
7049
|
return mailbox;
|
|
7050
7050
|
}
|
|
7051
7051
|
|
|
7052
|
-
const logger$
|
|
7052
|
+
const logger$1b = getLogger('naylence.fame.node.envelope_listener_manager');
|
|
7053
7053
|
const SYSTEM_INBOX$2 = '__sys__';
|
|
7054
7054
|
class EnvelopeListener {
|
|
7055
7055
|
constructor(stopFn, task) {
|
|
@@ -7057,7 +7057,7 @@ class EnvelopeListener {
|
|
|
7057
7057
|
this.task = task;
|
|
7058
7058
|
}
|
|
7059
7059
|
stop() {
|
|
7060
|
-
logger$
|
|
7060
|
+
logger$1b.debug('stopping_listener', {
|
|
7061
7061
|
task_name: this.task.name,
|
|
7062
7062
|
});
|
|
7063
7063
|
try {
|
|
@@ -7065,7 +7065,7 @@ class EnvelopeListener {
|
|
|
7065
7065
|
if (maybeCleanup &&
|
|
7066
7066
|
typeof maybeCleanup.then === 'function') {
|
|
7067
7067
|
void maybeCleanup.catch((error) => {
|
|
7068
|
-
logger$
|
|
7068
|
+
logger$1b.debug('listener_stop_cleanup_failed', {
|
|
7069
7069
|
task_name: this.task.name,
|
|
7070
7070
|
error: error instanceof Error ? error.message : String(error),
|
|
7071
7071
|
});
|
|
@@ -7073,7 +7073,7 @@ class EnvelopeListener {
|
|
|
7073
7073
|
}
|
|
7074
7074
|
}
|
|
7075
7075
|
catch (error) {
|
|
7076
|
-
logger$
|
|
7076
|
+
logger$1b.debug('listener_stop_cleanup_failed', {
|
|
7077
7077
|
task_name: this.task.name,
|
|
7078
7078
|
error: error instanceof Error ? error.message : String(error),
|
|
7079
7079
|
});
|
|
@@ -7103,7 +7103,7 @@ class EnvelopeListenerManager extends TaskSpawner {
|
|
|
7103
7103
|
envelope.replyTo = core.formatAddress(SYSTEM_INBOX$2, this.nodeLike.physicalPath);
|
|
7104
7104
|
}
|
|
7105
7105
|
catch (error) {
|
|
7106
|
-
logger$
|
|
7106
|
+
logger$1b.warning('default_reply_to_assignment_failed', {
|
|
7107
7107
|
envelope_id: envelope.id,
|
|
7108
7108
|
service_name: envelope.capabilities?.[0] ?? null,
|
|
7109
7109
|
error: error instanceof Error ? error.message : String(error),
|
|
@@ -7128,7 +7128,7 @@ class EnvelopeListenerManager extends TaskSpawner {
|
|
|
7128
7128
|
if (serviceName === SYSTEM_INBOX$2) {
|
|
7129
7129
|
continue;
|
|
7130
7130
|
}
|
|
7131
|
-
logger$
|
|
7131
|
+
logger$1b.debug('stopping_listener_for_service', {
|
|
7132
7132
|
service_name: serviceName,
|
|
7133
7133
|
});
|
|
7134
7134
|
entry.listener.stop();
|
|
@@ -7138,7 +7138,7 @@ class EnvelopeListenerManager extends TaskSpawner {
|
|
|
7138
7138
|
catch (error) {
|
|
7139
7139
|
if (!(error instanceof Error) ||
|
|
7140
7140
|
error.name !== 'TaskCancelledError') {
|
|
7141
|
-
logger$
|
|
7141
|
+
logger$1b.debug('listener_task_stopped', {
|
|
7142
7142
|
service_name: serviceName,
|
|
7143
7143
|
error: error instanceof Error ? error.message : String(error),
|
|
7144
7144
|
});
|
|
@@ -7146,7 +7146,7 @@ class EnvelopeListenerManager extends TaskSpawner {
|
|
|
7146
7146
|
}
|
|
7147
7147
|
}
|
|
7148
7148
|
if (systemEntry) {
|
|
7149
|
-
logger$
|
|
7149
|
+
logger$1b.debug('stopping_listener_for_service', {
|
|
7150
7150
|
service_name: SYSTEM_INBOX$2,
|
|
7151
7151
|
});
|
|
7152
7152
|
systemEntry.listener.stop();
|
|
@@ -7156,7 +7156,7 @@ class EnvelopeListenerManager extends TaskSpawner {
|
|
|
7156
7156
|
catch (error) {
|
|
7157
7157
|
if (!(error instanceof Error) ||
|
|
7158
7158
|
error.name !== 'TaskCancelledError') {
|
|
7159
|
-
logger$
|
|
7159
|
+
logger$1b.debug('listener_task_stopped', {
|
|
7160
7160
|
service_name: SYSTEM_INBOX$2,
|
|
7161
7161
|
error: error instanceof Error ? error.message : String(error),
|
|
7162
7162
|
});
|
|
@@ -7173,13 +7173,13 @@ class EnvelopeListenerManager extends TaskSpawner {
|
|
|
7173
7173
|
}
|
|
7174
7174
|
async recoverUnhandledInboundEnvelopes() {
|
|
7175
7175
|
if (typeof this.deliveryTracker.listInbound !== 'function') {
|
|
7176
|
-
logger$
|
|
7176
|
+
logger$1b.debug('delivery_tracker_missing_inbound_listing');
|
|
7177
7177
|
return;
|
|
7178
7178
|
}
|
|
7179
7179
|
const failedInbound = await this.deliveryTracker.listInbound((env) => env.status === EnvelopeStatus.RECEIVED ||
|
|
7180
7180
|
env.status === EnvelopeStatus.FAILED_TO_HANDLE);
|
|
7181
7181
|
if (!failedInbound.length) {
|
|
7182
|
-
logger$
|
|
7182
|
+
logger$1b.debug('no_failed_inbound_envelopes_to_recover');
|
|
7183
7183
|
return;
|
|
7184
7184
|
}
|
|
7185
7185
|
const grouped = new Map();
|
|
@@ -7196,7 +7196,7 @@ class EnvelopeListenerManager extends TaskSpawner {
|
|
|
7196
7196
|
this.pendingRecoveryEnvelopes.set(serviceName, envelopes);
|
|
7197
7197
|
}
|
|
7198
7198
|
});
|
|
7199
|
-
logger$
|
|
7199
|
+
logger$1b.debug('discovered_failed_inbound_envelopes', {
|
|
7200
7200
|
total: failedInbound.length,
|
|
7201
7201
|
services: Array.from(grouped.keys()),
|
|
7202
7202
|
});
|
|
@@ -7206,7 +7206,7 @@ class EnvelopeListenerManager extends TaskSpawner {
|
|
|
7206
7206
|
const pollTimeoutMs = options.pollTimeoutMs ??
|
|
7207
7207
|
options.poll_timeout_ms ??
|
|
7208
7208
|
core.DEFAULT_POLLING_TIMEOUT_MS;
|
|
7209
|
-
logger$
|
|
7209
|
+
logger$1b.debug('listen_start', {
|
|
7210
7210
|
recipient: serviceName,
|
|
7211
7211
|
poll_timeout_ms: pollTimeoutMs ?? core.DEFAULT_POLLING_TIMEOUT_MS,
|
|
7212
7212
|
});
|
|
@@ -7237,7 +7237,7 @@ class EnvelopeListenerManager extends TaskSpawner {
|
|
|
7237
7237
|
tracked?.mailboxType === MailboxType.OUTBOX ||
|
|
7238
7238
|
envelope.frame?.['type'] === 'DeliveryAck';
|
|
7239
7239
|
if (!shouldInvoke) {
|
|
7240
|
-
logger$
|
|
7240
|
+
logger$1b.debug('skipping_listener_handler', {
|
|
7241
7241
|
recipient: serviceName,
|
|
7242
7242
|
envelope_id: envelope.id,
|
|
7243
7243
|
tracked_status: tracked?.status,
|
|
@@ -7251,13 +7251,13 @@ class EnvelopeListenerManager extends TaskSpawner {
|
|
|
7251
7251
|
? undefined
|
|
7252
7252
|
: (tracked ?? undefined);
|
|
7253
7253
|
if (trackedForHandler && trackedForHandler.attempt > 0) {
|
|
7254
|
-
logger$
|
|
7254
|
+
logger$1b.info('resuming_handler_retry_after_restart', {
|
|
7255
7255
|
envelope_id: envelope.id,
|
|
7256
7256
|
current_attempts: trackedForHandler.attempt,
|
|
7257
7257
|
service_name: serviceName,
|
|
7258
7258
|
});
|
|
7259
7259
|
}
|
|
7260
|
-
logger$
|
|
7260
|
+
logger$1b.debug('forwarding_to_listener_handler', {
|
|
7261
7261
|
recipient: serviceName,
|
|
7262
7262
|
envelope_id: envelope.id,
|
|
7263
7263
|
frame_type: envelope.frame?.['type'],
|
|
@@ -7276,7 +7276,7 @@ class EnvelopeListenerManager extends TaskSpawner {
|
|
|
7276
7276
|
await channel.send(null);
|
|
7277
7277
|
}
|
|
7278
7278
|
catch (error) {
|
|
7279
|
-
logger$
|
|
7279
|
+
logger$1b.debug('listener_stop_signal_failed', {
|
|
7280
7280
|
service_name: serviceName,
|
|
7281
7281
|
error: error instanceof Error ? error.message : String(error),
|
|
7282
7282
|
});
|
|
@@ -7285,7 +7285,7 @@ class EnvelopeListenerManager extends TaskSpawner {
|
|
|
7285
7285
|
await this.listenersLock.runExclusive(async () => {
|
|
7286
7286
|
const existing = this.listeners.get(serviceName);
|
|
7287
7287
|
if (existing) {
|
|
7288
|
-
logger$
|
|
7288
|
+
logger$1b.debug('replacing_envelope_listener', { recipient: serviceName });
|
|
7289
7289
|
existing.listener.stop();
|
|
7290
7290
|
try {
|
|
7291
7291
|
await existing.listener.task.promise;
|
|
@@ -7303,13 +7303,13 @@ class EnvelopeListenerManager extends TaskSpawner {
|
|
|
7303
7303
|
return binding.address;
|
|
7304
7304
|
}
|
|
7305
7305
|
async listenRpc(serviceName, handler, options = {}) {
|
|
7306
|
-
logger$
|
|
7306
|
+
logger$1b.debug('rpc_listen_start', { service_name: serviceName });
|
|
7307
7307
|
const rpcHandler = async (envelope, context) => {
|
|
7308
7308
|
const result = await this.rpcServerHandler.handleRpcRequest(envelope, context, handler, serviceName);
|
|
7309
7309
|
return result ?? null;
|
|
7310
7310
|
};
|
|
7311
7311
|
const address = await this.listen(serviceName, rpcHandler, options);
|
|
7312
|
-
logger$
|
|
7312
|
+
logger$1b.debug('rpc_listen_bound', {
|
|
7313
7313
|
service_name: serviceName,
|
|
7314
7314
|
address: address.toString(),
|
|
7315
7315
|
});
|
|
@@ -7378,12 +7378,12 @@ class EnvelopeListenerManager extends TaskSpawner {
|
|
|
7378
7378
|
return cached;
|
|
7379
7379
|
});
|
|
7380
7380
|
if (!envelopes.length) {
|
|
7381
|
-
logger$
|
|
7381
|
+
logger$1b.debug('no_cached_recovery_for_service', {
|
|
7382
7382
|
service_name: serviceName,
|
|
7383
7383
|
});
|
|
7384
7384
|
return;
|
|
7385
7385
|
}
|
|
7386
|
-
logger$
|
|
7386
|
+
logger$1b.debug('recovering_unhandled_envelopes_on_listen', {
|
|
7387
7387
|
service_name: serviceName,
|
|
7388
7388
|
count: envelopes.length,
|
|
7389
7389
|
envelope_ids: envelopes.map((trackedEnvelope) => trackedEnvelope.envelopeId),
|
|
@@ -7394,7 +7394,7 @@ class EnvelopeListenerManager extends TaskSpawner {
|
|
|
7394
7394
|
async recoverServiceEnvelopes(serviceName, envelopes, handler) {
|
|
7395
7395
|
for (const tracked of envelopes) {
|
|
7396
7396
|
try {
|
|
7397
|
-
logger$
|
|
7397
|
+
logger$1b.warning('recovering_unhandled_envelope', {
|
|
7398
7398
|
envelope_id: tracked.envelopeId,
|
|
7399
7399
|
service_name: serviceName,
|
|
7400
7400
|
current_attempts: tracked.attempt,
|
|
@@ -7403,13 +7403,13 @@ class EnvelopeListenerManager extends TaskSpawner {
|
|
|
7403
7403
|
const originalEnvelope = tracked.originalEnvelope;
|
|
7404
7404
|
const receiverPolicy = this.nodeLike.deliveryPolicy?.receiverRetryPolicy ?? undefined;
|
|
7405
7405
|
await this.executeHandlerWithRetries(handler, originalEnvelope, undefined, receiverPolicy, tracked, serviceName);
|
|
7406
|
-
logger$
|
|
7406
|
+
logger$1b.debug('envelope_recovery_completed', {
|
|
7407
7407
|
envelope_id: tracked.envelopeId,
|
|
7408
7408
|
service_name: serviceName,
|
|
7409
7409
|
});
|
|
7410
7410
|
}
|
|
7411
7411
|
catch (error) {
|
|
7412
|
-
logger$
|
|
7412
|
+
logger$1b.error('envelope_recovery_failed', {
|
|
7413
7413
|
envelope_id: tracked.envelopeId,
|
|
7414
7414
|
service_name: serviceName,
|
|
7415
7415
|
error: error instanceof Error ? error.message : String(error),
|
|
@@ -7455,7 +7455,7 @@ class EnvelopeListenerManager extends TaskSpawner {
|
|
|
7455
7455
|
await this.deliveryTracker.onEnvelopeHandled(trackedEnvelope);
|
|
7456
7456
|
}
|
|
7457
7457
|
if (currentAttempt > 0) {
|
|
7458
|
-
logger$
|
|
7458
|
+
logger$1b.info('handler_retry_succeeded', {
|
|
7459
7459
|
envelope_id: envelope.id,
|
|
7460
7460
|
attempt: currentAttempt + 1,
|
|
7461
7461
|
total_attempts: currentAttempt + 1,
|
|
@@ -7471,7 +7471,7 @@ class EnvelopeListenerManager extends TaskSpawner {
|
|
|
7471
7471
|
await this.deliveryTracker.onEnvelopeHandleFailed(inboxName, trackedEnvelope, context, error instanceof Error ? error : new Error(String(error)), isFinalAttempt);
|
|
7472
7472
|
}
|
|
7473
7473
|
if (isFinalAttempt) {
|
|
7474
|
-
logger$
|
|
7474
|
+
logger$1b.error('handler_execution_failed_exhausted_retries', {
|
|
7475
7475
|
envelope_id: envelope.id,
|
|
7476
7476
|
total_attempts: attemptNumber,
|
|
7477
7477
|
max_retries: retryPolicy?.maxRetries ?? 0,
|
|
@@ -7480,7 +7480,7 @@ class EnvelopeListenerManager extends TaskSpawner {
|
|
|
7480
7480
|
break;
|
|
7481
7481
|
}
|
|
7482
7482
|
const delayMs = retryPolicy?.nextDelayMs(attemptNumber) ?? 0;
|
|
7483
|
-
logger$
|
|
7483
|
+
logger$1b.warning('handler_execution_failed_will_retry', {
|
|
7484
7484
|
envelope_id: envelope.id,
|
|
7485
7485
|
attempt: attemptNumber,
|
|
7486
7486
|
max_retries: retryPolicy?.maxRetries ?? 0,
|
|
@@ -7510,7 +7510,7 @@ class EnvelopeListenerManager extends TaskSpawner {
|
|
|
7510
7510
|
}
|
|
7511
7511
|
}
|
|
7512
7512
|
|
|
7513
|
-
const logger$
|
|
7513
|
+
const logger$1a = getLogger('naylence.fame.delivery.default_delivery_tracker');
|
|
7514
7514
|
const STREAM_END = Symbol('stream-end');
|
|
7515
7515
|
const SWEEPER_TICK = Symbol('tracker-sweeper-tick');
|
|
7516
7516
|
function createDeferred$2() {
|
|
@@ -7729,7 +7729,7 @@ class DefaultDeliveryTracker extends TaskSpawner {
|
|
|
7729
7729
|
const expectedResponseType = options.expectedResponseType;
|
|
7730
7730
|
const tracked = await this.lock.runExclusive(async () => {
|
|
7731
7731
|
if (this.ackFutures.has(envelope.id)) {
|
|
7732
|
-
logger$
|
|
7732
|
+
logger$1a.debug('tracker_envelope_already_tracked', {
|
|
7733
7733
|
envp_id: envelope.id,
|
|
7734
7734
|
});
|
|
7735
7735
|
return null;
|
|
@@ -7739,7 +7739,7 @@ class DefaultDeliveryTracker extends TaskSpawner {
|
|
|
7739
7739
|
if (expectedResponseType & core.FameResponseType.REPLY ||
|
|
7740
7740
|
expectedResponseType & core.FameResponseType.STREAM) {
|
|
7741
7741
|
if (existingEnvId && existingEnvId !== envelope.id) {
|
|
7742
|
-
logger$
|
|
7742
|
+
logger$1a.debug('envelope_already_tracked_for_replies', {
|
|
7743
7743
|
envp_id: envelope.id,
|
|
7744
7744
|
corr_id: corrId,
|
|
7745
7745
|
expected_response_type: expectedResponseType,
|
|
@@ -7788,7 +7788,7 @@ class DefaultDeliveryTracker extends TaskSpawner {
|
|
|
7788
7788
|
return null;
|
|
7789
7789
|
}
|
|
7790
7790
|
await this.scheduleTimer(tracked, options.retryPolicy ?? null, options.retryHandler ?? null);
|
|
7791
|
-
logger$
|
|
7791
|
+
logger$1a.debug('tracker_registered_envelope', {
|
|
7792
7792
|
envp_id: envelope.id,
|
|
7793
7793
|
corr_id: tracked.originalEnvelope.corrId,
|
|
7794
7794
|
expected_response: tracked.expectedResponseType,
|
|
@@ -7812,21 +7812,21 @@ class DefaultDeliveryTracker extends TaskSpawner {
|
|
|
7812
7812
|
return this.awaitEnvelopeFuture(envelopeId, core.FameResponseType.REPLY | core.FameResponseType.STREAM, future, timeoutMs);
|
|
7813
7813
|
}
|
|
7814
7814
|
async onEnvelopeDelivered(inboxName, envelope, context) {
|
|
7815
|
-
logger$
|
|
7815
|
+
logger$1a.debug('envelope_delivered', {
|
|
7816
7816
|
envp_id: envelope.id,
|
|
7817
7817
|
corr_id: envelope.corrId,
|
|
7818
7818
|
rtype: envelope.rtype ?? core.FameResponseType.NONE,
|
|
7819
7819
|
frame_type: envelope.frame?.type ?? 'unknown',
|
|
7820
7820
|
});
|
|
7821
7821
|
if (!envelope.corrId) {
|
|
7822
|
-
logger$
|
|
7822
|
+
logger$1a.debug('envelope_delivered_no_corr_id', {
|
|
7823
7823
|
envelope_id: envelope.id,
|
|
7824
7824
|
});
|
|
7825
7825
|
return null;
|
|
7826
7826
|
}
|
|
7827
7827
|
if (this.isDeliveryAckFrame(envelope.frame)) {
|
|
7828
7828
|
if (!envelope.frame.refId) {
|
|
7829
|
-
logger$
|
|
7829
|
+
logger$1a.debug('envelope_delivered_no_ref_id', {
|
|
7830
7830
|
envelope_id: envelope.id,
|
|
7831
7831
|
});
|
|
7832
7832
|
return null;
|
|
@@ -7863,7 +7863,7 @@ class DefaultDeliveryTracker extends TaskSpawner {
|
|
|
7863
7863
|
await inbox.set(envelope.id, tracked);
|
|
7864
7864
|
}
|
|
7865
7865
|
else {
|
|
7866
|
-
logger$
|
|
7866
|
+
logger$1a.debug('tracker_duplicate_envelope_already_handled', {
|
|
7867
7867
|
envp_id: envelope.id,
|
|
7868
7868
|
status: tracked.status,
|
|
7869
7869
|
});
|
|
@@ -7905,7 +7905,7 @@ class DefaultDeliveryTracker extends TaskSpawner {
|
|
|
7905
7905
|
}
|
|
7906
7906
|
if (isFinalFailure) {
|
|
7907
7907
|
envelope.status = EnvelopeStatus.FAILED_TO_HANDLE;
|
|
7908
|
-
logger$
|
|
7908
|
+
logger$1a.error('envelope_handle_failed_final', {
|
|
7909
7909
|
inbox_name: inboxName,
|
|
7910
7910
|
envp_id: envelope.originalEnvelope.id,
|
|
7911
7911
|
error: error?.message ?? 'unknown',
|
|
@@ -7916,7 +7916,7 @@ class DefaultDeliveryTracker extends TaskSpawner {
|
|
|
7916
7916
|
await inbox.delete(envelope.originalEnvelope.id);
|
|
7917
7917
|
return;
|
|
7918
7918
|
}
|
|
7919
|
-
logger$
|
|
7919
|
+
logger$1a.warning('envelope_handle_failed_retry', {
|
|
7920
7920
|
inbox_name: inboxName,
|
|
7921
7921
|
envp_id: envelope.originalEnvelope.id,
|
|
7922
7922
|
error: error?.message ?? 'unknown',
|
|
@@ -7961,14 +7961,14 @@ class DefaultDeliveryTracker extends TaskSpawner {
|
|
|
7961
7961
|
if (handledViaFuture) {
|
|
7962
7962
|
await this.markDoneSince(this.ackFutures, refId, this.ackDoneSince);
|
|
7963
7963
|
await this.clearTimer(refId);
|
|
7964
|
-
logger$
|
|
7964
|
+
logger$1a.debug('tracker_ack_resolved_without_tracked_envelope', {
|
|
7965
7965
|
envp_id: envelope.id,
|
|
7966
7966
|
ref_id: refId,
|
|
7967
7967
|
corr_id: envelope.corrId,
|
|
7968
7968
|
});
|
|
7969
7969
|
return;
|
|
7970
7970
|
}
|
|
7971
|
-
logger$
|
|
7971
|
+
logger$1a.debug('tracker_ack_for_unknown_envelope', {
|
|
7972
7972
|
envp_id: envelope.id,
|
|
7973
7973
|
ref_id: refId,
|
|
7974
7974
|
corr_id: envelope.corrId,
|
|
@@ -7976,7 +7976,7 @@ class DefaultDeliveryTracker extends TaskSpawner {
|
|
|
7976
7976
|
return;
|
|
7977
7977
|
}
|
|
7978
7978
|
if (tracked.originalEnvelope.corrId !== envelope.corrId) {
|
|
7979
|
-
logger$
|
|
7979
|
+
logger$1a.debug('tracker_ack_corr_id_mismatch', {
|
|
7980
7980
|
envp_id: envelope.id,
|
|
7981
7981
|
expected_corr_id: tracked.originalEnvelope.corrId,
|
|
7982
7982
|
actual_corr_id: envelope.corrId,
|
|
@@ -8001,7 +8001,7 @@ class DefaultDeliveryTracker extends TaskSpawner {
|
|
|
8001
8001
|
for (const handler of this.eventHandlers) {
|
|
8002
8002
|
await handler.onEnvelopeAcked?.(tracked);
|
|
8003
8003
|
}
|
|
8004
|
-
logger$
|
|
8004
|
+
logger$1a.debug('tracker_envelope_acked', {
|
|
8005
8005
|
envp_id: tracked.originalEnvelope.id,
|
|
8006
8006
|
});
|
|
8007
8007
|
}
|
|
@@ -8018,13 +8018,13 @@ class DefaultDeliveryTracker extends TaskSpawner {
|
|
|
8018
8018
|
const outbox = this.ensureOutbox();
|
|
8019
8019
|
const tracked = await outbox.get(envelope.frame.refId);
|
|
8020
8020
|
if (!tracked) {
|
|
8021
|
-
logger$
|
|
8021
|
+
logger$1a.debug('tracker_nack_for_unknown_envelope', {
|
|
8022
8022
|
envp_id: envelope.id,
|
|
8023
8023
|
});
|
|
8024
8024
|
return;
|
|
8025
8025
|
}
|
|
8026
8026
|
if (tracked.originalEnvelope.corrId !== envelope.corrId) {
|
|
8027
|
-
logger$
|
|
8027
|
+
logger$1a.debug('tracker_nack_corr_id_mismatch', {
|
|
8028
8028
|
envp_id: envelope.id,
|
|
8029
8029
|
expected_corr_id: tracked.originalEnvelope.corrId,
|
|
8030
8030
|
actual_corr_id: envelope.corrId,
|
|
@@ -8066,7 +8066,7 @@ class DefaultDeliveryTracker extends TaskSpawner {
|
|
|
8066
8066
|
for (const handler of this.eventHandlers) {
|
|
8067
8067
|
await handler.onEnvelopeNacked?.(tracked, ackFrame.reason ?? null);
|
|
8068
8068
|
}
|
|
8069
|
-
logger$
|
|
8069
|
+
logger$1a.debug('tracker_envelope_nacked', {
|
|
8070
8070
|
envp_id: tracked.originalEnvelope.id,
|
|
8071
8071
|
reason: ackFrame.reason,
|
|
8072
8072
|
});
|
|
@@ -8113,7 +8113,7 @@ class DefaultDeliveryTracker extends TaskSpawner {
|
|
|
8113
8113
|
for (const handler of this.eventHandlers) {
|
|
8114
8114
|
await handler.onEnvelopeReplied?.(trackedEnvelope, envelope);
|
|
8115
8115
|
}
|
|
8116
|
-
logger$
|
|
8116
|
+
logger$1a.debug('tracked_envelope_replied', {
|
|
8117
8117
|
envp_id: trackedEnvelope.originalEnvelope.id,
|
|
8118
8118
|
corr_id: envelope.corrId,
|
|
8119
8119
|
});
|
|
@@ -8187,7 +8187,7 @@ class DefaultDeliveryTracker extends TaskSpawner {
|
|
|
8187
8187
|
async addToInboxDlq(trackedEnvelope, reason = null) {
|
|
8188
8188
|
const dlq = this.inboxDlq;
|
|
8189
8189
|
if (!dlq) {
|
|
8190
|
-
logger$
|
|
8190
|
+
logger$1a.error('dlq_not_initialized', {
|
|
8191
8191
|
envp_id: trackedEnvelope.originalEnvelope.id,
|
|
8192
8192
|
});
|
|
8193
8193
|
return;
|
|
@@ -8202,7 +8202,7 @@ class DefaultDeliveryTracker extends TaskSpawner {
|
|
|
8202
8202
|
const deadLetteredAt = Date.now();
|
|
8203
8203
|
setMetaWithLegacy(trackedEnvelope.meta, 'deadLetteredAtMs', 'dead_lettered_at_ms', deadLetteredAt);
|
|
8204
8204
|
await dlq.set(trackedEnvelope.originalEnvelope.id, trackedEnvelope);
|
|
8205
|
-
logger$
|
|
8205
|
+
logger$1a.warning('envelope_moved_to_dlq', {
|
|
8206
8206
|
envp_id: trackedEnvelope.originalEnvelope.id,
|
|
8207
8207
|
service_name: trackedEnvelope.serviceName,
|
|
8208
8208
|
});
|
|
@@ -8231,7 +8231,7 @@ class DefaultDeliveryTracker extends TaskSpawner {
|
|
|
8231
8231
|
const toDelete = Object.entries(items).filter(([, value]) => predicate ? predicate(value) : true);
|
|
8232
8232
|
await Promise.all(toDelete.map(([key]) => dlq.delete(key)));
|
|
8233
8233
|
if (toDelete.length) {
|
|
8234
|
-
logger$
|
|
8234
|
+
logger$1a.debug('dlq_purged', { count: toDelete.length });
|
|
8235
8235
|
}
|
|
8236
8236
|
return toDelete.length;
|
|
8237
8237
|
}
|
|
@@ -8284,11 +8284,11 @@ class DefaultDeliveryTracker extends TaskSpawner {
|
|
|
8284
8284
|
}
|
|
8285
8285
|
this.futuresSweeper = null;
|
|
8286
8286
|
}
|
|
8287
|
-
logger$
|
|
8287
|
+
logger$1a.debug('tracker_cleanup_completed');
|
|
8288
8288
|
}
|
|
8289
8289
|
async recoverPending() {
|
|
8290
8290
|
const pending = await this.listPending();
|
|
8291
|
-
logger$
|
|
8291
|
+
logger$1a.debug('tracker_recovering_pending', { count: pending.length });
|
|
8292
8292
|
await this.lock.runExclusive(async () => {
|
|
8293
8293
|
for (const tracked of pending) {
|
|
8294
8294
|
if (tracked.expectedResponseType & core.FameResponseType.ACK) {
|
|
@@ -8314,7 +8314,7 @@ class DefaultDeliveryTracker extends TaskSpawner {
|
|
|
8314
8314
|
for (const tracked of pending) {
|
|
8315
8315
|
await this.scheduleTimer(tracked, null, null);
|
|
8316
8316
|
}
|
|
8317
|
-
logger$
|
|
8317
|
+
logger$1a.debug('tracker_recovery_completed', { count: pending.length });
|
|
8318
8318
|
}
|
|
8319
8319
|
ensureOutbox() {
|
|
8320
8320
|
if (!this.outbox) {
|
|
@@ -8329,7 +8329,7 @@ class DefaultDeliveryTracker extends TaskSpawner {
|
|
|
8329
8329
|
return this.inbox;
|
|
8330
8330
|
}
|
|
8331
8331
|
async waitForPendingAcks() {
|
|
8332
|
-
logger$
|
|
8332
|
+
logger$1a.debug('tracker_node_preparing_to_stop_waiting_for_pending_acks');
|
|
8333
8333
|
const outbox = this.outbox;
|
|
8334
8334
|
if (!outbox) {
|
|
8335
8335
|
return;
|
|
@@ -8341,7 +8341,7 @@ class DefaultDeliveryTracker extends TaskSpawner {
|
|
|
8341
8341
|
continue;
|
|
8342
8342
|
}
|
|
8343
8343
|
if (!future.done) {
|
|
8344
|
-
logger$
|
|
8344
|
+
logger$1a.debug('tracker_pending_ack_future_detected', {
|
|
8345
8345
|
envelope_id: envelopeId,
|
|
8346
8346
|
});
|
|
8347
8347
|
pending.push({ envelopeId, future });
|
|
@@ -8349,10 +8349,10 @@ class DefaultDeliveryTracker extends TaskSpawner {
|
|
|
8349
8349
|
}
|
|
8350
8350
|
});
|
|
8351
8351
|
if (!pending.length) {
|
|
8352
|
-
logger$
|
|
8352
|
+
logger$1a.debug('tracker_no_pending_acks_to_wait_for');
|
|
8353
8353
|
return;
|
|
8354
8354
|
}
|
|
8355
|
-
logger$
|
|
8355
|
+
logger$1a.debug('tracker_waiting_for_pending_acks', { count: pending.length });
|
|
8356
8356
|
for (const entry of pending) {
|
|
8357
8357
|
if (!entry) {
|
|
8358
8358
|
continue;
|
|
@@ -8369,19 +8369,19 @@ class DefaultDeliveryTracker extends TaskSpawner {
|
|
|
8369
8369
|
}
|
|
8370
8370
|
try {
|
|
8371
8371
|
await this.awaitWithTimeout(entry.future.promise, remainingMs);
|
|
8372
|
-
logger$
|
|
8372
|
+
logger$1a.debug('tracker_received_ack', {
|
|
8373
8373
|
envelope_id: entry.envelopeId,
|
|
8374
8374
|
});
|
|
8375
8375
|
await outbox.delete(entry.envelopeId);
|
|
8376
8376
|
}
|
|
8377
8377
|
catch (error) {
|
|
8378
8378
|
if (error instanceof Error && error.name === 'TimeoutError') {
|
|
8379
|
-
logger$
|
|
8379
|
+
logger$1a.debug('tracker_ack_timeout_expired', {
|
|
8380
8380
|
envelope_id: entry.envelopeId,
|
|
8381
8381
|
});
|
|
8382
8382
|
}
|
|
8383
8383
|
else {
|
|
8384
|
-
logger$
|
|
8384
|
+
logger$1a.debug('tracker_ack_wait_error', {
|
|
8385
8385
|
envelope_id: entry.envelopeId,
|
|
8386
8386
|
error: error instanceof Error ? error.message : String(error),
|
|
8387
8387
|
});
|
|
@@ -8389,13 +8389,13 @@ class DefaultDeliveryTracker extends TaskSpawner {
|
|
|
8389
8389
|
}
|
|
8390
8390
|
}
|
|
8391
8391
|
catch (error) {
|
|
8392
|
-
logger$
|
|
8392
|
+
logger$1a.error('tracker_error_waiting_for_ack', {
|
|
8393
8393
|
envelope_id: entry.envelopeId,
|
|
8394
8394
|
error: error instanceof Error ? error.message : String(error),
|
|
8395
8395
|
});
|
|
8396
8396
|
}
|
|
8397
8397
|
}
|
|
8398
|
-
logger$
|
|
8398
|
+
logger$1a.debug('tracker_finished_waiting_for_pending_acks');
|
|
8399
8399
|
}
|
|
8400
8400
|
async waitForPendingAckDispatches() {
|
|
8401
8401
|
while (this.pendingAckDispatches.size > 0) {
|
|
@@ -8453,7 +8453,7 @@ class DefaultDeliveryTracker extends TaskSpawner {
|
|
|
8453
8453
|
for (const handler of this.eventHandlers) {
|
|
8454
8454
|
await handler.onEnvelopeTimeout?.(currentTracked);
|
|
8455
8455
|
}
|
|
8456
|
-
logger$
|
|
8456
|
+
logger$1a.debug('tracker_envelope_timed_out', {
|
|
8457
8457
|
envp_id: tracked.originalEnvelope.id,
|
|
8458
8458
|
});
|
|
8459
8459
|
return;
|
|
@@ -8466,7 +8466,7 @@ class DefaultDeliveryTracker extends TaskSpawner {
|
|
|
8466
8466
|
currentTracked.timeoutAtMs = nextTimeoutAt;
|
|
8467
8467
|
await outbox.set(tracked.originalEnvelope.id, currentTracked);
|
|
8468
8468
|
await this.scheduleTimer(currentTracked, retryPolicy, retryHandler);
|
|
8469
|
-
logger$
|
|
8469
|
+
logger$1a.debug('tracker_retry_deferred_during_shutdown', {
|
|
8470
8470
|
envp_id: tracked.originalEnvelope.id,
|
|
8471
8471
|
defer_ms: shutdownDeferMs,
|
|
8472
8472
|
});
|
|
@@ -8489,7 +8489,7 @@ class DefaultDeliveryTracker extends TaskSpawner {
|
|
|
8489
8489
|
});
|
|
8490
8490
|
}
|
|
8491
8491
|
await this.scheduleTimer(currentTracked, retryPolicy, retryHandler);
|
|
8492
|
-
logger$
|
|
8492
|
+
logger$1a.debug('envelope_delivery_retry_scheduled', {
|
|
8493
8493
|
envp_id: tracked.originalEnvelope.id,
|
|
8494
8494
|
attempt: currentTracked.attempt,
|
|
8495
8495
|
max_retries: retryPolicy.maxRetries,
|
|
@@ -8501,7 +8501,7 @@ class DefaultDeliveryTracker extends TaskSpawner {
|
|
|
8501
8501
|
currentTracked.timeoutAtMs = currentTracked.overallTimeoutAtMs;
|
|
8502
8502
|
await outbox.set(tracked.originalEnvelope.id, currentTracked);
|
|
8503
8503
|
await this.scheduleTimer(currentTracked, retryPolicy, retryHandler);
|
|
8504
|
-
logger$
|
|
8504
|
+
logger$1a.debug('envelope_retries_exhausted_waiting_until_overall_timeout', {
|
|
8505
8505
|
envp_id: tracked.originalEnvelope.id,
|
|
8506
8506
|
attempt: currentTracked.attempt,
|
|
8507
8507
|
overall_timeout_at_ms: currentTracked.overallTimeoutAtMs,
|
|
@@ -8521,7 +8521,7 @@ class DefaultDeliveryTracker extends TaskSpawner {
|
|
|
8521
8521
|
for (const handler of this.eventHandlers) {
|
|
8522
8522
|
await handler.onEnvelopeTimeout?.(currentTracked);
|
|
8523
8523
|
}
|
|
8524
|
-
logger$
|
|
8524
|
+
logger$1a.debug('tracker_envelope_timed_out', {
|
|
8525
8525
|
envp_id: tracked.originalEnvelope.id,
|
|
8526
8526
|
});
|
|
8527
8527
|
}
|
|
@@ -8529,7 +8529,7 @@ class DefaultDeliveryTracker extends TaskSpawner {
|
|
|
8529
8529
|
if (error instanceof TaskCancelledError) {
|
|
8530
8530
|
return;
|
|
8531
8531
|
}
|
|
8532
|
-
logger$
|
|
8532
|
+
logger$1a.error('tracker_timer_error', {
|
|
8533
8533
|
envp_id: tracked.originalEnvelope.id,
|
|
8534
8534
|
error: error instanceof Error ? error.message : String(error),
|
|
8535
8535
|
});
|
|
@@ -8584,7 +8584,7 @@ class DefaultDeliveryTracker extends TaskSpawner {
|
|
|
8584
8584
|
if (timeoutSeconds !== null) {
|
|
8585
8585
|
return await this.awaitWithTimeout(future.promise, timeoutSeconds);
|
|
8586
8586
|
}
|
|
8587
|
-
logger$
|
|
8587
|
+
logger$1a.debug('await_envelope_no_timeout_wait', {
|
|
8588
8588
|
envelope_id: envelopeId,
|
|
8589
8589
|
});
|
|
8590
8590
|
return await future.promise;
|
|
@@ -8593,7 +8593,7 @@ class DefaultDeliveryTracker extends TaskSpawner {
|
|
|
8593
8593
|
if (error instanceof Error && error.name !== 'TimeoutError') {
|
|
8594
8594
|
throw error;
|
|
8595
8595
|
}
|
|
8596
|
-
logger$
|
|
8596
|
+
logger$1a.error('await_envelope_timeout_error', {
|
|
8597
8597
|
envelope_id: envelopeId,
|
|
8598
8598
|
timeout_ms: timeoutSeconds,
|
|
8599
8599
|
future_done: false,
|
|
@@ -8754,7 +8754,7 @@ class DefaultDeliveryTracker extends TaskSpawner {
|
|
|
8754
8754
|
this.replyDoneSince.delete(envId);
|
|
8755
8755
|
}
|
|
8756
8756
|
});
|
|
8757
|
-
logger$
|
|
8757
|
+
logger$1a.debug('tracker_swept_completed_futures', {
|
|
8758
8758
|
ack_removed: toRemoveAck.length,
|
|
8759
8759
|
reply_removed: toRemoveReply.length,
|
|
8760
8760
|
grace_secs: this.futGcGraceSecs,
|
|
@@ -8768,7 +8768,7 @@ class DefaultDeliveryTracker extends TaskSpawner {
|
|
|
8768
8768
|
if (error instanceof Error && error.name === 'TimeoutError') {
|
|
8769
8769
|
continue;
|
|
8770
8770
|
}
|
|
8771
|
-
logger$
|
|
8771
|
+
logger$1a.error('tracker_sweeper_error', {
|
|
8772
8772
|
error: error instanceof Error ? error.message : String(error),
|
|
8773
8773
|
});
|
|
8774
8774
|
}
|
|
@@ -8799,14 +8799,14 @@ class DefaultDeliveryTracker extends TaskSpawner {
|
|
|
8799
8799
|
}
|
|
8800
8800
|
const node = this.node;
|
|
8801
8801
|
if (!envelope.replyTo) {
|
|
8802
|
-
logger$
|
|
8802
|
+
logger$1a.error('cannot_send_ack_no_reply_to', { envp_id: envelope.id });
|
|
8803
8803
|
return;
|
|
8804
8804
|
}
|
|
8805
8805
|
if (!envelope.corrId) {
|
|
8806
|
-
logger$
|
|
8806
|
+
logger$1a.error('cannot_send_ack_no_corr_id', { envp_id: envelope.id });
|
|
8807
8807
|
return;
|
|
8808
8808
|
}
|
|
8809
|
-
logger$
|
|
8809
|
+
logger$1a.debug('tracker_sending_ack', {
|
|
8810
8810
|
envp_id: envelope.id,
|
|
8811
8811
|
ref_id: envelope.id,
|
|
8812
8812
|
to: envelope.replyTo,
|
|
@@ -8826,7 +8826,7 @@ class DefaultDeliveryTracker extends TaskSpawner {
|
|
|
8826
8826
|
.send(ackEnvelope)
|
|
8827
8827
|
.then(() => undefined)
|
|
8828
8828
|
.catch((error) => {
|
|
8829
|
-
logger$
|
|
8829
|
+
logger$1a.error('tracker_ack_dispatch_failed', {
|
|
8830
8830
|
envp_id: envelope.id,
|
|
8831
8831
|
error: error instanceof Error ? error.message : String(error),
|
|
8832
8832
|
});
|
|
@@ -8912,7 +8912,7 @@ class AsyncEvent {
|
|
|
8912
8912
|
}
|
|
8913
8913
|
}
|
|
8914
8914
|
|
|
8915
|
-
const logger$
|
|
8915
|
+
const logger$19 = getLogger('naylence.fame.node.root_session_manager');
|
|
8916
8916
|
function resolveOption$1(options, primary, ...aliases) {
|
|
8917
8917
|
const record = options;
|
|
8918
8918
|
const primaryKey = primary;
|
|
@@ -8993,7 +8993,7 @@ class RootSessionManager extends TaskSpawner {
|
|
|
8993
8993
|
this.onAdmissionFailed =
|
|
8994
8994
|
typeof onAdmissionFailed === 'function' ? onAdmissionFailed : undefined;
|
|
8995
8995
|
this.enableContinuousRefresh = enableContinuousRefresh ?? true;
|
|
8996
|
-
logger$
|
|
8996
|
+
logger$19.debug('created_root_session_manager');
|
|
8997
8997
|
}
|
|
8998
8998
|
get isReady() {
|
|
8999
8999
|
return this.readyEvent.isSet();
|
|
@@ -9018,7 +9018,7 @@ class RootSessionManager extends TaskSpawner {
|
|
|
9018
9018
|
if (this.admissionTask) {
|
|
9019
9019
|
return;
|
|
9020
9020
|
}
|
|
9021
|
-
logger$
|
|
9021
|
+
logger$19.debug('root_session_manager_starting');
|
|
9022
9022
|
this.stopEvent.clear();
|
|
9023
9023
|
this.readyEvent.clear();
|
|
9024
9024
|
const taskName = `root-admission-${this.admissionEpoch}`;
|
|
@@ -9038,10 +9038,10 @@ class RootSessionManager extends TaskSpawner {
|
|
|
9038
9038
|
await this.admissionTask.promise;
|
|
9039
9039
|
throw new FameConnectError('Root session manager failed to become ready');
|
|
9040
9040
|
}
|
|
9041
|
-
logger$
|
|
9041
|
+
logger$19.debug('root_session_manager_started');
|
|
9042
9042
|
}
|
|
9043
9043
|
async stop() {
|
|
9044
|
-
logger$
|
|
9044
|
+
logger$19.debug('root_session_manager_stopping');
|
|
9045
9045
|
this.stopEvent.set();
|
|
9046
9046
|
if (this.admissionTask) {
|
|
9047
9047
|
this.admissionTask.cancel();
|
|
@@ -9053,7 +9053,7 @@ class RootSessionManager extends TaskSpawner {
|
|
|
9053
9053
|
await this.consumeTask(this.expiryGuardTask);
|
|
9054
9054
|
this.expiryGuardTask = null;
|
|
9055
9055
|
}
|
|
9056
|
-
logger$
|
|
9056
|
+
logger$19.debug('root_session_manager_stopped');
|
|
9057
9057
|
}
|
|
9058
9058
|
async awaitReady(timeoutMs) {
|
|
9059
9059
|
if (this.isReady) {
|
|
@@ -9094,12 +9094,12 @@ class RootSessionManager extends TaskSpawner {
|
|
|
9094
9094
|
await this.onEpochChange(epoch);
|
|
9095
9095
|
}
|
|
9096
9096
|
else {
|
|
9097
|
-
logger$
|
|
9097
|
+
logger$19.debug('epoch_change_ignored_no_handler', { epoch });
|
|
9098
9098
|
}
|
|
9099
9099
|
}
|
|
9100
9100
|
static createForRootSentinel(node, admissionClient, requestedLogicals = [], enableContinuousRefresh = true, onEpochChange) {
|
|
9101
9101
|
const handleWelcome = async (frame) => {
|
|
9102
|
-
logger$
|
|
9102
|
+
logger$19.info('root_admission_successful', {
|
|
9103
9103
|
system_id: frame.systemId,
|
|
9104
9104
|
assigned_path: frame.assignedPath ?? null,
|
|
9105
9105
|
accepted_logicals: frame.acceptedLogicals ?? [],
|
|
@@ -9110,12 +9110,12 @@ class RootSessionManager extends TaskSpawner {
|
|
|
9110
9110
|
? grant.purpose
|
|
9111
9111
|
: undefined;
|
|
9112
9112
|
if (purpose) {
|
|
9113
|
-
logger$
|
|
9113
|
+
logger$19.debug('received_admission_grant', { purpose });
|
|
9114
9114
|
}
|
|
9115
9115
|
}
|
|
9116
9116
|
};
|
|
9117
9117
|
const handleFailure = async (error) => {
|
|
9118
|
-
logger$
|
|
9118
|
+
logger$19.error('root_admission_failed_permanently', {
|
|
9119
9119
|
error: error.message,
|
|
9120
9120
|
});
|
|
9121
9121
|
};
|
|
@@ -9144,10 +9144,10 @@ class RootSessionManager extends TaskSpawner {
|
|
|
9144
9144
|
this.readyEvent.set();
|
|
9145
9145
|
}
|
|
9146
9146
|
if (this.hadSuccessfulAdmission) {
|
|
9147
|
-
logger$
|
|
9147
|
+
logger$19.debug('root_admission_refreshed');
|
|
9148
9148
|
}
|
|
9149
9149
|
else {
|
|
9150
|
-
logger$
|
|
9150
|
+
logger$19.debug('root_admission_completed');
|
|
9151
9151
|
}
|
|
9152
9152
|
this.hadSuccessfulAdmission = true;
|
|
9153
9153
|
delay = RootSessionManager.BACKOFF_INITIAL;
|
|
@@ -9156,7 +9156,7 @@ class RootSessionManager extends TaskSpawner {
|
|
|
9156
9156
|
await this.startExpiryGuard(welcomeFrame);
|
|
9157
9157
|
const expiryTriggered = await this.waitForExpiryOrStop();
|
|
9158
9158
|
if (expiryTriggered && !this.stopEvent.isSet()) {
|
|
9159
|
-
logger$
|
|
9159
|
+
logger$19.debug('performing_scheduled_re_admission');
|
|
9160
9160
|
continue;
|
|
9161
9161
|
}
|
|
9162
9162
|
}
|
|
@@ -9168,7 +9168,7 @@ class RootSessionManager extends TaskSpawner {
|
|
|
9168
9168
|
}
|
|
9169
9169
|
const errorObject = error instanceof Error ? error : new Error(String(error));
|
|
9170
9170
|
const willRetry = attempts < RootSessionManager.RETRY_MAX_ATTEMPTS;
|
|
9171
|
-
logger$
|
|
9171
|
+
logger$19.warning('root_admission_failed', {
|
|
9172
9172
|
error: errorObject.message,
|
|
9173
9173
|
attempt: attempts,
|
|
9174
9174
|
will_retry: willRetry,
|
|
@@ -9186,7 +9186,7 @@ class RootSessionManager extends TaskSpawner {
|
|
|
9186
9186
|
}
|
|
9187
9187
|
}
|
|
9188
9188
|
if (attempts >= RootSessionManager.RETRY_MAX_ATTEMPTS) {
|
|
9189
|
-
logger$
|
|
9189
|
+
logger$19.error('root_admission_max_attempts_exceeded', {
|
|
9190
9190
|
max_attempts: RootSessionManager.RETRY_MAX_ATTEMPTS,
|
|
9191
9191
|
});
|
|
9192
9192
|
}
|
|
@@ -9263,7 +9263,7 @@ class RootSessionManager extends TaskSpawner {
|
|
|
9263
9263
|
}
|
|
9264
9264
|
async expiryGuard(welcomeFrame, signal) {
|
|
9265
9265
|
if (!welcomeFrame.expiresAt) {
|
|
9266
|
-
logger$
|
|
9266
|
+
logger$19.debug('no_admission_expiry_configured');
|
|
9267
9267
|
await Promise.race([this.stopEvent.wait(), this.waitForAbort(signal)]);
|
|
9268
9268
|
return;
|
|
9269
9269
|
}
|
|
@@ -9272,7 +9272,7 @@ class RootSessionManager extends TaskSpawner {
|
|
|
9272
9272
|
let delaySeconds = (expiresAt.getTime() - now.getTime()) / 1000 -
|
|
9273
9273
|
RootSessionManager.JWT_REFRESH_SAFETY;
|
|
9274
9274
|
delaySeconds = Math.max(delaySeconds, 0);
|
|
9275
|
-
logger$
|
|
9275
|
+
logger$19.debug('admission_expiry_guard_started', {
|
|
9276
9276
|
welcome_expires_at: expiresAt.toISOString(),
|
|
9277
9277
|
delay_seconds: delaySeconds,
|
|
9278
9278
|
refresh_safety_seconds: RootSessionManager.JWT_REFRESH_SAFETY,
|
|
@@ -9281,7 +9281,7 @@ class RootSessionManager extends TaskSpawner {
|
|
|
9281
9281
|
if (this.stopEvent.isSet() || signal?.aborted) {
|
|
9282
9282
|
return;
|
|
9283
9283
|
}
|
|
9284
|
-
logger$
|
|
9284
|
+
logger$19.debug('admission_expiry_triggered_refresh', {
|
|
9285
9285
|
expires_at: expiresAt.toISOString(),
|
|
9286
9286
|
current_time: new Date().toISOString(),
|
|
9287
9287
|
seconds_before_expiry: RootSessionManager.JWT_REFRESH_SAFETY,
|
|
@@ -9296,7 +9296,7 @@ class RootSessionManager extends TaskSpawner {
|
|
|
9296
9296
|
return;
|
|
9297
9297
|
}
|
|
9298
9298
|
const errorObject = error instanceof Error ? error : new Error(String(error));
|
|
9299
|
-
logger$
|
|
9299
|
+
logger$19.debug('background_task_error', {
|
|
9300
9300
|
task_name: task.name,
|
|
9301
9301
|
error: errorObject.message,
|
|
9302
9302
|
});
|
|
@@ -9337,7 +9337,7 @@ RootSessionManager.JWT_REFRESH_SAFETY = 60.0;
|
|
|
9337
9337
|
* Concrete implementations must define supported grant types and provide grant-to-connector
|
|
9338
9338
|
* conversion logic.
|
|
9339
9339
|
*/
|
|
9340
|
-
const logger$
|
|
9340
|
+
const logger$18 = getLogger('naylence.fame.connector.connector_factory');
|
|
9341
9341
|
const CONNECTOR_FACTORY_BASE_TYPE = 'ConnectorFactory';
|
|
9342
9342
|
/**
|
|
9343
9343
|
* Abstract base class for connector factories
|
|
@@ -9373,7 +9373,7 @@ class ConnectorFactory {
|
|
|
9373
9373
|
}
|
|
9374
9374
|
}
|
|
9375
9375
|
catch (error) {
|
|
9376
|
-
logger$
|
|
9376
|
+
logger$18.warning(`Failed to evaluate grant with factory ${factoryInfo.constructor.name}: ${error}`);
|
|
9377
9377
|
continue;
|
|
9378
9378
|
}
|
|
9379
9379
|
}
|
|
@@ -9416,7 +9416,7 @@ class ConnectorFactory {
|
|
|
9416
9416
|
}
|
|
9417
9417
|
}
|
|
9418
9418
|
catch (error) {
|
|
9419
|
-
logger$
|
|
9419
|
+
logger$18.warning(`Failed to create connector config from grant: ${error}`);
|
|
9420
9420
|
continue;
|
|
9421
9421
|
}
|
|
9422
9422
|
}
|
|
@@ -9483,20 +9483,20 @@ class ConnectorFactory {
|
|
|
9483
9483
|
return existing;
|
|
9484
9484
|
}
|
|
9485
9485
|
if (existing && !this.isGrantAware(existing)) {
|
|
9486
|
-
logger$
|
|
9486
|
+
logger$18.warning(`Factory ${factoryInfo.constructor.name} is registered under ${CONNECTOR_FACTORY_BASE_TYPE} but is missing grant conversion APIs; skipping.`);
|
|
9487
9487
|
return null;
|
|
9488
9488
|
}
|
|
9489
9489
|
try {
|
|
9490
9490
|
const instance = new factoryInfo.constructor();
|
|
9491
9491
|
if (!this.isGrantAware(instance)) {
|
|
9492
|
-
logger$
|
|
9492
|
+
logger$18.warning(`Factory ${factoryInfo.constructor.name} does not implement grant conversion APIs required by ${CONNECTOR_FACTORY_BASE_TYPE}; skipping.`);
|
|
9493
9493
|
return null;
|
|
9494
9494
|
}
|
|
9495
9495
|
factoryInfo.instance = instance;
|
|
9496
9496
|
return instance;
|
|
9497
9497
|
}
|
|
9498
9498
|
catch (error) {
|
|
9499
|
-
logger$
|
|
9499
|
+
logger$18.warning(`Failed to instantiate factory ${factoryInfo.constructor.name} while resolving grant conversion APIs: ${error}`);
|
|
9500
9500
|
return null;
|
|
9501
9501
|
}
|
|
9502
9502
|
}
|
|
@@ -9599,7 +9599,7 @@ class TaskCancellationError extends Error {
|
|
|
9599
9599
|
this.name = 'TaskCancellationError';
|
|
9600
9600
|
}
|
|
9601
9601
|
}
|
|
9602
|
-
const logger$
|
|
9602
|
+
const logger$17 = getLogger('naylence.fame.connector.base_async_connector');
|
|
9603
9603
|
// Environment variables
|
|
9604
9604
|
const ENV_VAR_FAME_FLOW_CONTROL = 'FAME_FLOW_CONTROL';
|
|
9605
9605
|
const FLOW_CONTROL_ENABLED = typeof process !== 'undefined' && process?.env
|
|
@@ -9682,7 +9682,7 @@ class BaseAsyncConnector extends TaskSpawner {
|
|
|
9682
9682
|
if (this._state !== newState) {
|
|
9683
9683
|
const oldState = this._state;
|
|
9684
9684
|
this._state = newState;
|
|
9685
|
-
logger$
|
|
9685
|
+
logger$17.debug('connector_state_transition', {
|
|
9686
9686
|
connector_id: this._connectorFlowId,
|
|
9687
9687
|
old_state: oldState,
|
|
9688
9688
|
new_state: newState,
|
|
@@ -9721,12 +9721,12 @@ class BaseAsyncConnector extends TaskSpawner {
|
|
|
9721
9721
|
* Stop the connector gracefully
|
|
9722
9722
|
*/
|
|
9723
9723
|
async stop() {
|
|
9724
|
-
logger$
|
|
9724
|
+
logger$17.debug('stopping_connector', {
|
|
9725
9725
|
current_state: this._state,
|
|
9726
9726
|
connector_id: this._connectorFlowId,
|
|
9727
9727
|
});
|
|
9728
9728
|
if (!core.ConnectorStateUtils.canStop(this._state)) {
|
|
9729
|
-
logger$
|
|
9729
|
+
logger$17.debug('connector_stop_already_stopped', {
|
|
9730
9730
|
current_state: this._state,
|
|
9731
9731
|
connector_id: this._connectorFlowId,
|
|
9732
9732
|
});
|
|
@@ -9737,7 +9737,7 @@ class BaseAsyncConnector extends TaskSpawner {
|
|
|
9737
9737
|
if (this._lastError) {
|
|
9738
9738
|
throw this._lastError;
|
|
9739
9739
|
}
|
|
9740
|
-
logger$
|
|
9740
|
+
logger$17.debug('connector_stopped', {
|
|
9741
9741
|
current_state: this._state,
|
|
9742
9742
|
connector_id: this._connectorFlowId,
|
|
9743
9743
|
});
|
|
@@ -9746,19 +9746,19 @@ class BaseAsyncConnector extends TaskSpawner {
|
|
|
9746
9746
|
* Pause the connector (suspends heartbeat and housekeeping, but keeps connection alive)
|
|
9747
9747
|
*/
|
|
9748
9748
|
async pause() {
|
|
9749
|
-
logger$
|
|
9749
|
+
logger$17.debug('pausing_connector', {
|
|
9750
9750
|
current_state: this._state,
|
|
9751
9751
|
connector_id: this._connectorFlowId,
|
|
9752
9752
|
});
|
|
9753
9753
|
if (this._state !== core.ConnectorState.STARTED) {
|
|
9754
|
-
logger$
|
|
9754
|
+
logger$17.debug('connector_pause_invalid_state', {
|
|
9755
9755
|
current_state: this._state,
|
|
9756
9756
|
connector_id: this._connectorFlowId,
|
|
9757
9757
|
});
|
|
9758
9758
|
return;
|
|
9759
9759
|
}
|
|
9760
9760
|
this._setState(core.ConnectorState.PAUSED);
|
|
9761
|
-
logger$
|
|
9761
|
+
logger$17.debug('connector_paused', {
|
|
9762
9762
|
current_state: this._state,
|
|
9763
9763
|
connector_id: this._connectorFlowId,
|
|
9764
9764
|
});
|
|
@@ -9767,19 +9767,19 @@ class BaseAsyncConnector extends TaskSpawner {
|
|
|
9767
9767
|
* Resume the connector from paused state
|
|
9768
9768
|
*/
|
|
9769
9769
|
async resume() {
|
|
9770
|
-
logger$
|
|
9770
|
+
logger$17.debug('resuming_connector', {
|
|
9771
9771
|
current_state: this._state,
|
|
9772
9772
|
connector_id: this._connectorFlowId,
|
|
9773
9773
|
});
|
|
9774
9774
|
if (this._state !== core.ConnectorState.PAUSED) {
|
|
9775
|
-
logger$
|
|
9775
|
+
logger$17.debug('connector_resume_invalid_state', {
|
|
9776
9776
|
current_state: this._state,
|
|
9777
9777
|
connector_id: this._connectorFlowId,
|
|
9778
9778
|
});
|
|
9779
9779
|
return;
|
|
9780
9780
|
}
|
|
9781
9781
|
this._setState(core.ConnectorState.STARTED);
|
|
9782
|
-
logger$
|
|
9782
|
+
logger$17.debug('connector_resumed', {
|
|
9783
9783
|
current_state: this._state,
|
|
9784
9784
|
connector_id: this._connectorFlowId,
|
|
9785
9785
|
});
|
|
@@ -9789,7 +9789,7 @@ class BaseAsyncConnector extends TaskSpawner {
|
|
|
9789
9789
|
*/
|
|
9790
9790
|
async close(code = 1000, reason = 'normal closure') {
|
|
9791
9791
|
if (!core.ConnectorStateUtils.canClose(this._state)) {
|
|
9792
|
-
logger$
|
|
9792
|
+
logger$17.warning('connector_close_invalid_state', {
|
|
9793
9793
|
current_state: this._state,
|
|
9794
9794
|
connector_id: this._connectorFlowId,
|
|
9795
9795
|
});
|
|
@@ -9870,7 +9870,7 @@ class BaseAsyncConnector extends TaskSpawner {
|
|
|
9870
9870
|
// Add to queue and notify send loop
|
|
9871
9871
|
this._sendQueue.push(raw);
|
|
9872
9872
|
// Log for debugging
|
|
9873
|
-
logger$
|
|
9873
|
+
logger$17.debug('send_envelope_queued', {
|
|
9874
9874
|
queue_length: this._sendQueue.length,
|
|
9875
9875
|
max_queue_size: this._maxQueueSize,
|
|
9876
9876
|
});
|
|
@@ -9919,14 +9919,14 @@ class BaseAsyncConnector extends TaskSpawner {
|
|
|
9919
9919
|
const item = this._sendQueue[0];
|
|
9920
9920
|
if (!item)
|
|
9921
9921
|
continue;
|
|
9922
|
-
logger$
|
|
9922
|
+
logger$17.debug('send_loop_processing_item', {
|
|
9923
9923
|
queue_length_before_send: this._sendQueue.length,
|
|
9924
9924
|
});
|
|
9925
9925
|
// Send through transport (this may block)
|
|
9926
9926
|
await this._transportSendBytes(item);
|
|
9927
9927
|
// Only remove from queue after successful send
|
|
9928
9928
|
this._sendQueue.shift();
|
|
9929
|
-
logger$
|
|
9929
|
+
logger$17.debug('send_loop_item_sent', {
|
|
9930
9930
|
queue_length_after_send: this._sendQueue.length,
|
|
9931
9931
|
});
|
|
9932
9932
|
}
|
|
@@ -9939,14 +9939,14 @@ class BaseAsyncConnector extends TaskSpawner {
|
|
|
9939
9939
|
}
|
|
9940
9940
|
else if (error instanceof TaskCancellationError) {
|
|
9941
9941
|
// Task cancellation is expected during shutdown - log as debug, not critical
|
|
9942
|
-
logger$
|
|
9942
|
+
logger$17.debug('send loop cancelled', {
|
|
9943
9943
|
connector: this.constructor.name,
|
|
9944
9944
|
reason: error.message,
|
|
9945
9945
|
});
|
|
9946
9946
|
// Don't re-throw - this is normal during shutdown
|
|
9947
9947
|
}
|
|
9948
9948
|
else {
|
|
9949
|
-
logger$
|
|
9949
|
+
logger$17.critical('unexpected exception in send loop', {
|
|
9950
9950
|
connector: this.constructor.name,
|
|
9951
9951
|
error: error instanceof Error ? error.message : String(error),
|
|
9952
9952
|
});
|
|
@@ -9987,7 +9987,7 @@ class BaseAsyncConnector extends TaskSpawner {
|
|
|
9987
9987
|
env = JSON.parse(jsonStr);
|
|
9988
9988
|
}
|
|
9989
9989
|
catch (error) {
|
|
9990
|
-
logger$
|
|
9990
|
+
logger$17.error('Invalid envelope', {
|
|
9991
9991
|
message: message.toString(),
|
|
9992
9992
|
error: error instanceof Error ? error.message : String(error),
|
|
9993
9993
|
});
|
|
@@ -10011,7 +10011,7 @@ class BaseAsyncConnector extends TaskSpawner {
|
|
|
10011
10011
|
};
|
|
10012
10012
|
await withEnvelopeContextAsync(envelopeContext, async () => {
|
|
10013
10013
|
const prettyEnvelope = prettyModel$1(env);
|
|
10014
|
-
logger$
|
|
10014
|
+
logger$17.trace('connector_received_envelope', {
|
|
10015
10015
|
envelope: env,
|
|
10016
10016
|
pretty: prettyEnvelope,
|
|
10017
10017
|
});
|
|
@@ -10040,7 +10040,7 @@ class BaseAsyncConnector extends TaskSpawner {
|
|
|
10040
10040
|
if (error instanceof TaskCancellationError) {
|
|
10041
10041
|
throw error;
|
|
10042
10042
|
}
|
|
10043
|
-
logger$
|
|
10043
|
+
logger$17.error('handler_failed', {
|
|
10044
10044
|
error: error instanceof Error ? error.message : String(error),
|
|
10045
10045
|
envelope_id: env.id ?? null,
|
|
10046
10046
|
trace_id: env.traceId ?? null,
|
|
@@ -10061,14 +10061,14 @@ class BaseAsyncConnector extends TaskSpawner {
|
|
|
10061
10061
|
}
|
|
10062
10062
|
else if (error instanceof TaskCancellationError) {
|
|
10063
10063
|
// Task cancellation is expected during shutdown - log as debug, not critical
|
|
10064
|
-
logger$
|
|
10064
|
+
logger$17.debug('receive loop cancelled', {
|
|
10065
10065
|
connector: this.constructor.name,
|
|
10066
10066
|
reason: error.message,
|
|
10067
10067
|
});
|
|
10068
10068
|
// Don't re-throw - this is normal during shutdown
|
|
10069
10069
|
}
|
|
10070
10070
|
else {
|
|
10071
|
-
logger$
|
|
10071
|
+
logger$17.critical('unexpected_error_in recv_loop', {
|
|
10072
10072
|
error: error instanceof Error ? error.message : String(error),
|
|
10073
10073
|
});
|
|
10074
10074
|
throw error;
|
|
@@ -10084,7 +10084,7 @@ class BaseAsyncConnector extends TaskSpawner {
|
|
|
10084
10084
|
async _maybeEmitCredit(flowId, traceId) {
|
|
10085
10085
|
const remainingCredits = this._flowCtrl.getCredits(flowId);
|
|
10086
10086
|
const needsRefill = this._flowCtrl.needsRefill(flowId);
|
|
10087
|
-
logger$
|
|
10087
|
+
logger$17.debug('maybe_emit_credit_check', {
|
|
10088
10088
|
connector_id: this._connectorFlowId,
|
|
10089
10089
|
flow_id: flowId,
|
|
10090
10090
|
trace_id: traceId ?? null,
|
|
@@ -10100,7 +10100,7 @@ class BaseAsyncConnector extends TaskSpawner {
|
|
|
10100
10100
|
}
|
|
10101
10101
|
const delta = this._initialWindow;
|
|
10102
10102
|
this._flowCtrl.addCredits(flowId, delta);
|
|
10103
|
-
logger$
|
|
10103
|
+
logger$17.debug('maybe_emit_credit_emit', {
|
|
10104
10104
|
connector_id: this._connectorFlowId,
|
|
10105
10105
|
flow_id: flowId,
|
|
10106
10106
|
trace_id: traceId ?? null,
|
|
@@ -10120,7 +10120,7 @@ class BaseAsyncConnector extends TaskSpawner {
|
|
|
10120
10120
|
});
|
|
10121
10121
|
try {
|
|
10122
10122
|
await this.send(ackEnv);
|
|
10123
|
-
logger$
|
|
10123
|
+
logger$17.debug('maybe_emit_credit_sent', {
|
|
10124
10124
|
connector_id: this._connectorFlowId,
|
|
10125
10125
|
flow_id: flowId,
|
|
10126
10126
|
trace_id: traceId ?? null,
|
|
@@ -10128,7 +10128,7 @@ class BaseAsyncConnector extends TaskSpawner {
|
|
|
10128
10128
|
});
|
|
10129
10129
|
}
|
|
10130
10130
|
catch (error) {
|
|
10131
|
-
logger$
|
|
10131
|
+
logger$17.error('maybe_emit_credit_send_failed', {
|
|
10132
10132
|
connector_id: this._connectorFlowId,
|
|
10133
10133
|
flow_id: flowId,
|
|
10134
10134
|
trace_id: traceId ?? null,
|
|
@@ -10153,13 +10153,13 @@ class BaseAsyncConnector extends TaskSpawner {
|
|
|
10153
10153
|
*/
|
|
10154
10154
|
async _shutdown(code, reason, gracePeriod, exc) {
|
|
10155
10155
|
if (this._closed) {
|
|
10156
|
-
logger$
|
|
10156
|
+
logger$17.debug('shutdown_already_closed', {
|
|
10157
10157
|
connector_id: this._connectorFlowId,
|
|
10158
10158
|
current_state: this._state,
|
|
10159
10159
|
});
|
|
10160
10160
|
return;
|
|
10161
10161
|
}
|
|
10162
|
-
logger$
|
|
10162
|
+
logger$17.debug('connector_shutdown_starting', {
|
|
10163
10163
|
connector_id: this._connectorFlowId,
|
|
10164
10164
|
connector_type: this.constructor.name,
|
|
10165
10165
|
code,
|
|
@@ -10189,19 +10189,19 @@ class BaseAsyncConnector extends TaskSpawner {
|
|
|
10189
10189
|
this._sendPromiseResolve = undefined;
|
|
10190
10190
|
}
|
|
10191
10191
|
// Close transport
|
|
10192
|
-
logger$
|
|
10192
|
+
logger$17.debug('connector_closing_transport', {
|
|
10193
10193
|
connector_id: this._connectorFlowId,
|
|
10194
10194
|
connector_type: this.constructor.name,
|
|
10195
10195
|
timestamp: new Date().toISOString(),
|
|
10196
10196
|
});
|
|
10197
10197
|
await this._transportClose(code, reason);
|
|
10198
|
-
logger$
|
|
10198
|
+
logger$17.debug('connector_transport_closed', {
|
|
10199
10199
|
connector_id: this._connectorFlowId,
|
|
10200
10200
|
connector_type: this.constructor.name,
|
|
10201
10201
|
timestamp: new Date().toISOString(),
|
|
10202
10202
|
});
|
|
10203
10203
|
// Shutdown spawned tasks
|
|
10204
|
-
logger$
|
|
10204
|
+
logger$17.debug('connector_shutting_down_tasks', {
|
|
10205
10205
|
connector_id: this._connectorFlowId,
|
|
10206
10206
|
connector_type: this.constructor.name,
|
|
10207
10207
|
grace_period_ms: effectiveGracePeriod * 1000,
|
|
@@ -10213,14 +10213,14 @@ class BaseAsyncConnector extends TaskSpawner {
|
|
|
10213
10213
|
gracePeriod: effectiveGracePeriod * 1000, // Convert to milliseconds
|
|
10214
10214
|
joinTimeout: this._shutdownJoinTimeout,
|
|
10215
10215
|
});
|
|
10216
|
-
logger$
|
|
10216
|
+
logger$17.debug('connector_tasks_shutdown_complete', {
|
|
10217
10217
|
connector_id: this._connectorFlowId,
|
|
10218
10218
|
connector_type: this.constructor.name,
|
|
10219
10219
|
timestamp: new Date().toISOString(),
|
|
10220
10220
|
});
|
|
10221
10221
|
}
|
|
10222
10222
|
catch (error) {
|
|
10223
|
-
logger$
|
|
10223
|
+
logger$17.warning('task_shutdown_error', {
|
|
10224
10224
|
connector_id: this._connectorFlowId,
|
|
10225
10225
|
error: error instanceof Error ? error.message : String(error),
|
|
10226
10226
|
});
|
|
@@ -10233,7 +10233,7 @@ class BaseAsyncConnector extends TaskSpawner {
|
|
|
10233
10233
|
if (this._closeResolver) {
|
|
10234
10234
|
this._closeResolver();
|
|
10235
10235
|
}
|
|
10236
|
-
logger$
|
|
10236
|
+
logger$17.debug('connector_shutdown_complete', {
|
|
10237
10237
|
connector_id: this._connectorFlowId,
|
|
10238
10238
|
connector_type: this.constructor.name,
|
|
10239
10239
|
final_state: this._state,
|
|
@@ -10309,7 +10309,7 @@ class BoundedAsyncQueue {
|
|
|
10309
10309
|
}
|
|
10310
10310
|
}
|
|
10311
10311
|
|
|
10312
|
-
const logger$
|
|
10312
|
+
const logger$16 = getLogger('naylence.fame.connector.broadcast_channel_connector');
|
|
10313
10313
|
const BROADCAST_CHANNEL_CONNECTOR_TYPE = 'broadcast-channel-connector';
|
|
10314
10314
|
const DEFAULT_CHANNEL$7 = 'naylence-fabric';
|
|
10315
10315
|
const DEFAULT_INBOX_CAPACITY$7 = 2048;
|
|
@@ -10398,7 +10398,7 @@ let BroadcastChannelConnector$2 = class BroadcastChannelConnector extends BaseAs
|
|
|
10398
10398
|
this.localNodeId = normalizedLocalNodeId;
|
|
10399
10399
|
this.targetNodeId = BroadcastChannelConnector.normalizeTargetNodeId(config.initialTargetNodeId);
|
|
10400
10400
|
this.channel = new BroadcastChannel(this.channelName);
|
|
10401
|
-
logger$
|
|
10401
|
+
logger$16.debug('broadcast_channel_connector_created', {
|
|
10402
10402
|
channel: this.channelName,
|
|
10403
10403
|
connector_id: this.connectorId,
|
|
10404
10404
|
local_node_id: this.localNodeId,
|
|
@@ -10410,7 +10410,7 @@ let BroadcastChannelConnector$2 = class BroadcastChannelConnector extends BaseAs
|
|
|
10410
10410
|
this.onMsg = (event) => {
|
|
10411
10411
|
// Guard: Don't process if listener was unregistered
|
|
10412
10412
|
if (!this.listenerRegistered) {
|
|
10413
|
-
logger$
|
|
10413
|
+
logger$16.warning('broadcast_channel_message_after_unregister', {
|
|
10414
10414
|
channel: this.channelName,
|
|
10415
10415
|
connector_id: this.connectorId,
|
|
10416
10416
|
timestamp: new Date().toISOString(),
|
|
@@ -10418,7 +10418,7 @@ let BroadcastChannelConnector$2 = class BroadcastChannelConnector extends BaseAs
|
|
|
10418
10418
|
return;
|
|
10419
10419
|
}
|
|
10420
10420
|
const message = event.data;
|
|
10421
|
-
logger$
|
|
10421
|
+
logger$16.debug('broadcast_channel_raw_event', {
|
|
10422
10422
|
channel: this.channelName,
|
|
10423
10423
|
connector_id: this.connectorId,
|
|
10424
10424
|
message_type: message && typeof message === 'object'
|
|
@@ -10434,7 +10434,7 @@ let BroadcastChannelConnector$2 = class BroadcastChannelConnector extends BaseAs
|
|
|
10434
10434
|
const busMessage = message;
|
|
10435
10435
|
const senderNodeId = BroadcastChannelConnector.normalizeNodeId(busMessage.senderNodeId);
|
|
10436
10436
|
if (!senderNodeId) {
|
|
10437
|
-
logger$
|
|
10437
|
+
logger$16.debug('broadcast_channel_message_rejected', {
|
|
10438
10438
|
channel: this.channelName,
|
|
10439
10439
|
connector_id: this.connectorId,
|
|
10440
10440
|
reason: 'missing_sender_node_id',
|
|
@@ -10442,7 +10442,7 @@ let BroadcastChannelConnector$2 = class BroadcastChannelConnector extends BaseAs
|
|
|
10442
10442
|
return;
|
|
10443
10443
|
}
|
|
10444
10444
|
if (senderNodeId === this.localNodeId) {
|
|
10445
|
-
logger$
|
|
10445
|
+
logger$16.debug('broadcast_channel_message_rejected', {
|
|
10446
10446
|
channel: this.channelName,
|
|
10447
10447
|
connector_id: this.connectorId,
|
|
10448
10448
|
reason: 'self_echo',
|
|
@@ -10456,14 +10456,14 @@ let BroadcastChannelConnector$2 = class BroadcastChannelConnector extends BaseAs
|
|
|
10456
10456
|
}
|
|
10457
10457
|
const payload = BroadcastChannelConnector.coercePayload(busMessage.payload);
|
|
10458
10458
|
if (!payload) {
|
|
10459
|
-
logger$
|
|
10459
|
+
logger$16.debug('broadcast_channel_payload_rejected', {
|
|
10460
10460
|
channel: this.channelName,
|
|
10461
10461
|
connector_id: this.connectorId,
|
|
10462
10462
|
reason: 'unrecognized_payload_type',
|
|
10463
10463
|
});
|
|
10464
10464
|
return;
|
|
10465
10465
|
}
|
|
10466
|
-
logger$
|
|
10466
|
+
logger$16.debug('broadcast_channel_message_received', {
|
|
10467
10467
|
channel: this.channelName,
|
|
10468
10468
|
sender_id: message?.senderId,
|
|
10469
10469
|
sender_node_id: senderNodeId,
|
|
@@ -10492,14 +10492,14 @@ let BroadcastChannelConnector$2 = class BroadcastChannelConnector extends BaseAs
|
|
|
10492
10492
|
}
|
|
10493
10493
|
catch (error) {
|
|
10494
10494
|
if (error instanceof QueueFullError) {
|
|
10495
|
-
logger$
|
|
10495
|
+
logger$16.warning('broadcast_channel_receive_queue_full', {
|
|
10496
10496
|
channel: this.channelName,
|
|
10497
10497
|
inbox_capacity: this.inboxCapacity,
|
|
10498
10498
|
inbox_remaining_capacity: this.inbox.remainingCapacity,
|
|
10499
10499
|
});
|
|
10500
10500
|
}
|
|
10501
10501
|
else {
|
|
10502
|
-
logger$
|
|
10502
|
+
logger$16.error('broadcast_channel_receive_error', {
|
|
10503
10503
|
channel: this.channelName,
|
|
10504
10504
|
error: error instanceof Error ? error.message : String(error),
|
|
10505
10505
|
});
|
|
@@ -10513,7 +10513,7 @@ let BroadcastChannelConnector$2 = class BroadcastChannelConnector extends BaseAs
|
|
|
10513
10513
|
// Setup visibility change monitoring
|
|
10514
10514
|
this.visibilityChangeHandler = () => {
|
|
10515
10515
|
const isHidden = document.hidden;
|
|
10516
|
-
logger$
|
|
10516
|
+
logger$16.debug('broadcast_channel_visibility_changed', {
|
|
10517
10517
|
channel: this.channelName,
|
|
10518
10518
|
connector_id: this.connectorId,
|
|
10519
10519
|
visibility: isHidden ? 'hidden' : 'visible',
|
|
@@ -10522,7 +10522,7 @@ let BroadcastChannelConnector$2 = class BroadcastChannelConnector extends BaseAs
|
|
|
10522
10522
|
// Pause/resume connector based on visibility
|
|
10523
10523
|
if (isHidden && this.state === core.ConnectorState.STARTED) {
|
|
10524
10524
|
this.pause().catch((err) => {
|
|
10525
|
-
logger$
|
|
10525
|
+
logger$16.warning('broadcast_channel_pause_failed', {
|
|
10526
10526
|
channel: this.channelName,
|
|
10527
10527
|
connector_id: this.connectorId,
|
|
10528
10528
|
error: err instanceof Error ? err.message : String(err),
|
|
@@ -10531,7 +10531,7 @@ let BroadcastChannelConnector$2 = class BroadcastChannelConnector extends BaseAs
|
|
|
10531
10531
|
}
|
|
10532
10532
|
else if (!isHidden && this.state === core.ConnectorState.PAUSED) {
|
|
10533
10533
|
this.resume().catch((err) => {
|
|
10534
|
-
logger$
|
|
10534
|
+
logger$16.warning('broadcast_channel_resume_failed', {
|
|
10535
10535
|
channel: this.channelName,
|
|
10536
10536
|
connector_id: this.connectorId,
|
|
10537
10537
|
error: err instanceof Error ? err.message : String(err),
|
|
@@ -10545,7 +10545,7 @@ let BroadcastChannelConnector$2 = class BroadcastChannelConnector extends BaseAs
|
|
|
10545
10545
|
// Track page lifecycle events to detect browser unload/discard
|
|
10546
10546
|
if (typeof window !== 'undefined') {
|
|
10547
10547
|
const lifecycleLogger = (event) => {
|
|
10548
|
-
logger$
|
|
10548
|
+
logger$16.debug('broadcast_channel_page_lifecycle', {
|
|
10549
10549
|
channel: this.channelName,
|
|
10550
10550
|
connector_id: this.connectorId,
|
|
10551
10551
|
event_type: event.type,
|
|
@@ -10561,7 +10561,7 @@ let BroadcastChannelConnector$2 = class BroadcastChannelConnector extends BaseAs
|
|
|
10561
10561
|
document.addEventListener('resume', lifecycleLogger);
|
|
10562
10562
|
}
|
|
10563
10563
|
// Log initial state with detailed visibility info
|
|
10564
|
-
logger$
|
|
10564
|
+
logger$16.debug('broadcast_channel_initial_visibility', {
|
|
10565
10565
|
channel: this.channelName,
|
|
10566
10566
|
connector_id: this.connectorId,
|
|
10567
10567
|
visibility: document.hidden ? 'hidden' : 'visible',
|
|
@@ -10593,14 +10593,14 @@ let BroadcastChannelConnector$2 = class BroadcastChannelConnector extends BaseAs
|
|
|
10593
10593
|
}
|
|
10594
10594
|
catch (error) {
|
|
10595
10595
|
if (error instanceof QueueFullError) {
|
|
10596
|
-
logger$
|
|
10596
|
+
logger$16.warning('broadcast_channel_push_queue_full', {
|
|
10597
10597
|
channel: this.channelName,
|
|
10598
10598
|
inbox_capacity: this.inboxCapacity,
|
|
10599
10599
|
inbox_remaining_capacity: this.inbox.remainingCapacity,
|
|
10600
10600
|
});
|
|
10601
10601
|
throw error;
|
|
10602
10602
|
}
|
|
10603
|
-
logger$
|
|
10603
|
+
logger$16.error('broadcast_channel_push_failed', {
|
|
10604
10604
|
channel: this.channelName,
|
|
10605
10605
|
error: error instanceof Error ? error.message : String(error),
|
|
10606
10606
|
});
|
|
@@ -10610,7 +10610,7 @@ let BroadcastChannelConnector$2 = class BroadcastChannelConnector extends BaseAs
|
|
|
10610
10610
|
async _transportSendBytes(data) {
|
|
10611
10611
|
ensureBroadcastEnvironment();
|
|
10612
10612
|
const targetNodeId = this.targetNodeId ?? '*';
|
|
10613
|
-
logger$
|
|
10613
|
+
logger$16.debug('broadcast_channel_message_sending', {
|
|
10614
10614
|
channel: this.channelName,
|
|
10615
10615
|
sender_id: this.connectorId,
|
|
10616
10616
|
sender_node_id: this.localNodeId,
|
|
@@ -10631,7 +10631,7 @@ let BroadcastChannelConnector$2 = class BroadcastChannelConnector extends BaseAs
|
|
|
10631
10631
|
return item;
|
|
10632
10632
|
}
|
|
10633
10633
|
async _transportClose(code, reason) {
|
|
10634
|
-
logger$
|
|
10634
|
+
logger$16.debug('broadcast_channel_transport_closing', {
|
|
10635
10635
|
channel: this.channelName,
|
|
10636
10636
|
connector_id: this.connectorId,
|
|
10637
10637
|
code,
|
|
@@ -10640,14 +10640,14 @@ let BroadcastChannelConnector$2 = class BroadcastChannelConnector extends BaseAs
|
|
|
10640
10640
|
timestamp: new Date().toISOString(),
|
|
10641
10641
|
});
|
|
10642
10642
|
if (this.listenerRegistered) {
|
|
10643
|
-
logger$
|
|
10643
|
+
logger$16.debug('broadcast_channel_removing_listener', {
|
|
10644
10644
|
channel: this.channelName,
|
|
10645
10645
|
connector_id: this.connectorId,
|
|
10646
10646
|
timestamp: new Date().toISOString(),
|
|
10647
10647
|
});
|
|
10648
10648
|
this.channel.removeEventListener('message', this.onMsg);
|
|
10649
10649
|
this.listenerRegistered = false;
|
|
10650
|
-
logger$
|
|
10650
|
+
logger$16.debug('broadcast_channel_listener_removed', {
|
|
10651
10651
|
channel: this.channelName,
|
|
10652
10652
|
connector_id: this.connectorId,
|
|
10653
10653
|
timestamp: new Date().toISOString(),
|
|
@@ -10660,13 +10660,13 @@ let BroadcastChannelConnector$2 = class BroadcastChannelConnector extends BaseAs
|
|
|
10660
10660
|
this.visibilityChangeListenerRegistered = false;
|
|
10661
10661
|
this.visibilityChangeHandler = undefined;
|
|
10662
10662
|
}
|
|
10663
|
-
logger$
|
|
10663
|
+
logger$16.debug('broadcast_channel_closing', {
|
|
10664
10664
|
channel: this.channelName,
|
|
10665
10665
|
connector_id: this.connectorId,
|
|
10666
10666
|
timestamp: new Date().toISOString(),
|
|
10667
10667
|
});
|
|
10668
10668
|
this.channel.close();
|
|
10669
|
-
logger$
|
|
10669
|
+
logger$16.debug('broadcast_channel_closed', {
|
|
10670
10670
|
channel: this.channelName,
|
|
10671
10671
|
connector_id: this.connectorId,
|
|
10672
10672
|
timestamp: new Date().toISOString(),
|
|
@@ -10690,7 +10690,7 @@ let BroadcastChannelConnector$2 = class BroadcastChannelConnector extends BaseAs
|
|
|
10690
10690
|
if (targetNodeId &&
|
|
10691
10691
|
targetNodeId !== '*' &&
|
|
10692
10692
|
targetNodeId !== this.localNodeId) {
|
|
10693
|
-
logger$
|
|
10693
|
+
logger$16.debug('broadcast_channel_message_rejected', {
|
|
10694
10694
|
channel: this.channelName,
|
|
10695
10695
|
connector_id: this.connectorId,
|
|
10696
10696
|
reason: 'wildcard_target_mismatch',
|
|
@@ -10706,7 +10706,7 @@ let BroadcastChannelConnector$2 = class BroadcastChannelConnector extends BaseAs
|
|
|
10706
10706
|
if (expectedSender &&
|
|
10707
10707
|
expectedSender !== '*' &&
|
|
10708
10708
|
senderNodeId !== expectedSender) {
|
|
10709
|
-
logger$
|
|
10709
|
+
logger$16.debug('broadcast_channel_message_rejected', {
|
|
10710
10710
|
channel: this.channelName,
|
|
10711
10711
|
connector_id: this.connectorId,
|
|
10712
10712
|
reason: 'unexpected_sender',
|
|
@@ -10719,7 +10719,7 @@ let BroadcastChannelConnector$2 = class BroadcastChannelConnector extends BaseAs
|
|
|
10719
10719
|
if (targetNodeId &&
|
|
10720
10720
|
targetNodeId !== '*' &&
|
|
10721
10721
|
targetNodeId !== this.localNodeId) {
|
|
10722
|
-
logger$
|
|
10722
|
+
logger$16.debug('broadcast_channel_message_rejected', {
|
|
10723
10723
|
channel: this.channelName,
|
|
10724
10724
|
connector_id: this.connectorId,
|
|
10725
10725
|
reason: 'unexpected_target',
|
|
@@ -10744,7 +10744,7 @@ let BroadcastChannelConnector$2 = class BroadcastChannelConnector extends BaseAs
|
|
|
10744
10744
|
return 'unknown';
|
|
10745
10745
|
}
|
|
10746
10746
|
logInboxSnapshot(event, extra = {}) {
|
|
10747
|
-
logger$
|
|
10747
|
+
logger$16.debug(event, {
|
|
10748
10748
|
channel: this.channelName,
|
|
10749
10749
|
connector_id: this.connectorId,
|
|
10750
10750
|
connector_state: this.state,
|
|
@@ -10760,7 +10760,7 @@ let BroadcastChannelConnector$2 = class BroadcastChannelConnector extends BaseAs
|
|
|
10760
10760
|
await super.start(inboundHandler);
|
|
10761
10761
|
// After transitioning to STARTED, check if tab is already hidden
|
|
10762
10762
|
if (typeof document !== 'undefined' && document.hidden) {
|
|
10763
|
-
logger$
|
|
10763
|
+
logger$16.debug('broadcast_channel_start_in_hidden_tab', {
|
|
10764
10764
|
channel: this.channelName,
|
|
10765
10765
|
connector_id: this.connectorId,
|
|
10766
10766
|
document_hidden: document.hidden,
|
|
@@ -10770,7 +10770,7 @@ let BroadcastChannelConnector$2 = class BroadcastChannelConnector extends BaseAs
|
|
|
10770
10770
|
});
|
|
10771
10771
|
// Immediately pause if tab is hidden at start time
|
|
10772
10772
|
await this.pause().catch((err) => {
|
|
10773
|
-
logger$
|
|
10773
|
+
logger$16.warning('broadcast_channel_initial_pause_failed', {
|
|
10774
10774
|
channel: this.channelName,
|
|
10775
10775
|
connector_id: this.connectorId,
|
|
10776
10776
|
error: err instanceof Error ? err.message : String(err),
|
|
@@ -10788,7 +10788,7 @@ let BroadcastChannelConnector$2 = class BroadcastChannelConnector extends BaseAs
|
|
|
10788
10788
|
return;
|
|
10789
10789
|
}
|
|
10790
10790
|
this.targetNodeId = normalized;
|
|
10791
|
-
logger$
|
|
10791
|
+
logger$16.debug('broadcast_channel_target_updated', {
|
|
10792
10792
|
channel: this.channelName,
|
|
10793
10793
|
connector_id: this.connectorId,
|
|
10794
10794
|
local_node_id: this.localNodeId,
|
|
@@ -10798,7 +10798,7 @@ let BroadcastChannelConnector$2 = class BroadcastChannelConnector extends BaseAs
|
|
|
10798
10798
|
}
|
|
10799
10799
|
setWildcardTarget() {
|
|
10800
10800
|
this.targetNodeId = '*';
|
|
10801
|
-
logger$
|
|
10801
|
+
logger$16.debug('broadcast_channel_target_updated', {
|
|
10802
10802
|
channel: this.channelName,
|
|
10803
10803
|
connector_id: this.connectorId,
|
|
10804
10804
|
local_node_id: this.localNodeId,
|
|
@@ -10971,7 +10971,7 @@ function broadcastChannelGrantToConnectorConfig(grant) {
|
|
|
10971
10971
|
return config;
|
|
10972
10972
|
}
|
|
10973
10973
|
|
|
10974
|
-
const logger$
|
|
10974
|
+
const logger$15 = getLogger('naylence.fame.node.upstream_session_manager');
|
|
10975
10975
|
function isPlainRecord$4(value) {
|
|
10976
10976
|
if (typeof value !== 'object' || value === null) {
|
|
10977
10977
|
return false;
|
|
@@ -11092,7 +11092,7 @@ class UpstreamSessionManager extends TaskSpawner {
|
|
|
11092
11092
|
this.wrappedHandler = this.makeHeartbeatEnabledHandler(options.inboundHandler);
|
|
11093
11093
|
// Store the connection retry policy (can be null, in which case default behavior applies)
|
|
11094
11094
|
this.connectionRetryPolicy = options.retryPolicy ?? null;
|
|
11095
|
-
logger$
|
|
11095
|
+
logger$15.debug('created_upstream_session_manager', {
|
|
11096
11096
|
target_system_id: this.targetSystemId,
|
|
11097
11097
|
has_retry_policy: this.connectionRetryPolicy !== null,
|
|
11098
11098
|
});
|
|
@@ -11101,23 +11101,23 @@ class UpstreamSessionManager extends TaskSpawner {
|
|
|
11101
11101
|
return this.targetSystemId;
|
|
11102
11102
|
}
|
|
11103
11103
|
setupVisibilityListener() {
|
|
11104
|
-
logger$
|
|
11104
|
+
logger$15.debug('setup_visibility_listener_called', {
|
|
11105
11105
|
has_document: typeof document !== 'undefined',
|
|
11106
11106
|
});
|
|
11107
11107
|
if (typeof document !== 'undefined' && document.addEventListener) {
|
|
11108
11108
|
this._visibilityHandler = () => {
|
|
11109
|
-
logger$
|
|
11109
|
+
logger$15.debug('visibility_change_event_fired', {
|
|
11110
11110
|
state: document.visibilityState,
|
|
11111
11111
|
});
|
|
11112
11112
|
if (document.visibilityState === 'visible') {
|
|
11113
|
-
logger$
|
|
11113
|
+
logger$15.debug('visibility_change_detected_waking_up');
|
|
11114
11114
|
this.wakeEvent.set();
|
|
11115
11115
|
}
|
|
11116
11116
|
};
|
|
11117
11117
|
document.addEventListener('visibilitychange', this._visibilityHandler);
|
|
11118
11118
|
}
|
|
11119
11119
|
else {
|
|
11120
|
-
logger$
|
|
11120
|
+
logger$15.debug('setup_visibility_listener_skipped_no_document');
|
|
11121
11121
|
}
|
|
11122
11122
|
}
|
|
11123
11123
|
teardownVisibilityListener() {
|
|
@@ -11150,13 +11150,13 @@ class UpstreamSessionManager extends TaskSpawner {
|
|
|
11150
11150
|
}
|
|
11151
11151
|
throw new FameConnectError('Upstream session manager failed to attach');
|
|
11152
11152
|
}
|
|
11153
|
-
logger$
|
|
11153
|
+
logger$15.debug('upstream_session_manager_started');
|
|
11154
11154
|
}
|
|
11155
11155
|
getActiveConnector() {
|
|
11156
11156
|
return this.connector;
|
|
11157
11157
|
}
|
|
11158
11158
|
async stop() {
|
|
11159
|
-
logger$
|
|
11159
|
+
logger$15.debug('upstream_session_manager_stopping');
|
|
11160
11160
|
this.teardownVisibilityListener();
|
|
11161
11161
|
this.stopEvent.set();
|
|
11162
11162
|
this.currentStopSubtasks?.set();
|
|
@@ -11167,7 +11167,7 @@ class UpstreamSessionManager extends TaskSpawner {
|
|
|
11167
11167
|
}
|
|
11168
11168
|
catch (error) {
|
|
11169
11169
|
if (!(error instanceof TaskCancelledError)) {
|
|
11170
|
-
logger$
|
|
11170
|
+
logger$15.debug('fsm_task_stopped_with_error', {
|
|
11171
11171
|
error: error.message,
|
|
11172
11172
|
});
|
|
11173
11173
|
}
|
|
@@ -11176,13 +11176,13 @@ class UpstreamSessionManager extends TaskSpawner {
|
|
|
11176
11176
|
}
|
|
11177
11177
|
if (this.connector) {
|
|
11178
11178
|
await this.connector.stop().catch((error) => {
|
|
11179
|
-
logger$
|
|
11179
|
+
logger$15.debug('connector_stop_error', {
|
|
11180
11180
|
error: error.message,
|
|
11181
11181
|
});
|
|
11182
11182
|
});
|
|
11183
11183
|
this.connector = null;
|
|
11184
11184
|
}
|
|
11185
|
-
logger$
|
|
11185
|
+
logger$15.debug('upstream_session_manager_stopped');
|
|
11186
11186
|
}
|
|
11187
11187
|
async send(envelope) {
|
|
11188
11188
|
if (this.messageQueue.length >= UpstreamSessionManager.TX_QUEUE_MAX) {
|
|
@@ -11231,7 +11231,7 @@ class UpstreamSessionManager extends TaskSpawner {
|
|
|
11231
11231
|
const shouldFailFast = this.shouldFailFastOnError(error);
|
|
11232
11232
|
if (error instanceof FameTransportClose ||
|
|
11233
11233
|
error instanceof FameConnectError) {
|
|
11234
|
-
logger$
|
|
11234
|
+
logger$15.warning('upstream_link_closed', {
|
|
11235
11235
|
error: error.message,
|
|
11236
11236
|
will_retry: !shouldFailFast,
|
|
11237
11237
|
attempt: this.initialAttempts,
|
|
@@ -11244,13 +11244,13 @@ class UpstreamSessionManager extends TaskSpawner {
|
|
|
11244
11244
|
else {
|
|
11245
11245
|
const err = error;
|
|
11246
11246
|
if (err.name === 'OAuth2PkceRedirectInitiatedError') {
|
|
11247
|
-
logger$
|
|
11247
|
+
logger$15.info('upstream_link_redirecting', {
|
|
11248
11248
|
error: err.message,
|
|
11249
11249
|
will_retry: true,
|
|
11250
11250
|
});
|
|
11251
11251
|
}
|
|
11252
11252
|
else {
|
|
11253
|
-
logger$
|
|
11253
|
+
logger$15.warning('upstream_link_closed', {
|
|
11254
11254
|
error: err.message,
|
|
11255
11255
|
will_retry: !shouldFailFast,
|
|
11256
11256
|
attempt: this.initialAttempts,
|
|
@@ -11294,7 +11294,7 @@ class UpstreamSessionManager extends TaskSpawner {
|
|
|
11294
11294
|
// If sleep was interrupted by visibility change (user returned to tab),
|
|
11295
11295
|
// reset backoff to initial delay for immediate retry with fresh backoff
|
|
11296
11296
|
if (wasWoken) {
|
|
11297
|
-
logger$
|
|
11297
|
+
logger$15.debug('backoff_reset_on_visibility_change', {
|
|
11298
11298
|
previous_delay: delay,
|
|
11299
11299
|
new_delay: UpstreamSessionManager.BACKOFF_INITIAL,
|
|
11300
11300
|
});
|
|
@@ -11313,7 +11313,7 @@ class UpstreamSessionManager extends TaskSpawner {
|
|
|
11313
11313
|
// Check if wake event is already set (e.g., visibility just changed)
|
|
11314
11314
|
if (this.wakeEvent.isSet()) {
|
|
11315
11315
|
this.wakeEvent.clear();
|
|
11316
|
-
logger$
|
|
11316
|
+
logger$15.debug('sleep_skipped_wake_event_pending');
|
|
11317
11317
|
return true;
|
|
11318
11318
|
}
|
|
11319
11319
|
let timeout;
|
|
@@ -11330,7 +11330,7 @@ class UpstreamSessionManager extends TaskSpawner {
|
|
|
11330
11330
|
]);
|
|
11331
11331
|
const wasWoken = this.wakeEvent.isSet();
|
|
11332
11332
|
if (wasWoken) {
|
|
11333
|
-
logger$
|
|
11333
|
+
logger$15.debug('sleep_interrupted_by_wake_event');
|
|
11334
11334
|
this.wakeEvent.clear();
|
|
11335
11335
|
}
|
|
11336
11336
|
if (timeout !== undefined) {
|
|
@@ -11393,7 +11393,7 @@ class UpstreamSessionManager extends TaskSpawner {
|
|
|
11393
11393
|
await connector.start(this.wrappedHandler);
|
|
11394
11394
|
this.connector = connector;
|
|
11395
11395
|
const callbackGrants = this.node.gatherSupportedCallbackGrants();
|
|
11396
|
-
logger$
|
|
11396
|
+
logger$15.debug('callback_grants_before_augmentation', {
|
|
11397
11397
|
count: callbackGrants.length,
|
|
11398
11398
|
types: callbackGrants.map((g) => g.type),
|
|
11399
11399
|
});
|
|
@@ -11403,7 +11403,7 @@ class UpstreamSessionManager extends TaskSpawner {
|
|
|
11403
11403
|
const broadcastCallbackGrant = shouldAddBroadcastGrant
|
|
11404
11404
|
? this.createBroadcastCallbackGrant(grant)
|
|
11405
11405
|
: null;
|
|
11406
|
-
logger$
|
|
11406
|
+
logger$15.debug('broadcast_callback_grant_check', {
|
|
11407
11407
|
should_add: shouldAddBroadcastGrant,
|
|
11408
11408
|
grant_created: !!broadcastCallbackGrant,
|
|
11409
11409
|
});
|
|
@@ -11422,12 +11422,12 @@ class UpstreamSessionManager extends TaskSpawner {
|
|
|
11422
11422
|
const isDuplicate = callbackGrants.some((existing) => JSON.stringify(existing) === JSON.stringify(grant));
|
|
11423
11423
|
if (!isDuplicate) {
|
|
11424
11424
|
callbackGrants.push(grant);
|
|
11425
|
-
logger$
|
|
11425
|
+
logger$15.debug('added_connection_grant_as_callback', {
|
|
11426
11426
|
type: grant.type,
|
|
11427
11427
|
});
|
|
11428
11428
|
}
|
|
11429
11429
|
else {
|
|
11430
|
-
logger$
|
|
11430
|
+
logger$15.debug('skipped_duplicate_connection_grant', {
|
|
11431
11431
|
type: grant.type,
|
|
11432
11432
|
});
|
|
11433
11433
|
}
|
|
@@ -11439,12 +11439,12 @@ class UpstreamSessionManager extends TaskSpawner {
|
|
|
11439
11439
|
if (broadcastCallbackGrant &&
|
|
11440
11440
|
this.shouldAdvertiseBroadcastGrant(grant, callbackGrants)) {
|
|
11441
11441
|
callbackGrants.push(broadcastCallbackGrant);
|
|
11442
|
-
logger$
|
|
11442
|
+
logger$15.debug('added_broadcast_callback_grant');
|
|
11443
11443
|
}
|
|
11444
11444
|
else if (broadcastCallbackGrant) {
|
|
11445
|
-
logger$
|
|
11445
|
+
logger$15.debug('skipped_duplicate_broadcast_callback_grant');
|
|
11446
11446
|
}
|
|
11447
|
-
logger$
|
|
11447
|
+
logger$15.debug('callback_grants_after_augmentation', {
|
|
11448
11448
|
count: callbackGrants.length,
|
|
11449
11449
|
types: callbackGrants.map((g) => g.type),
|
|
11450
11450
|
});
|
|
@@ -11457,7 +11457,7 @@ class UpstreamSessionManager extends TaskSpawner {
|
|
|
11457
11457
|
targetAware.setTargetNodeId(this.targetSystemId);
|
|
11458
11458
|
}
|
|
11459
11459
|
catch (error) {
|
|
11460
|
-
logger$
|
|
11460
|
+
logger$15.warning('broadcast_channel_target_apply_failed', {
|
|
11461
11461
|
error: error instanceof Error ? error.message : String(error),
|
|
11462
11462
|
target_node_id: this.targetSystemId,
|
|
11463
11463
|
});
|
|
@@ -11479,14 +11479,14 @@ class UpstreamSessionManager extends TaskSpawner {
|
|
|
11479
11479
|
});
|
|
11480
11480
|
}
|
|
11481
11481
|
else {
|
|
11482
|
-
logger$
|
|
11482
|
+
logger$15.warning('parent_epoch_changed', { epoch });
|
|
11483
11483
|
}
|
|
11484
11484
|
}
|
|
11485
11485
|
if (!this.readyEvent.isSet()) {
|
|
11486
11486
|
this.readyEvent.set();
|
|
11487
11487
|
}
|
|
11488
11488
|
if (this.messageQueue.length > 0) {
|
|
11489
|
-
logger$
|
|
11489
|
+
logger$15.debug('flushing_buffered_frames', {
|
|
11490
11490
|
queue_size: this.messageQueue.length,
|
|
11491
11491
|
});
|
|
11492
11492
|
this.queueEvent.set();
|
|
@@ -11503,12 +11503,12 @@ class UpstreamSessionManager extends TaskSpawner {
|
|
|
11503
11503
|
name: `expiry-guard-${this.connectEpoch}`,
|
|
11504
11504
|
});
|
|
11505
11505
|
if (this.hadSuccessfulAttach) {
|
|
11506
|
-
logger$
|
|
11506
|
+
logger$15.debug('reconnected_to_upstream', {
|
|
11507
11507
|
attach_expires_at: attachInfo.attachExpiresAt?.toISOString?.() ?? null,
|
|
11508
11508
|
});
|
|
11509
11509
|
}
|
|
11510
11510
|
else {
|
|
11511
|
-
logger$
|
|
11511
|
+
logger$15.debug('connected_to_upstream', {
|
|
11512
11512
|
attach_expires_at: attachInfo.attachExpiresAt?.toISOString?.() ?? null,
|
|
11513
11513
|
});
|
|
11514
11514
|
}
|
|
@@ -11526,18 +11526,18 @@ class UpstreamSessionManager extends TaskSpawner {
|
|
|
11526
11526
|
this.currentStopSubtasks = null;
|
|
11527
11527
|
await Promise.allSettled(tasks.map((task) => task.promise));
|
|
11528
11528
|
if (this.connector) {
|
|
11529
|
-
logger$
|
|
11529
|
+
logger$15.debug('upstream_stopping_old_connector', {
|
|
11530
11530
|
connect_epoch: this.connectEpoch,
|
|
11531
11531
|
target_system_id: this.targetSystemId,
|
|
11532
11532
|
timestamp: new Date().toISOString(),
|
|
11533
11533
|
});
|
|
11534
11534
|
await this.connector.stop().catch((err) => {
|
|
11535
|
-
logger$
|
|
11535
|
+
logger$15.warning('upstream_connector_stop_error', {
|
|
11536
11536
|
connect_epoch: this.connectEpoch,
|
|
11537
11537
|
error: err instanceof Error ? err.message : String(err),
|
|
11538
11538
|
});
|
|
11539
11539
|
});
|
|
11540
|
-
logger$
|
|
11540
|
+
logger$15.debug('upstream_old_connector_stopped', {
|
|
11541
11541
|
connect_epoch: this.connectEpoch,
|
|
11542
11542
|
target_system_id: this.targetSystemId,
|
|
11543
11543
|
timestamp: new Date().toISOString(),
|
|
@@ -11590,7 +11590,7 @@ class UpstreamSessionManager extends TaskSpawner {
|
|
|
11590
11590
|
});
|
|
11591
11591
|
}
|
|
11592
11592
|
catch (error) {
|
|
11593
|
-
logger$
|
|
11593
|
+
logger$15.debug('broadcast_callback_grant_generation_failed', {
|
|
11594
11594
|
error: error instanceof Error ? error.message : String(error),
|
|
11595
11595
|
});
|
|
11596
11596
|
return null;
|
|
@@ -11645,7 +11645,7 @@ class UpstreamSessionManager extends TaskSpawner {
|
|
|
11645
11645
|
}
|
|
11646
11646
|
}
|
|
11647
11647
|
async heartbeatLoop(connector, stopEvt, signal) {
|
|
11648
|
-
logger$
|
|
11648
|
+
logger$15.debug('starting_heartbeat_loop');
|
|
11649
11649
|
const intervalMs = UpstreamSessionManager.HEARTBEAT_INTERVAL * 1000;
|
|
11650
11650
|
const graceMs = intervalMs * UpstreamSessionManager.HEARTBEAT_GRACE;
|
|
11651
11651
|
this.lastHeartbeatAckTime = Date.now();
|
|
@@ -11681,7 +11681,7 @@ class UpstreamSessionManager extends TaskSpawner {
|
|
|
11681
11681
|
// Skip heartbeat if connector is paused (e.g., tab is hidden)
|
|
11682
11682
|
// Keep ack time current so we don't timeout immediately after resuming
|
|
11683
11683
|
if (currentState === core.ConnectorState.PAUSED) {
|
|
11684
|
-
logger$
|
|
11684
|
+
logger$15.debug('skipping_heartbeat_connector_paused', {
|
|
11685
11685
|
connector_state: currentState,
|
|
11686
11686
|
});
|
|
11687
11687
|
this.lastHeartbeatAckTime = Date.now();
|
|
@@ -11690,14 +11690,14 @@ class UpstreamSessionManager extends TaskSpawner {
|
|
|
11690
11690
|
// Reset ack time if just resumed from pause (prevents immediate timeout)
|
|
11691
11691
|
if (previousState === core.ConnectorState.PAUSED &&
|
|
11692
11692
|
currentState === core.ConnectorState.STARTED) {
|
|
11693
|
-
logger$
|
|
11693
|
+
logger$15.debug('connector_just_resumed_resetting_ack_time', {
|
|
11694
11694
|
previous_state: previousState,
|
|
11695
11695
|
current_state: currentState,
|
|
11696
11696
|
});
|
|
11697
11697
|
this.lastHeartbeatAckTime = Date.now();
|
|
11698
11698
|
}
|
|
11699
11699
|
const envelope = await this.makeHeartbeatEnvelope();
|
|
11700
|
-
logger$
|
|
11700
|
+
logger$15.debug('sending_heartbeat', {
|
|
11701
11701
|
hb_corr_id: envelope.corrId,
|
|
11702
11702
|
hb_env_id: envelope.id,
|
|
11703
11703
|
});
|
|
@@ -11723,7 +11723,7 @@ class UpstreamSessionManager extends TaskSpawner {
|
|
|
11723
11723
|
throw new FameConnectError('missed heartbeat acknowledgement');
|
|
11724
11724
|
}
|
|
11725
11725
|
}
|
|
11726
|
-
logger$
|
|
11726
|
+
logger$15.debug('completed_heartbeat_loop');
|
|
11727
11727
|
}
|
|
11728
11728
|
async messagePumpLoop(connector, stopEvt, signal) {
|
|
11729
11729
|
while (!stopEvt.isSet() && !signal?.aborted) {
|
|
@@ -11740,19 +11740,19 @@ class UpstreamSessionManager extends TaskSpawner {
|
|
|
11740
11740
|
if (!envelope) {
|
|
11741
11741
|
continue;
|
|
11742
11742
|
}
|
|
11743
|
-
logger$
|
|
11743
|
+
logger$15.debug('upstream_pump_sending_envelope', {
|
|
11744
11744
|
envelopeId: envelope.id,
|
|
11745
11745
|
type: envelope.frame?.type,
|
|
11746
11746
|
});
|
|
11747
11747
|
try {
|
|
11748
11748
|
await connector.send(envelope);
|
|
11749
|
-
logger$
|
|
11749
|
+
logger$15.debug('upstream_pump_sent_envelope', {
|
|
11750
11750
|
envelopeId: envelope.id,
|
|
11751
11751
|
});
|
|
11752
11752
|
}
|
|
11753
11753
|
catch (error) {
|
|
11754
11754
|
if (error instanceof FameMessageTooLarge) {
|
|
11755
|
-
logger$
|
|
11755
|
+
logger$15.error('failed_to_send_message', { error: error.message });
|
|
11756
11756
|
await this.handleMessageTooLarge(envelope, error.message);
|
|
11757
11757
|
}
|
|
11758
11758
|
else if (error instanceof FameTransportClose) {
|
|
@@ -11814,7 +11814,7 @@ class UpstreamSessionManager extends TaskSpawner {
|
|
|
11814
11814
|
await fabric.send(ackEnvelope);
|
|
11815
11815
|
}
|
|
11816
11816
|
catch (error) {
|
|
11817
|
-
logger$
|
|
11817
|
+
logger$15.warning('failed_to_send_nack', {
|
|
11818
11818
|
error: error.message,
|
|
11819
11819
|
});
|
|
11820
11820
|
}
|
|
@@ -11828,7 +11828,7 @@ class UpstreamSessionManager extends TaskSpawner {
|
|
|
11828
11828
|
timestamps.push(info.attachExpiresAt);
|
|
11829
11829
|
}
|
|
11830
11830
|
if (!timestamps.length) {
|
|
11831
|
-
logger$
|
|
11831
|
+
logger$15.debug('no_ttl_expiry_configured');
|
|
11832
11832
|
await this.waitEvent(stopEvt, signal);
|
|
11833
11833
|
return;
|
|
11834
11834
|
}
|
|
@@ -11837,7 +11837,7 @@ class UpstreamSessionManager extends TaskSpawner {
|
|
|
11837
11837
|
let delaySeconds = (earliest.getTime() - now.getTime()) / 1000 -
|
|
11838
11838
|
UpstreamSessionManager.JWT_REFRESH_SAFETY;
|
|
11839
11839
|
delaySeconds = Math.max(delaySeconds, UpstreamSessionManager.JWT_REFRESH_SAFETY);
|
|
11840
|
-
logger$
|
|
11840
|
+
logger$15.debug('ttl_expiry_guard_started', {
|
|
11841
11841
|
welcome_expires_at: welcome.frame.expiresAt ?? null,
|
|
11842
11842
|
attach_expires_at: info.attachExpiresAt?.toISOString?.() ?? null,
|
|
11843
11843
|
earliest_expiry: earliest.toISOString(),
|
|
@@ -11865,7 +11865,7 @@ class UpstreamSessionManager extends TaskSpawner {
|
|
|
11865
11865
|
}
|
|
11866
11866
|
}
|
|
11867
11867
|
if (!stopEvt.isSet()) {
|
|
11868
|
-
logger$
|
|
11868
|
+
logger$15.debug('ttl_expiry_triggered_reconnect', {
|
|
11869
11869
|
expires_at: earliest.toISOString(),
|
|
11870
11870
|
current_time: new Date().toISOString(),
|
|
11871
11871
|
seconds_before_expiry: UpstreamSessionManager.JWT_REFRESH_SAFETY,
|
|
@@ -11910,7 +11910,7 @@ class UpstreamSessionManager extends TaskSpawner {
|
|
|
11910
11910
|
}
|
|
11911
11911
|
await this.node.dispatchEnvelopeEvent('onEnvelopeReceived', this.node, env, context);
|
|
11912
11912
|
if (env.frame.type === 'NodeHeartbeatAck') {
|
|
11913
|
-
logger$
|
|
11913
|
+
logger$15.debug('received_heartbeat_ack', {
|
|
11914
11914
|
hb_ack_env_id: env.id,
|
|
11915
11915
|
hb_ack_corr_id: env.corrId,
|
|
11916
11916
|
hb_routing_epoch: env.frame.routingEpoch,
|
|
@@ -11924,7 +11924,7 @@ class UpstreamSessionManager extends TaskSpawner {
|
|
|
11924
11924
|
await this.onEpochChange(epoch);
|
|
11925
11925
|
}
|
|
11926
11926
|
else {
|
|
11927
|
-
logger$
|
|
11927
|
+
logger$15.warning('parent_epoch_changed', { epoch });
|
|
11928
11928
|
}
|
|
11929
11929
|
}
|
|
11930
11930
|
return;
|
|
@@ -11943,7 +11943,7 @@ UpstreamSessionManager.TX_QUEUE_MAX = 512;
|
|
|
11943
11943
|
UpstreamSessionManager.BACKOFF_INITIAL = 1; // seconds
|
|
11944
11944
|
UpstreamSessionManager.BACKOFF_CAP = 30; // seconds
|
|
11945
11945
|
|
|
11946
|
-
const logger$
|
|
11946
|
+
const logger$14 = getLogger('naylence.fame.node.admission.noop_admission_client');
|
|
11947
11947
|
class NoopAdmissionClient {
|
|
11948
11948
|
constructor(options = {}) {
|
|
11949
11949
|
this.hasUpstream = false;
|
|
@@ -11957,7 +11957,7 @@ class NoopAdmissionClient {
|
|
|
11957
11957
|
const acceptedLogicals = this.autoAcceptLogicals
|
|
11958
11958
|
? [...(requestedLogicals ?? [])]
|
|
11959
11959
|
: [];
|
|
11960
|
-
logger$
|
|
11960
|
+
logger$14.debug('noop_admission_hello', {
|
|
11961
11961
|
systemId: effectiveSystemId,
|
|
11962
11962
|
instanceId,
|
|
11963
11963
|
requestedLogicals,
|
|
@@ -11975,7 +11975,7 @@ class NoopAdmissionClient {
|
|
|
11975
11975
|
});
|
|
11976
11976
|
}
|
|
11977
11977
|
async close() {
|
|
11978
|
-
logger$
|
|
11978
|
+
logger$14.debug('noop_admission_close');
|
|
11979
11979
|
}
|
|
11980
11980
|
}
|
|
11981
11981
|
|
|
@@ -12181,7 +12181,7 @@ class DefaultServiceManager {
|
|
|
12181
12181
|
}
|
|
12182
12182
|
|
|
12183
12183
|
const SYSTEM_INBOX$1 = '__sys__';
|
|
12184
|
-
const logger$
|
|
12184
|
+
const logger$13 = getLogger('naylence.fame.node.node');
|
|
12185
12185
|
function isSnakeCase(name) {
|
|
12186
12186
|
return name.includes('_');
|
|
12187
12187
|
}
|
|
@@ -12451,7 +12451,7 @@ class FameNode extends TaskSpawner {
|
|
|
12451
12451
|
confirmIdentity(systemId, source) {
|
|
12452
12452
|
if (this._confirmedId) {
|
|
12453
12453
|
if (this._confirmedId !== systemId) {
|
|
12454
|
-
logger$
|
|
12454
|
+
logger$13.error('node_identity_mismatch', {
|
|
12455
12455
|
current_id: this._confirmedId,
|
|
12456
12456
|
new_id: systemId,
|
|
12457
12457
|
source,
|
|
@@ -12463,14 +12463,14 @@ class FameNode extends TaskSpawner {
|
|
|
12463
12463
|
const isReassignment = this._provisionalId !== systemId;
|
|
12464
12464
|
this._confirmedId = systemId;
|
|
12465
12465
|
if (isReassignment) {
|
|
12466
|
-
logger$
|
|
12466
|
+
logger$13.debug('node_identity_reassigned', {
|
|
12467
12467
|
system_id: systemId,
|
|
12468
12468
|
previous_id: this._provisionalId,
|
|
12469
12469
|
source,
|
|
12470
12470
|
});
|
|
12471
12471
|
}
|
|
12472
12472
|
else {
|
|
12473
|
-
logger$
|
|
12473
|
+
logger$13.debug('node_identity_confirmed', {
|
|
12474
12474
|
system_id: systemId,
|
|
12475
12475
|
source,
|
|
12476
12476
|
});
|
|
@@ -12538,7 +12538,7 @@ class FameNode extends TaskSpawner {
|
|
|
12538
12538
|
return;
|
|
12539
12539
|
}
|
|
12540
12540
|
if (frameType === 'NodeHeartbeat') {
|
|
12541
|
-
logger$
|
|
12541
|
+
logger$13.debug('received_heartbeat_frame', {
|
|
12542
12542
|
envelopeId: envelope.id,
|
|
12543
12543
|
corrId: envelope.corrId ?? null,
|
|
12544
12544
|
});
|
|
@@ -12550,7 +12550,7 @@ class FameNode extends TaskSpawner {
|
|
|
12550
12550
|
await this.handleDeliveryAck(envelope, context);
|
|
12551
12551
|
return;
|
|
12552
12552
|
}
|
|
12553
|
-
logger$
|
|
12553
|
+
logger$13.debug('unhandled_system_frame', {
|
|
12554
12554
|
envelopeId: envelope.id,
|
|
12555
12555
|
frameType,
|
|
12556
12556
|
});
|
|
@@ -12562,13 +12562,13 @@ class FameNode extends TaskSpawner {
|
|
|
12562
12562
|
}
|
|
12563
12563
|
await this._deliveryTracker.onEnvelopeDelivered(SYSTEM_INBOX$1, envelope, context);
|
|
12564
12564
|
if (frame.ok !== false) {
|
|
12565
|
-
logger$
|
|
12565
|
+
logger$13.debug('delivery_ack_received', {
|
|
12566
12566
|
envelopeId: envelope.id,
|
|
12567
12567
|
corrId: envelope.corrId ?? null,
|
|
12568
12568
|
});
|
|
12569
12569
|
return;
|
|
12570
12570
|
}
|
|
12571
|
-
logger$
|
|
12571
|
+
logger$13.warning('delivery_nack_received', {
|
|
12572
12572
|
envelopeId: envelope.id,
|
|
12573
12573
|
corrId: envelope.corrId ?? null,
|
|
12574
12574
|
code: frame.code ?? null,
|
|
@@ -12578,7 +12578,7 @@ class FameNode extends TaskSpawner {
|
|
|
12578
12578
|
await this.onDeliveryNack(frame, envelope, context);
|
|
12579
12579
|
}
|
|
12580
12580
|
async onDeliveryNack(frame, envelope, _context) {
|
|
12581
|
-
logger$
|
|
12581
|
+
logger$13.debug('delivery_nack_processed', {
|
|
12582
12582
|
envelopeId: envelope.id,
|
|
12583
12583
|
code: frame.code ?? null,
|
|
12584
12584
|
reason: frame.reason ?? null,
|
|
@@ -12693,7 +12693,7 @@ class FameNode extends TaskSpawner {
|
|
|
12693
12693
|
await this._bindingManager.restore();
|
|
12694
12694
|
await this._envelopeListenerManager.start();
|
|
12695
12695
|
this._isStarted = true;
|
|
12696
|
-
logger$
|
|
12696
|
+
logger$13.debug('node_started', {
|
|
12697
12697
|
node_id: this.id,
|
|
12698
12698
|
sid: this.sid,
|
|
12699
12699
|
path: this.physicalPath,
|
|
@@ -12725,7 +12725,7 @@ class FameNode extends TaskSpawner {
|
|
|
12725
12725
|
await this._serviceManager.stop();
|
|
12726
12726
|
await this.dispatchEvent('onNodeStopped', this);
|
|
12727
12727
|
this._isStarted = false;
|
|
12728
|
-
logger$
|
|
12728
|
+
logger$13.debug('node_stopped', {
|
|
12729
12729
|
node_id: this.id,
|
|
12730
12730
|
});
|
|
12731
12731
|
}
|
|
@@ -12915,20 +12915,20 @@ class FameNode extends TaskSpawner {
|
|
|
12915
12915
|
await this.forwardUpstream(processedEnvelope, context);
|
|
12916
12916
|
}
|
|
12917
12917
|
else {
|
|
12918
|
-
logger$
|
|
12918
|
+
logger$13.error('attempted_upstream_loop', {
|
|
12919
12919
|
envelopeId: processedEnvelope.id,
|
|
12920
12920
|
});
|
|
12921
12921
|
}
|
|
12922
12922
|
return;
|
|
12923
12923
|
}
|
|
12924
12924
|
if (!processedEnvelope.to) {
|
|
12925
|
-
logger$
|
|
12925
|
+
logger$13.error('dropping_envelope_without_destination', {
|
|
12926
12926
|
envelopeId: processedEnvelope.id,
|
|
12927
12927
|
capabilities: processedEnvelope.capabilities ?? [],
|
|
12928
12928
|
});
|
|
12929
12929
|
return;
|
|
12930
12930
|
}
|
|
12931
|
-
logger$
|
|
12931
|
+
logger$13.warning('no_local_handler_for_address', {
|
|
12932
12932
|
address: processedEnvelope.to.toString?.() ?? String(processedEnvelope.to),
|
|
12933
12933
|
originType: context?.originType ?? null,
|
|
12934
12934
|
});
|
|
@@ -13052,7 +13052,7 @@ class FameNode extends TaskSpawner {
|
|
|
13052
13052
|
}
|
|
13053
13053
|
}
|
|
13054
13054
|
catch (error) {
|
|
13055
|
-
logger$
|
|
13055
|
+
logger$13.warning('callback_grant_collection_failed', {
|
|
13056
13056
|
error: error instanceof Error ? error.message : String(error),
|
|
13057
13057
|
});
|
|
13058
13058
|
}
|
|
@@ -13115,7 +13115,7 @@ class FameNode extends TaskSpawner {
|
|
|
13115
13115
|
await store.set('self', record);
|
|
13116
13116
|
}
|
|
13117
13117
|
catch (error) {
|
|
13118
|
-
logger$
|
|
13118
|
+
logger$13.warning('node_meta_persist_failed', {
|
|
13119
13119
|
error: error instanceof Error ? error.message : String(error),
|
|
13120
13120
|
});
|
|
13121
13121
|
}
|
|
@@ -13253,44 +13253,12 @@ class ConnectionRetryPolicyFactory extends factory.AbstractResourceFactory {
|
|
|
13253
13253
|
}
|
|
13254
13254
|
}
|
|
13255
13255
|
|
|
13256
|
-
|
|
13257
|
-
|
|
13258
|
-
|
|
13259
|
-
|
|
13260
|
-
|
|
13261
|
-
|
|
13262
|
-
throw new Error('Failed to create token provider from configuration');
|
|
13263
|
-
}
|
|
13264
|
-
return provider;
|
|
13265
|
-
}
|
|
13266
|
-
let provider = null;
|
|
13267
|
-
try {
|
|
13268
|
-
provider = await factory.createDefaultResource(TOKEN_PROVIDER_FACTORY_BASE_TYPE, null, options);
|
|
13269
|
-
}
|
|
13270
|
-
catch (error) {
|
|
13271
|
-
const message = 'Failed to create default token provider' +
|
|
13272
|
-
(error instanceof Error && error.message ? `: ${error.message}` : '');
|
|
13273
|
-
throw new Error(message);
|
|
13274
|
-
}
|
|
13275
|
-
if (!provider) {
|
|
13276
|
-
throw new Error('Failed to create default token provider');
|
|
13277
|
-
}
|
|
13278
|
-
return provider;
|
|
13279
|
-
}
|
|
13280
|
-
}
|
|
13281
|
-
|
|
13282
|
-
function isTokenProvider(candidate) {
|
|
13283
|
-
return (typeof candidate === 'object' &&
|
|
13284
|
-
candidate !== null &&
|
|
13285
|
-
typeof candidate.getToken === 'function');
|
|
13286
|
-
}
|
|
13287
|
-
function isIdentityExposingTokenProvider(candidate) {
|
|
13288
|
-
return (isTokenProvider(candidate) &&
|
|
13289
|
-
typeof candidate.getIdentity ===
|
|
13290
|
-
'function');
|
|
13291
|
-
}
|
|
13292
|
-
|
|
13293
|
-
const logger$13 = getLogger('naylence.fame.node.default_node_identity_policy');
|
|
13256
|
+
/**
|
|
13257
|
+
* Default node identity policy that preserves the current node ID.
|
|
13258
|
+
*
|
|
13259
|
+
* This policy does NOT derive identity from tokens or grants.
|
|
13260
|
+
* For token-subject-based identity, use TokenSubjectNodeIdentityPolicy.
|
|
13261
|
+
*/
|
|
13294
13262
|
class DefaultNodeIdentityPolicy {
|
|
13295
13263
|
async resolveInitialNodeId(context) {
|
|
13296
13264
|
if (context.configuredId) {
|
|
@@ -13302,44 +13270,10 @@ class DefaultNodeIdentityPolicy {
|
|
|
13302
13270
|
return await core.generateIdAsync({ mode: 'fingerprint' });
|
|
13303
13271
|
}
|
|
13304
13272
|
async resolveAdmissionNodeId(context) {
|
|
13305
|
-
|
|
13306
|
-
|
|
13307
|
-
for (const grant of context.grants) {
|
|
13308
|
-
try {
|
|
13309
|
-
const auth = grant.auth;
|
|
13310
|
-
if (!auth) {
|
|
13311
|
-
continue;
|
|
13312
|
-
}
|
|
13313
|
-
const tokenProviderConfig = (auth.tokenProvider ??
|
|
13314
|
-
auth.token_provider);
|
|
13315
|
-
if (!tokenProviderConfig ||
|
|
13316
|
-
typeof tokenProviderConfig.type !== 'string') {
|
|
13317
|
-
continue;
|
|
13318
|
-
}
|
|
13319
|
-
const provider = await TokenProviderFactory.createTokenProvider(tokenProviderConfig);
|
|
13320
|
-
if (isIdentityExposingTokenProvider(provider)) {
|
|
13321
|
-
const identity = await provider.getIdentity();
|
|
13322
|
-
if (identity && identity.subject) {
|
|
13323
|
-
logger$13.debug('identity_extracted_from_grant', {
|
|
13324
|
-
identity_id: identity.subject,
|
|
13325
|
-
grant_type: grant.type,
|
|
13326
|
-
});
|
|
13327
|
-
return identity.subject;
|
|
13328
|
-
}
|
|
13329
|
-
}
|
|
13330
|
-
}
|
|
13331
|
-
catch (error) {
|
|
13332
|
-
logger$13.warning('identity_extraction_failed', {
|
|
13333
|
-
error: error instanceof Error ? error.message : String(error),
|
|
13334
|
-
grant_type: grant.type,
|
|
13335
|
-
});
|
|
13336
|
-
}
|
|
13337
|
-
}
|
|
13338
|
-
}
|
|
13339
|
-
if (!context.currentNodeId) {
|
|
13340
|
-
return await core.generateIdAsync({ mode: 'fingerprint' });
|
|
13273
|
+
if (context.currentNodeId) {
|
|
13274
|
+
return context.currentNodeId;
|
|
13341
13275
|
}
|
|
13342
|
-
return
|
|
13276
|
+
return await core.generateIdAsync({ mode: 'fingerprint' });
|
|
13343
13277
|
}
|
|
13344
13278
|
}
|
|
13345
13279
|
|
|
@@ -16106,6 +16040,43 @@ var defaultNodeIdentityPolicyFactory = /*#__PURE__*/Object.freeze({
|
|
|
16106
16040
|
default: DefaultNodeIdentityPolicyFactory
|
|
16107
16041
|
});
|
|
16108
16042
|
|
|
16043
|
+
const TOKEN_PROVIDER_FACTORY_BASE_TYPE = 'TokenProviderFactory';
|
|
16044
|
+
class TokenProviderFactory extends factory.AbstractResourceFactory {
|
|
16045
|
+
static async createTokenProvider(config, options = {}) {
|
|
16046
|
+
if (config) {
|
|
16047
|
+
const provider = await factory.createResource(TOKEN_PROVIDER_FACTORY_BASE_TYPE, config, options);
|
|
16048
|
+
if (!provider) {
|
|
16049
|
+
throw new Error('Failed to create token provider from configuration');
|
|
16050
|
+
}
|
|
16051
|
+
return provider;
|
|
16052
|
+
}
|
|
16053
|
+
let provider = null;
|
|
16054
|
+
try {
|
|
16055
|
+
provider = await factory.createDefaultResource(TOKEN_PROVIDER_FACTORY_BASE_TYPE, null, options);
|
|
16056
|
+
}
|
|
16057
|
+
catch (error) {
|
|
16058
|
+
const message = 'Failed to create default token provider' +
|
|
16059
|
+
(error instanceof Error && error.message ? `: ${error.message}` : '');
|
|
16060
|
+
throw new Error(message);
|
|
16061
|
+
}
|
|
16062
|
+
if (!provider) {
|
|
16063
|
+
throw new Error('Failed to create default token provider');
|
|
16064
|
+
}
|
|
16065
|
+
return provider;
|
|
16066
|
+
}
|
|
16067
|
+
}
|
|
16068
|
+
|
|
16069
|
+
function isTokenProvider(candidate) {
|
|
16070
|
+
return (typeof candidate === 'object' &&
|
|
16071
|
+
candidate !== null &&
|
|
16072
|
+
typeof candidate.getToken === 'function');
|
|
16073
|
+
}
|
|
16074
|
+
function isIdentityExposingTokenProvider(candidate) {
|
|
16075
|
+
return (isTokenProvider(candidate) &&
|
|
16076
|
+
typeof candidate.getIdentity ===
|
|
16077
|
+
'function');
|
|
16078
|
+
}
|
|
16079
|
+
|
|
16109
16080
|
const logger$_ = getLogger('naylence.fame.node.token_subject_node_identity_policy');
|
|
16110
16081
|
class TokenSubjectNodeIdentityPolicy {
|
|
16111
16082
|
async resolveInitialNodeId(context) {
|