@naylence/runtime 0.3.21 → 0.3.22
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.mjs
CHANGED
|
@@ -513,12 +513,12 @@ async function ensureRuntimeFactoriesRegistered(registry = Registry) {
|
|
|
513
513
|
}
|
|
514
514
|
|
|
515
515
|
// This file is auto-generated during build - do not edit manually
|
|
516
|
-
// Generated from package.json version: 0.3.
|
|
516
|
+
// Generated from package.json version: 0.3.22
|
|
517
517
|
/**
|
|
518
518
|
* The package version, injected at build time.
|
|
519
519
|
* @internal
|
|
520
520
|
*/
|
|
521
|
-
const VERSION = '0.3.
|
|
521
|
+
const VERSION = '0.3.22';
|
|
522
522
|
|
|
523
523
|
let initialized = false;
|
|
524
524
|
const runtimePlugin = {
|
|
@@ -1363,7 +1363,7 @@ class TaskCancelledError extends Error {
|
|
|
1363
1363
|
* Provides functionality similar to Python's asyncio TaskSpawner with proper
|
|
1364
1364
|
* error handling, cancellation, and graceful shutdown capabilities.
|
|
1365
1365
|
*/
|
|
1366
|
-
const logger$
|
|
1366
|
+
const logger$1g = getLogger('naylence.fame.util.task_spawner');
|
|
1367
1367
|
function firstDefined(source, keys) {
|
|
1368
1368
|
for (const key of keys) {
|
|
1369
1369
|
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
@@ -1524,7 +1524,7 @@ class TaskSpawner {
|
|
|
1524
1524
|
const taskId = `task-${++this._taskCounter}`;
|
|
1525
1525
|
const taskName = normalizedOptions.name || `unnamed-${taskId}`;
|
|
1526
1526
|
const timeout = normalizedOptions.timeout ?? this._config.defaultTimeout;
|
|
1527
|
-
logger$
|
|
1527
|
+
logger$1g.debug('starting_background_task', {
|
|
1528
1528
|
task_name: taskName,
|
|
1529
1529
|
task_id: taskId,
|
|
1530
1530
|
});
|
|
@@ -1541,7 +1541,7 @@ class TaskSpawner {
|
|
|
1541
1541
|
task.promise
|
|
1542
1542
|
.then(() => {
|
|
1543
1543
|
if (!this._suppressCompletionLogging) {
|
|
1544
|
-
logger$
|
|
1544
|
+
logger$1g.debug('task_completed_successfully', {
|
|
1545
1545
|
task_name: taskName,
|
|
1546
1546
|
task_id: taskId,
|
|
1547
1547
|
duration_ms: Date.now() - task.startTime,
|
|
@@ -1595,7 +1595,7 @@ class TaskSpawner {
|
|
|
1595
1595
|
error.name === 'AbortError' ||
|
|
1596
1596
|
error.message === 'Task cancelled' ||
|
|
1597
1597
|
error.message === 'Aborted') {
|
|
1598
|
-
logger$
|
|
1598
|
+
logger$1g.debug('task_cancelled', {
|
|
1599
1599
|
task_name: taskName,
|
|
1600
1600
|
note: 'Task cancelled as requested',
|
|
1601
1601
|
});
|
|
@@ -1603,7 +1603,7 @@ class TaskSpawner {
|
|
|
1603
1603
|
}
|
|
1604
1604
|
// Handle timeout
|
|
1605
1605
|
if (error instanceof TaskTimeoutError) {
|
|
1606
|
-
logger$
|
|
1606
|
+
logger$1g.warning('task_timed_out', {
|
|
1607
1607
|
task_name: taskName,
|
|
1608
1608
|
error: error.message,
|
|
1609
1609
|
});
|
|
@@ -1615,7 +1615,7 @@ class TaskSpawner {
|
|
|
1615
1615
|
// Handle known WebSocket shutdown race condition (similar to Python version)
|
|
1616
1616
|
if (error.message.includes("await wasn't used with future") ||
|
|
1617
1617
|
error.message.includes('WebSocket closed during receive')) {
|
|
1618
|
-
logger$
|
|
1618
|
+
logger$1g.debug('task_shutdown_race_condition_handled', {
|
|
1619
1619
|
task_name: taskName,
|
|
1620
1620
|
note: 'Normal WebSocket close timing during shutdown - not an error',
|
|
1621
1621
|
});
|
|
@@ -1625,7 +1625,7 @@ class TaskSpawner {
|
|
|
1625
1625
|
if (error.name === 'FameTransportClose' ||
|
|
1626
1626
|
error.message.includes('normal closure') ||
|
|
1627
1627
|
error.message.includes('Connection closed')) {
|
|
1628
|
-
logger$
|
|
1628
|
+
logger$1g.debug('task_shutdown_completed_normally', {
|
|
1629
1629
|
task_name: taskName,
|
|
1630
1630
|
note: 'Task closed normally during shutdown',
|
|
1631
1631
|
});
|
|
@@ -1633,7 +1633,7 @@ class TaskSpawner {
|
|
|
1633
1633
|
}
|
|
1634
1634
|
// Handle PKCE redirect "errors" as info
|
|
1635
1635
|
if (error.name === 'OAuth2PkceRedirectInitiatedError') {
|
|
1636
|
-
logger$
|
|
1636
|
+
logger$1g.debug('background_task_redirecting', {
|
|
1637
1637
|
task_name: taskName,
|
|
1638
1638
|
note: 'Task interrupted for PKCE redirect',
|
|
1639
1639
|
});
|
|
@@ -1646,14 +1646,14 @@ class TaskSpawner {
|
|
|
1646
1646
|
// Log retriable errors as warnings (they'll be retried by upstream logic)
|
|
1647
1647
|
// Log non-retriable errors as errors (fatal failures)
|
|
1648
1648
|
if (isRetriableError) {
|
|
1649
|
-
logger$
|
|
1649
|
+
logger$1g.warning('background_task_failed', {
|
|
1650
1650
|
task_name: taskName,
|
|
1651
1651
|
error: error.message,
|
|
1652
1652
|
retriable: true,
|
|
1653
1653
|
});
|
|
1654
1654
|
}
|
|
1655
1655
|
else {
|
|
1656
|
-
logger$
|
|
1656
|
+
logger$1g.error('background_task_failed', {
|
|
1657
1657
|
task_name: taskName,
|
|
1658
1658
|
error: error.message,
|
|
1659
1659
|
stack: error.stack,
|
|
@@ -1672,11 +1672,11 @@ class TaskSpawner {
|
|
|
1672
1672
|
async shutdownTasks(options = {}) {
|
|
1673
1673
|
const { gracePeriod, cancelHanging, joinTimeout } = normalizeShutdownOptions(options);
|
|
1674
1674
|
if (this._tasks.size === 0) {
|
|
1675
|
-
logger$
|
|
1675
|
+
logger$1g.debug('shutdown_tasks_no_tasks_to_shutdown');
|
|
1676
1676
|
return;
|
|
1677
1677
|
}
|
|
1678
1678
|
this._suppressCompletionLogging = true;
|
|
1679
|
-
logger$
|
|
1679
|
+
logger$1g.debug('shutting_down_tasks', {
|
|
1680
1680
|
task_count: this._tasks.size,
|
|
1681
1681
|
task_names: Array.from(this._tasks.values()).map((t) => t.name),
|
|
1682
1682
|
grace_period_ms: gracePeriod,
|
|
@@ -1691,7 +1691,7 @@ class TaskSpawner {
|
|
|
1691
1691
|
if (cancelHanging) {
|
|
1692
1692
|
const stillRunning = tasks.filter((task) => task.getState() === TaskState.RUNNING && !completed.has(task));
|
|
1693
1693
|
if (stillRunning.length > 0) {
|
|
1694
|
-
logger$
|
|
1694
|
+
logger$1g.debug('tasks_did_not_complete_within_grace_period', {
|
|
1695
1695
|
hanging_count: stillRunning.length,
|
|
1696
1696
|
});
|
|
1697
1697
|
// Wait for them to finish with individual timeouts
|
|
@@ -1701,7 +1701,7 @@ class TaskSpawner {
|
|
|
1701
1701
|
}
|
|
1702
1702
|
catch (error) {
|
|
1703
1703
|
if (error instanceof TaskTimeoutError) {
|
|
1704
|
-
logger$
|
|
1704
|
+
logger$1g.warning('task_did_not_shutdown', {
|
|
1705
1705
|
task_name: task.name || task.id,
|
|
1706
1706
|
join_timeout_ms: joinTimeout,
|
|
1707
1707
|
});
|
|
@@ -1712,7 +1712,7 @@ class TaskSpawner {
|
|
|
1712
1712
|
}
|
|
1713
1713
|
else if (!(error instanceof TaskCancelledError)) {
|
|
1714
1714
|
/* istanbul ignore next - unreachable defensive branch */
|
|
1715
|
-
logger$
|
|
1715
|
+
logger$1g.error('task_raised_during_cancellation', {
|
|
1716
1716
|
task_name: task.name || task.id,
|
|
1717
1717
|
error: error instanceof Error ? error.message : String(error),
|
|
1718
1718
|
});
|
|
@@ -2849,7 +2849,7 @@ async function safeImport(loader, dependencyNameOrOptions, maybeOptions) {
|
|
|
2849
2849
|
* condition/promise and ensure at most one notifier coroutine exists for a
|
|
2850
2850
|
* flow at any time.
|
|
2851
2851
|
*/
|
|
2852
|
-
const logger$
|
|
2852
|
+
const logger$1f = getLogger('naylence.fame.flow.flow_controller');
|
|
2853
2853
|
/**
|
|
2854
2854
|
* Simple condition variable implementation for TypeScript/Node.js
|
|
2855
2855
|
* Similar to Python's asyncio.Condition
|
|
@@ -2983,7 +2983,7 @@ class FlowController {
|
|
|
2983
2983
|
const newBalance = Math.max(0, Math.min(this.initialWindow, prev + delta));
|
|
2984
2984
|
this.credits.set(flowId, newBalance);
|
|
2985
2985
|
const crossedZero = prev <= 0 && newBalance > 0;
|
|
2986
|
-
logger$
|
|
2986
|
+
logger$1f.debug('flow_controller_add_credits', {
|
|
2987
2987
|
flow_id: flowId,
|
|
2988
2988
|
delta,
|
|
2989
2989
|
prev_balance: prev,
|
|
@@ -3003,12 +3003,12 @@ class FlowController {
|
|
|
3003
3003
|
async acquire(flowId) {
|
|
3004
3004
|
this.ensureFlow(flowId);
|
|
3005
3005
|
const condition = this.conditions.get(flowId);
|
|
3006
|
-
logger$
|
|
3006
|
+
logger$1f.debug('flow_controller_acquire_attempt', {
|
|
3007
3007
|
flow_id: flowId,
|
|
3008
3008
|
current_balance: this.credits.get(flowId),
|
|
3009
3009
|
});
|
|
3010
3010
|
while (this.credits.get(flowId) <= 0) {
|
|
3011
|
-
logger$
|
|
3011
|
+
logger$1f.debug('flow_controller_waiting_for_credits', {
|
|
3012
3012
|
flow_id: flowId,
|
|
3013
3013
|
current_balance: this.credits.get(flowId),
|
|
3014
3014
|
});
|
|
@@ -3016,12 +3016,12 @@ class FlowController {
|
|
|
3016
3016
|
}
|
|
3017
3017
|
const newBalance = this.credits.get(flowId) - 1;
|
|
3018
3018
|
this.credits.set(flowId, newBalance);
|
|
3019
|
-
logger$
|
|
3019
|
+
logger$1f.debug('flow_controller_acquire_success', {
|
|
3020
3020
|
flow_id: flowId,
|
|
3021
3021
|
new_balance: newBalance,
|
|
3022
3022
|
});
|
|
3023
3023
|
if (newBalance <= this.lowWatermark) {
|
|
3024
|
-
logger$
|
|
3024
|
+
logger$1f.debug('flow_controller_acquire_below_low_watermark', {
|
|
3025
3025
|
flow_id: flowId,
|
|
3026
3026
|
low_watermark: this.lowWatermark,
|
|
3027
3027
|
});
|
|
@@ -3045,7 +3045,7 @@ class FlowController {
|
|
|
3045
3045
|
const current = this.credits.get(flowId);
|
|
3046
3046
|
const remaining = Math.max(current - credits, 0);
|
|
3047
3047
|
this.credits.set(flowId, remaining);
|
|
3048
|
-
logger$
|
|
3048
|
+
logger$1f.debug('flow_controller_consume', {
|
|
3049
3049
|
flow_id: flowId,
|
|
3050
3050
|
requested: credits,
|
|
3051
3051
|
prev_balance: current,
|
|
@@ -3071,7 +3071,7 @@ class FlowController {
|
|
|
3071
3071
|
this.windowIds.delete(flowId);
|
|
3072
3072
|
this.credits.set(flowId, this.initialWindow);
|
|
3073
3073
|
this.wakeWaiters(flowId);
|
|
3074
|
-
logger$
|
|
3074
|
+
logger$1f.debug('flow_controller_flow_reset', {
|
|
3075
3075
|
flow_id: flowId,
|
|
3076
3076
|
reset_balance: this.initialWindow,
|
|
3077
3077
|
});
|
|
@@ -3359,7 +3359,7 @@ class InMemoryBinding {
|
|
|
3359
3359
|
* TypeScript port of Python's InMemoryFanoutBroker that extends TaskSpawner
|
|
3360
3360
|
* to manage multiple WriteChannel subscribers with concurrent message distribution.
|
|
3361
3361
|
*/
|
|
3362
|
-
const logger$
|
|
3362
|
+
const logger$1e = getLogger('naylence.fame.channel.in_memory.in_memory_fanout_broker');
|
|
3363
3363
|
// Sentinel object for shutdown signaling
|
|
3364
3364
|
const SENTINEL = Symbol('fanout-broker-sentinel');
|
|
3365
3365
|
function isCloseable(obj) {
|
|
@@ -3412,7 +3412,7 @@ class InMemoryFanoutBroker extends TaskSpawner {
|
|
|
3412
3412
|
}
|
|
3413
3413
|
catch (error) {
|
|
3414
3414
|
// Ignore errors when sending sentinel (sink might be closed)
|
|
3415
|
-
logger$
|
|
3415
|
+
logger$1e.debug('error_sending_sentinel', {
|
|
3416
3416
|
error: error.message,
|
|
3417
3417
|
});
|
|
3418
3418
|
}
|
|
@@ -3426,7 +3426,7 @@ class InMemoryFanoutBroker extends TaskSpawner {
|
|
|
3426
3426
|
await sub.close();
|
|
3427
3427
|
}
|
|
3428
3428
|
catch (error) {
|
|
3429
|
-
logger$
|
|
3429
|
+
logger$1e.error('error_closing_subscriber', {
|
|
3430
3430
|
subscriber: sub.toString(),
|
|
3431
3431
|
error: error.message,
|
|
3432
3432
|
});
|
|
@@ -3466,7 +3466,7 @@ class InMemoryFanoutBroker extends TaskSpawner {
|
|
|
3466
3466
|
[envelope, context] = extractEnvelopeAndContext(msg);
|
|
3467
3467
|
}
|
|
3468
3468
|
catch (error) {
|
|
3469
|
-
logger$
|
|
3469
|
+
logger$1e.debug('failed_to_extract_envelope', {
|
|
3470
3470
|
error: error.message,
|
|
3471
3471
|
});
|
|
3472
3472
|
continue;
|
|
@@ -3488,7 +3488,7 @@ class InMemoryFanoutBroker extends TaskSpawner {
|
|
|
3488
3488
|
await sub.send(messageToSend);
|
|
3489
3489
|
}
|
|
3490
3490
|
catch (error) {
|
|
3491
|
-
logger$
|
|
3491
|
+
logger$1e.error('error_sending_to_subscriber', {
|
|
3492
3492
|
subscriber: sub.toString(),
|
|
3493
3493
|
error: error.message,
|
|
3494
3494
|
action: 'unsubscribing',
|
|
@@ -3504,7 +3504,7 @@ class InMemoryFanoutBroker extends TaskSpawner {
|
|
|
3504
3504
|
}
|
|
3505
3505
|
catch (error) {
|
|
3506
3506
|
// Critical broker-level error: log and back off, but keep the loop running
|
|
3507
|
-
logger$
|
|
3507
|
+
logger$1e.critical('receive_loop_failed_unexpectedly', {
|
|
3508
3508
|
error: error.message,
|
|
3509
3509
|
stack: error.stack,
|
|
3510
3510
|
});
|
|
@@ -5180,7 +5180,7 @@ function normalizeResponseType(value) {
|
|
|
5180
5180
|
return value;
|
|
5181
5181
|
}
|
|
5182
5182
|
|
|
5183
|
-
const logger$
|
|
5183
|
+
const logger$1d = getLogger('naylence.fame.node.binding_manager');
|
|
5184
5184
|
const SYSTEM_INBOX$3 = '__sys__';
|
|
5185
5185
|
const DEFAULT_ACK_TIMEOUT_MS = 20000;
|
|
5186
5186
|
class BindingStoreEntryRecord {
|
|
@@ -5266,7 +5266,7 @@ class BindingManager {
|
|
|
5266
5266
|
if (!this.bindings.has(key)) {
|
|
5267
5267
|
const binding = this.bindingFactory(new FameAddress(key));
|
|
5268
5268
|
this.bindings.set(key, binding);
|
|
5269
|
-
logger$
|
|
5269
|
+
logger$1d.debug('restored_binding', { address: key });
|
|
5270
5270
|
}
|
|
5271
5271
|
}
|
|
5272
5272
|
if (!this.hasUpstream) {
|
|
@@ -5276,13 +5276,13 @@ class BindingManager {
|
|
|
5276
5276
|
await this.readvertiseCapabilitiesUpstream();
|
|
5277
5277
|
}
|
|
5278
5278
|
async bind(participant, capabilities) {
|
|
5279
|
-
logger$
|
|
5279
|
+
logger$1d.debug('binding_participant', { participant });
|
|
5280
5280
|
const { prefixAddress, addresses, propagateAddress, capabilityAddress } = this.computeBindingAddresses(participant);
|
|
5281
5281
|
for (const address of addresses) {
|
|
5282
5282
|
if (!this.bindings.has(address)) {
|
|
5283
5283
|
const binding = this.bindingFactory(new FameAddress(address));
|
|
5284
5284
|
this.bindings.set(address, binding);
|
|
5285
|
-
logger$
|
|
5285
|
+
logger$1d.debug('bound_address', { address, participant });
|
|
5286
5286
|
}
|
|
5287
5287
|
}
|
|
5288
5288
|
let propagatedAddress = null;
|
|
@@ -5311,7 +5311,7 @@ class BindingManager {
|
|
|
5311
5311
|
await this.unbindAddressUpstream(propagatedAddress);
|
|
5312
5312
|
}
|
|
5313
5313
|
catch (rollbackError) {
|
|
5314
|
-
logger$
|
|
5314
|
+
logger$1d.error('bind_rollback_failed', {
|
|
5315
5315
|
address: propagatedAddress.toString(),
|
|
5316
5316
|
error: rollbackError.message,
|
|
5317
5317
|
});
|
|
@@ -5330,7 +5330,7 @@ class BindingManager {
|
|
|
5330
5330
|
physicalPath: null,
|
|
5331
5331
|
});
|
|
5332
5332
|
}
|
|
5333
|
-
logger$
|
|
5333
|
+
logger$1d.debug('bind_success', {
|
|
5334
5334
|
participant,
|
|
5335
5335
|
address: prefixAddress.toString(),
|
|
5336
5336
|
capabilities,
|
|
@@ -5366,7 +5366,7 @@ class BindingManager {
|
|
|
5366
5366
|
await this.bindingStore.delete(address);
|
|
5367
5367
|
}
|
|
5368
5368
|
}
|
|
5369
|
-
logger$
|
|
5369
|
+
logger$1d.debug('unbind_success', {
|
|
5370
5370
|
participant,
|
|
5371
5371
|
address: prefixAddress.toString(),
|
|
5372
5372
|
totalBindings: this.bindings.size,
|
|
@@ -5396,7 +5396,7 @@ class BindingManager {
|
|
|
5396
5396
|
await this.bindAddressUpstream(new FameAddress(address));
|
|
5397
5397
|
}
|
|
5398
5398
|
catch (error) {
|
|
5399
|
-
logger$
|
|
5399
|
+
logger$1d.error('rebind_failed', {
|
|
5400
5400
|
address,
|
|
5401
5401
|
error: error.message,
|
|
5402
5402
|
});
|
|
@@ -5415,7 +5415,7 @@ class BindingManager {
|
|
|
5415
5415
|
await this.advertiseCapabilities(new FameAddress(address), Array.from(capabilities));
|
|
5416
5416
|
}
|
|
5417
5417
|
catch (error) {
|
|
5418
|
-
logger$
|
|
5418
|
+
logger$1d.error('capability_replay_failed', {
|
|
5419
5419
|
address,
|
|
5420
5420
|
error: error.message,
|
|
5421
5421
|
});
|
|
@@ -5682,7 +5682,7 @@ class BindingManager {
|
|
|
5682
5682
|
}
|
|
5683
5683
|
}
|
|
5684
5684
|
|
|
5685
|
-
const logger$
|
|
5685
|
+
const logger$1c = getLogger('naylence.fame.node.response_context_manager');
|
|
5686
5686
|
function cloneSecurityContext(source) {
|
|
5687
5687
|
if (!source) {
|
|
5688
5688
|
return undefined;
|
|
@@ -5710,7 +5710,7 @@ class ResponseContextManager {
|
|
|
5710
5710
|
security: responseSecurity,
|
|
5711
5711
|
expectedResponseType: FameResponseType.NONE,
|
|
5712
5712
|
};
|
|
5713
|
-
logger$
|
|
5713
|
+
logger$1c.debug('created_response_context', {
|
|
5714
5714
|
request_id: requestEnvelope.id,
|
|
5715
5715
|
inherited_crypto_level: responseSecurity?.inboundCryptoLevel ?? null,
|
|
5716
5716
|
channel_id: responseSecurity?.cryptoChannelId ?? null,
|
|
@@ -5730,14 +5730,14 @@ class ResponseContextManager {
|
|
|
5730
5730
|
responseContext.fromSystemId = this.getId();
|
|
5731
5731
|
}
|
|
5732
5732
|
// Envelope-level metadata is intentionally omitted to defer to context usage.
|
|
5733
|
-
logger$
|
|
5733
|
+
logger$1c.debug('ensured_response_metadata', {
|
|
5734
5734
|
response_id: responseEnvelope.id,
|
|
5735
5735
|
request_id: requestEnvelope.id,
|
|
5736
5736
|
});
|
|
5737
5737
|
}
|
|
5738
5738
|
}
|
|
5739
5739
|
|
|
5740
|
-
const logger$
|
|
5740
|
+
const logger$1b = getLogger('naylence.fame.node.streaming_response_handler');
|
|
5741
5741
|
function isObject(value) {
|
|
5742
5742
|
return typeof value === 'object' && value !== null;
|
|
5743
5743
|
}
|
|
@@ -5856,12 +5856,12 @@ class StreamingResponseHandler {
|
|
|
5856
5856
|
}
|
|
5857
5857
|
async handleStreamingFameMessageResponses(responses, requestEnvelope, requestContext) {
|
|
5858
5858
|
const asyncResponses = toAsyncIterable(responses);
|
|
5859
|
-
logger$
|
|
5859
|
+
logger$1b.debug('handling_streaming_fame_message_responses', {
|
|
5860
5860
|
request_id: requestEnvelope.id,
|
|
5861
5861
|
});
|
|
5862
5862
|
for await (const response of asyncResponses) {
|
|
5863
5863
|
if (!response?.envelope) {
|
|
5864
|
-
logger$
|
|
5864
|
+
logger$1b.warning('invalid_streaming_response_type', {
|
|
5865
5865
|
request_id: requestEnvelope.id,
|
|
5866
5866
|
actual_type: typeof response,
|
|
5867
5867
|
});
|
|
@@ -5875,7 +5875,7 @@ class StreamingResponseHandler {
|
|
|
5875
5875
|
}
|
|
5876
5876
|
async handleStreamingResponse(result, requestEnvelope, requestContext, replyTo, requestId) {
|
|
5877
5877
|
const iterable = toAsyncIterable(result);
|
|
5878
|
-
logger$
|
|
5878
|
+
logger$1b.debug('handling_streaming_response', {
|
|
5879
5879
|
request_id: requestId,
|
|
5880
5880
|
reply_to: replyTo,
|
|
5881
5881
|
});
|
|
@@ -5886,7 +5886,7 @@ class StreamingResponseHandler {
|
|
|
5886
5886
|
await this.sendRpcResponse(null, requestEnvelope, requestContext, replyTo, requestId);
|
|
5887
5887
|
}
|
|
5888
5888
|
catch (error) {
|
|
5889
|
-
logger$
|
|
5889
|
+
logger$1b.error('streaming_response_handler_error', {
|
|
5890
5890
|
request_id: requestId,
|
|
5891
5891
|
error: error instanceof Error ? error.message : String(error),
|
|
5892
5892
|
});
|
|
@@ -5913,7 +5913,7 @@ class StreamingResponseHandler {
|
|
|
5913
5913
|
});
|
|
5914
5914
|
const responseContext = this.responseContextManager.createResponseContext(requestEnvelope, requestContext);
|
|
5915
5915
|
this.responseContextManager.ensureResponseMetadata(responseEnvelope, requestEnvelope, responseContext);
|
|
5916
|
-
logger$
|
|
5916
|
+
logger$1b.debug('sending_streaming_rpc_response', {
|
|
5917
5917
|
request_id: requestId,
|
|
5918
5918
|
response_envelope_id: responseEnvelope.id,
|
|
5919
5919
|
reply_to: replyTo,
|
|
@@ -5926,7 +5926,7 @@ class StreamingResponseHandler {
|
|
|
5926
5926
|
}
|
|
5927
5927
|
}
|
|
5928
5928
|
|
|
5929
|
-
const logger$
|
|
5929
|
+
const logger$1a = getLogger('naylence.fame.node.channel_polling_manager');
|
|
5930
5930
|
class ChannelPollingManager {
|
|
5931
5931
|
constructor(deliverWrapper, responseContextManager, streamingResponseHandler) {
|
|
5932
5932
|
this.deliverWrapper = deliverWrapper;
|
|
@@ -5934,7 +5934,7 @@ class ChannelPollingManager {
|
|
|
5934
5934
|
this.streamingResponseHandler = streamingResponseHandler;
|
|
5935
5935
|
}
|
|
5936
5936
|
async startPollingLoop(serviceName, channel, handler, stopState, pollTimeoutMs = DEFAULT_POLLING_TIMEOUT_MS) {
|
|
5937
|
-
logger$
|
|
5937
|
+
logger$1a.debug('poll_loop_started', {
|
|
5938
5938
|
recipient: serviceName,
|
|
5939
5939
|
});
|
|
5940
5940
|
try {
|
|
@@ -5942,7 +5942,7 @@ class ChannelPollingManager {
|
|
|
5942
5942
|
while (true) {
|
|
5943
5943
|
if (this.isStopRequested(stopState) && !draining) {
|
|
5944
5944
|
draining = true;
|
|
5945
|
-
logger$
|
|
5945
|
+
logger$1a.debug('poll_loop_draining_pending_messages', {
|
|
5946
5946
|
recipient: serviceName,
|
|
5947
5947
|
});
|
|
5948
5948
|
}
|
|
@@ -5952,7 +5952,7 @@ class ChannelPollingManager {
|
|
|
5952
5952
|
}
|
|
5953
5953
|
catch (error) {
|
|
5954
5954
|
if (error instanceof FameTransportClose) {
|
|
5955
|
-
logger$
|
|
5955
|
+
logger$1a.debug('channel_closed', {
|
|
5956
5956
|
recipient: serviceName,
|
|
5957
5957
|
message: error.message,
|
|
5958
5958
|
});
|
|
@@ -5965,7 +5965,7 @@ class ChannelPollingManager {
|
|
|
5965
5965
|
continue;
|
|
5966
5966
|
}
|
|
5967
5967
|
if (error instanceof Error && error.name === 'AbortError') {
|
|
5968
|
-
logger$
|
|
5968
|
+
logger$1a.debug('listener_cancelled', {
|
|
5969
5969
|
recipient: serviceName,
|
|
5970
5970
|
});
|
|
5971
5971
|
throw error;
|
|
@@ -5977,13 +5977,13 @@ class ChannelPollingManager {
|
|
|
5977
5977
|
continue;
|
|
5978
5978
|
}
|
|
5979
5979
|
if (error instanceof Error && error.message === 'Channel is closed') {
|
|
5980
|
-
logger$
|
|
5980
|
+
logger$1a.debug('channel_closed', {
|
|
5981
5981
|
recipient: serviceName,
|
|
5982
5982
|
});
|
|
5983
5983
|
break;
|
|
5984
5984
|
}
|
|
5985
5985
|
if (error instanceof Error && error.name === 'TaskCancelledError') {
|
|
5986
|
-
logger$
|
|
5986
|
+
logger$1a.debug('listener_cancelled', {
|
|
5987
5987
|
recipient: serviceName,
|
|
5988
5988
|
});
|
|
5989
5989
|
throw error;
|
|
@@ -5995,12 +5995,12 @@ class ChannelPollingManager {
|
|
|
5995
5995
|
continue;
|
|
5996
5996
|
}
|
|
5997
5997
|
if (error instanceof Error && error.message.includes('closed')) {
|
|
5998
|
-
logger$
|
|
5998
|
+
logger$1a.debug('channel_closed', {
|
|
5999
5999
|
recipient: serviceName,
|
|
6000
6000
|
});
|
|
6001
6001
|
break;
|
|
6002
6002
|
}
|
|
6003
|
-
logger$
|
|
6003
|
+
logger$1a.error('transport_error', {
|
|
6004
6004
|
recipient: serviceName,
|
|
6005
6005
|
error: error instanceof Error ? error.message : String(error),
|
|
6006
6006
|
});
|
|
@@ -6016,7 +6016,7 @@ class ChannelPollingManager {
|
|
|
6016
6016
|
}
|
|
6017
6017
|
}
|
|
6018
6018
|
finally {
|
|
6019
|
-
logger$
|
|
6019
|
+
logger$1a.debug('poll_loop_exiting', {
|
|
6020
6020
|
recipient: serviceName,
|
|
6021
6021
|
});
|
|
6022
6022
|
}
|
|
@@ -6029,7 +6029,7 @@ class ChannelPollingManager {
|
|
|
6029
6029
|
await this.processHandlerResult(result, envelope, deliveryContext, serviceName);
|
|
6030
6030
|
}
|
|
6031
6031
|
catch (error) {
|
|
6032
|
-
logger$
|
|
6032
|
+
logger$1a.error('handler_crashed', {
|
|
6033
6033
|
recipient: serviceName,
|
|
6034
6034
|
error: error instanceof Error ? error.message : String(error),
|
|
6035
6035
|
});
|
|
@@ -6043,7 +6043,7 @@ class ChannelPollingManager {
|
|
|
6043
6043
|
return;
|
|
6044
6044
|
}
|
|
6045
6045
|
if (this.streamingResponseHandler.isStreamingFameMessageResponse(result)) {
|
|
6046
|
-
logger$
|
|
6046
|
+
logger$1a.debug('handling_streaming_fame_message_responses', {
|
|
6047
6047
|
service_name: serviceName,
|
|
6048
6048
|
envelope_id: envelope.id,
|
|
6049
6049
|
});
|
|
@@ -6051,7 +6051,7 @@ class ChannelPollingManager {
|
|
|
6051
6051
|
}
|
|
6052
6052
|
}
|
|
6053
6053
|
async handleMessageResponse(response, requestEnvelope, requestContext, serviceName) {
|
|
6054
|
-
logger$
|
|
6054
|
+
logger$1a.debug('delivering_envelope_response_message', {
|
|
6055
6055
|
service_name: serviceName,
|
|
6056
6056
|
response_envelope_id: response.envelope.id,
|
|
6057
6057
|
});
|
|
@@ -6071,7 +6071,7 @@ class ChannelPollingManager {
|
|
|
6071
6071
|
}
|
|
6072
6072
|
}
|
|
6073
6073
|
|
|
6074
|
-
const logger$
|
|
6074
|
+
const logger$19 = getLogger('naylence.fame.node.rpc_server_handler');
|
|
6075
6075
|
function isPlainRecord$6(value) {
|
|
6076
6076
|
if (typeof value !== 'object' || value === null) {
|
|
6077
6077
|
return false;
|
|
@@ -6115,13 +6115,13 @@ class RPCServerHandler {
|
|
|
6115
6115
|
}
|
|
6116
6116
|
async handleRpcRequest(envelope, handlerContext, handler, serviceName) {
|
|
6117
6117
|
if (!this.isDataFrame(envelope.frame)) {
|
|
6118
|
-
logger$
|
|
6118
|
+
logger$19.warning('rpc_request_missing_data_frame', {
|
|
6119
6119
|
service_name: serviceName,
|
|
6120
6120
|
envelope_id: envelope.id,
|
|
6121
6121
|
});
|
|
6122
6122
|
return;
|
|
6123
6123
|
}
|
|
6124
|
-
logger$
|
|
6124
|
+
logger$19.debug('rpc_request_received', {
|
|
6125
6125
|
service_name: serviceName,
|
|
6126
6126
|
envelope_id: envelope.id,
|
|
6127
6127
|
trace_id: envelope.traceId,
|
|
@@ -6133,7 +6133,7 @@ class RPCServerHandler {
|
|
|
6133
6133
|
request = parseRequest(envelope.frame.payload);
|
|
6134
6134
|
params = cloneParams(request.params);
|
|
6135
6135
|
const paramKeys = Object.keys(params);
|
|
6136
|
-
logger$
|
|
6136
|
+
logger$19.debug('parsed_rpc_request', {
|
|
6137
6137
|
service_name: serviceName,
|
|
6138
6138
|
method: request.method,
|
|
6139
6139
|
request_id: request.id,
|
|
@@ -6142,7 +6142,7 @@ class RPCServerHandler {
|
|
|
6142
6142
|
});
|
|
6143
6143
|
}
|
|
6144
6144
|
catch (error) {
|
|
6145
|
-
logger$
|
|
6145
|
+
logger$19.warning('request_decode_error', {
|
|
6146
6146
|
service_name: serviceName,
|
|
6147
6147
|
envelope_id: envelope.id,
|
|
6148
6148
|
error: error instanceof Error ? error.message : String(error),
|
|
@@ -6150,7 +6150,7 @@ class RPCServerHandler {
|
|
|
6150
6150
|
return;
|
|
6151
6151
|
}
|
|
6152
6152
|
if (request.id == null) {
|
|
6153
|
-
logger$
|
|
6153
|
+
logger$19.warning('request_missing_id', {
|
|
6154
6154
|
service_name: serviceName,
|
|
6155
6155
|
envelope_id: envelope.id,
|
|
6156
6156
|
});
|
|
@@ -6158,7 +6158,7 @@ class RPCServerHandler {
|
|
|
6158
6158
|
}
|
|
6159
6159
|
const replyTo = this.resolveReplyTo(envelope, params);
|
|
6160
6160
|
if (!replyTo) {
|
|
6161
|
-
logger$
|
|
6161
|
+
logger$19.warning('missing_reply_to', {
|
|
6162
6162
|
service_name: serviceName,
|
|
6163
6163
|
envelope_id: envelope.id,
|
|
6164
6164
|
request_id: request.id,
|
|
@@ -6167,13 +6167,13 @@ class RPCServerHandler {
|
|
|
6167
6167
|
}
|
|
6168
6168
|
let handlerResult;
|
|
6169
6169
|
try {
|
|
6170
|
-
logger$
|
|
6170
|
+
logger$19.debug('calling_rpc_handler', {
|
|
6171
6171
|
service_name: serviceName,
|
|
6172
6172
|
method: request.method,
|
|
6173
6173
|
request_id: request.id,
|
|
6174
6174
|
});
|
|
6175
6175
|
handlerResult = await handler(request.method, params);
|
|
6176
|
-
logger$
|
|
6176
|
+
logger$19.debug('rpc_handler_returned', {
|
|
6177
6177
|
service_name: serviceName,
|
|
6178
6178
|
method: request.method,
|
|
6179
6179
|
request_id: request.id,
|
|
@@ -6182,7 +6182,7 @@ class RPCServerHandler {
|
|
|
6182
6182
|
});
|
|
6183
6183
|
}
|
|
6184
6184
|
catch (error) {
|
|
6185
|
-
logger$
|
|
6185
|
+
logger$19.error('rpc_handler_error', {
|
|
6186
6186
|
service_name: serviceName,
|
|
6187
6187
|
request_id: request.id,
|
|
6188
6188
|
envelope_id: envelope.id,
|
|
@@ -6192,7 +6192,7 @@ class RPCServerHandler {
|
|
|
6192
6192
|
return this.createTraditionalResponse(response, request.id, envelope, replyTo, handlerContext, serviceName);
|
|
6193
6193
|
}
|
|
6194
6194
|
if (isFameMessageResponse(handlerResult)) {
|
|
6195
|
-
logger$
|
|
6195
|
+
logger$19.debug('returning_response_message', {
|
|
6196
6196
|
service_name: serviceName,
|
|
6197
6197
|
request_id: request.id,
|
|
6198
6198
|
response_envelope_id: handlerResult.envelope.id,
|
|
@@ -6200,7 +6200,7 @@ class RPCServerHandler {
|
|
|
6200
6200
|
return handlerResult;
|
|
6201
6201
|
}
|
|
6202
6202
|
if (this.streamingResponseHandler.isStreamingResult(handlerResult)) {
|
|
6203
|
-
logger$
|
|
6203
|
+
logger$19.debug('handling_streaming_response', {
|
|
6204
6204
|
service_name: serviceName,
|
|
6205
6205
|
request_id: request.id,
|
|
6206
6206
|
envelope_id: envelope.id,
|
|
@@ -6229,7 +6229,7 @@ class RPCServerHandler {
|
|
|
6229
6229
|
return null;
|
|
6230
6230
|
}
|
|
6231
6231
|
async createTraditionalResponse(payload, requestId, requestEnvelope, replyTo, handlerContext, serviceName) {
|
|
6232
|
-
logger$
|
|
6232
|
+
logger$19.debug('creating_traditional_response_envelope', {
|
|
6233
6233
|
service_name: serviceName,
|
|
6234
6234
|
request_id: requestId,
|
|
6235
6235
|
envelope_id: requestEnvelope.id,
|
|
@@ -6253,7 +6253,7 @@ class RPCServerHandler {
|
|
|
6253
6253
|
if (requestEnvelope.id) {
|
|
6254
6254
|
responseContext.meta['response-to-id'] = requestEnvelope.id;
|
|
6255
6255
|
}
|
|
6256
|
-
logger$
|
|
6256
|
+
logger$19.debug('returning_traditional_response', {
|
|
6257
6257
|
service_name: serviceName,
|
|
6258
6258
|
request_id: requestId,
|
|
6259
6259
|
envelope_id: requestEnvelope.id,
|
|
@@ -6318,7 +6318,7 @@ function normalizeErrorCode(code) {
|
|
|
6318
6318
|
return code;
|
|
6319
6319
|
}
|
|
6320
6320
|
|
|
6321
|
-
const logger$
|
|
6321
|
+
const logger$18 = getLogger('naylence.fame.node.rpc_client_manager');
|
|
6322
6322
|
function isPlainRecord$5(value) {
|
|
6323
6323
|
if (typeof value !== 'object' || value === null) {
|
|
6324
6324
|
return false;
|
|
@@ -6535,7 +6535,7 @@ class RPCClientManager {
|
|
|
6535
6535
|
const metaReason = tracked.meta?.['nack_reason'];
|
|
6536
6536
|
const formattedMessage = formatDeliveryErrorMessage(typeof metaCode === 'string' ? metaCode : 'DELIVERY_ERROR', reason ??
|
|
6537
6537
|
(typeof metaReason === 'string' ? metaReason : undefined));
|
|
6538
|
-
logger$
|
|
6538
|
+
logger$18.debug('pending_request_rejected_by_delivery_nack', {
|
|
6539
6539
|
envelope_id: envelopeId,
|
|
6540
6540
|
request_id: requestId,
|
|
6541
6541
|
code: typeof metaCode === 'string' ? metaCode : 'DELIVERY_ERROR',
|
|
@@ -6558,7 +6558,7 @@ class RPCClientManager {
|
|
|
6558
6558
|
this.trackerWithEvents.removeEventHandler?.(this.trackerEventHandler);
|
|
6559
6559
|
}
|
|
6560
6560
|
catch (error) {
|
|
6561
|
-
logger$
|
|
6561
|
+
logger$18.debug('rpc_tracker_handler_remove_failed', {
|
|
6562
6562
|
error: error instanceof Error ? error.message : String(error),
|
|
6563
6563
|
});
|
|
6564
6564
|
}
|
|
@@ -6601,7 +6601,7 @@ class RPCClientManager {
|
|
|
6601
6601
|
this.rpcListenerAddress = await this.listenCallback(recipient, handler);
|
|
6602
6602
|
this.rpcBound = true;
|
|
6603
6603
|
this.boundPhysicalPath = currentPhysicalPath;
|
|
6604
|
-
logger$
|
|
6604
|
+
logger$18.debug('rpc_reply_listener_bound', {
|
|
6605
6605
|
reply_recipient: recipient,
|
|
6606
6606
|
reply_address: this.rpcReplyAddress?.toString(),
|
|
6607
6607
|
listener_address: this.rpcListenerAddress?.toString(),
|
|
@@ -6695,7 +6695,7 @@ class RPCClientManager {
|
|
|
6695
6695
|
const finalizePromise = this.notifyStreamClosed(envelopeId);
|
|
6696
6696
|
if (finalizePromise) {
|
|
6697
6697
|
finalizePromise.catch((notifyError) => {
|
|
6698
|
-
logger$
|
|
6698
|
+
logger$18.debug('stream_tracker_finalize_failed', {
|
|
6699
6699
|
request_id: requestId,
|
|
6700
6700
|
envelope_id: envelopeId,
|
|
6701
6701
|
error: notifyError instanceof Error
|
|
@@ -6756,7 +6756,7 @@ class RPCClientManager {
|
|
|
6756
6756
|
return iterator;
|
|
6757
6757
|
}
|
|
6758
6758
|
async sendRpcRequest(requestId, envelope, expectedResponseType, timeoutMs) {
|
|
6759
|
-
logger$
|
|
6759
|
+
logger$18.debug('sending_rpc_request', {
|
|
6760
6760
|
envp_id: envelope.id,
|
|
6761
6761
|
corr_id: envelope.corrId,
|
|
6762
6762
|
request_id: requestId,
|
|
@@ -6772,7 +6772,7 @@ class RPCClientManager {
|
|
|
6772
6772
|
}
|
|
6773
6773
|
}
|
|
6774
6774
|
catch (error) {
|
|
6775
|
-
logger$
|
|
6775
|
+
logger$18.warning('delivery_tracker_track_failed', {
|
|
6776
6776
|
request_id: requestId,
|
|
6777
6777
|
error: error instanceof Error ? error.message : String(error),
|
|
6778
6778
|
});
|
|
@@ -6785,14 +6785,14 @@ class RPCClientManager {
|
|
|
6785
6785
|
await this.deliverWrapper()(envelope, context);
|
|
6786
6786
|
}
|
|
6787
6787
|
async handleReplyEnvelope(envelope) {
|
|
6788
|
-
logger$
|
|
6788
|
+
logger$18.debug('handle_reply_envelope_received', {
|
|
6789
6789
|
envelope_id: envelope.id,
|
|
6790
6790
|
corr_id: envelope.corrId,
|
|
6791
6791
|
frame_type: envelope.frame?.['type'],
|
|
6792
6792
|
});
|
|
6793
6793
|
let requestId = envelope.corrId ?? envelope.id;
|
|
6794
6794
|
if (!requestId) {
|
|
6795
|
-
logger$
|
|
6795
|
+
logger$18.warning('reply_envelope_missing_corr_id', {
|
|
6796
6796
|
envelope_id: envelope.id,
|
|
6797
6797
|
});
|
|
6798
6798
|
return;
|
|
@@ -6810,12 +6810,12 @@ class RPCClientManager {
|
|
|
6810
6810
|
}
|
|
6811
6811
|
}
|
|
6812
6812
|
if (!entry) {
|
|
6813
|
-
logger$
|
|
6813
|
+
logger$18.debug('no_pending_request_for_reply', {
|
|
6814
6814
|
request_id: requestId,
|
|
6815
6815
|
});
|
|
6816
6816
|
return;
|
|
6817
6817
|
}
|
|
6818
|
-
logger$
|
|
6818
|
+
logger$18.debug('handle_reply_envelope', {
|
|
6819
6819
|
envelope_id: envelope.id,
|
|
6820
6820
|
request_id: requestId,
|
|
6821
6821
|
corr_id: envelope.corrId,
|
|
@@ -6828,7 +6828,7 @@ class RPCClientManager {
|
|
|
6828
6828
|
const ackIndicatesSuccess = frame.ok === true ||
|
|
6829
6829
|
(frame.ok === undefined && !frame.code && !frame.reason);
|
|
6830
6830
|
if (ackIndicatesSuccess) {
|
|
6831
|
-
logger$
|
|
6831
|
+
logger$18.debug('pending_request_delivery_acknowledged', {
|
|
6832
6832
|
request_id: requestId,
|
|
6833
6833
|
envelope_id: envelope.id,
|
|
6834
6834
|
ref_id: frame.refId ?? null,
|
|
@@ -6856,7 +6856,7 @@ class RPCClientManager {
|
|
|
6856
6856
|
entry.timer = null;
|
|
6857
6857
|
}
|
|
6858
6858
|
if (!this.isDataFrame(envelope.frame)) {
|
|
6859
|
-
logger$
|
|
6859
|
+
logger$18.warning('unexpected_reply_frame_type', {
|
|
6860
6860
|
request_id: requestId,
|
|
6861
6861
|
frame_type: envelope.frame?.['type'],
|
|
6862
6862
|
});
|
|
@@ -6922,7 +6922,7 @@ class RPCClientManager {
|
|
|
6922
6922
|
return;
|
|
6923
6923
|
}
|
|
6924
6924
|
Promise.resolve(this.deliveryTracker.onStreamItem(envelopeId, envelope)).catch((error) => {
|
|
6925
|
-
logger$
|
|
6925
|
+
logger$18.debug('stream_tracker_push_failed', {
|
|
6926
6926
|
envelope_id: envelopeId,
|
|
6927
6927
|
error: error instanceof Error ? error.message : String(error),
|
|
6928
6928
|
});
|
|
@@ -7037,7 +7037,7 @@ function normalizeMailbox(mailbox) {
|
|
|
7037
7037
|
return mailbox;
|
|
7038
7038
|
}
|
|
7039
7039
|
|
|
7040
|
-
const logger$
|
|
7040
|
+
const logger$17 = getLogger('naylence.fame.node.envelope_listener_manager');
|
|
7041
7041
|
const SYSTEM_INBOX$2 = '__sys__';
|
|
7042
7042
|
class EnvelopeListener {
|
|
7043
7043
|
constructor(stopFn, task) {
|
|
@@ -7045,7 +7045,7 @@ class EnvelopeListener {
|
|
|
7045
7045
|
this.task = task;
|
|
7046
7046
|
}
|
|
7047
7047
|
stop() {
|
|
7048
|
-
logger$
|
|
7048
|
+
logger$17.debug('stopping_listener', {
|
|
7049
7049
|
task_name: this.task.name,
|
|
7050
7050
|
});
|
|
7051
7051
|
try {
|
|
@@ -7053,7 +7053,7 @@ class EnvelopeListener {
|
|
|
7053
7053
|
if (maybeCleanup &&
|
|
7054
7054
|
typeof maybeCleanup.then === 'function') {
|
|
7055
7055
|
void maybeCleanup.catch((error) => {
|
|
7056
|
-
logger$
|
|
7056
|
+
logger$17.debug('listener_stop_cleanup_failed', {
|
|
7057
7057
|
task_name: this.task.name,
|
|
7058
7058
|
error: error instanceof Error ? error.message : String(error),
|
|
7059
7059
|
});
|
|
@@ -7061,7 +7061,7 @@ class EnvelopeListener {
|
|
|
7061
7061
|
}
|
|
7062
7062
|
}
|
|
7063
7063
|
catch (error) {
|
|
7064
|
-
logger$
|
|
7064
|
+
logger$17.debug('listener_stop_cleanup_failed', {
|
|
7065
7065
|
task_name: this.task.name,
|
|
7066
7066
|
error: error instanceof Error ? error.message : String(error),
|
|
7067
7067
|
});
|
|
@@ -7091,7 +7091,7 @@ class EnvelopeListenerManager extends TaskSpawner {
|
|
|
7091
7091
|
envelope.replyTo = formatAddress(SYSTEM_INBOX$2, this.nodeLike.physicalPath);
|
|
7092
7092
|
}
|
|
7093
7093
|
catch (error) {
|
|
7094
|
-
logger$
|
|
7094
|
+
logger$17.warning('default_reply_to_assignment_failed', {
|
|
7095
7095
|
envelope_id: envelope.id,
|
|
7096
7096
|
service_name: envelope.capabilities?.[0] ?? null,
|
|
7097
7097
|
error: error instanceof Error ? error.message : String(error),
|
|
@@ -7116,7 +7116,7 @@ class EnvelopeListenerManager extends TaskSpawner {
|
|
|
7116
7116
|
if (serviceName === SYSTEM_INBOX$2) {
|
|
7117
7117
|
continue;
|
|
7118
7118
|
}
|
|
7119
|
-
logger$
|
|
7119
|
+
logger$17.debug('stopping_listener_for_service', {
|
|
7120
7120
|
service_name: serviceName,
|
|
7121
7121
|
});
|
|
7122
7122
|
entry.listener.stop();
|
|
@@ -7126,7 +7126,7 @@ class EnvelopeListenerManager extends TaskSpawner {
|
|
|
7126
7126
|
catch (error) {
|
|
7127
7127
|
if (!(error instanceof Error) ||
|
|
7128
7128
|
error.name !== 'TaskCancelledError') {
|
|
7129
|
-
logger$
|
|
7129
|
+
logger$17.debug('listener_task_stopped', {
|
|
7130
7130
|
service_name: serviceName,
|
|
7131
7131
|
error: error instanceof Error ? error.message : String(error),
|
|
7132
7132
|
});
|
|
@@ -7134,7 +7134,7 @@ class EnvelopeListenerManager extends TaskSpawner {
|
|
|
7134
7134
|
}
|
|
7135
7135
|
}
|
|
7136
7136
|
if (systemEntry) {
|
|
7137
|
-
logger$
|
|
7137
|
+
logger$17.debug('stopping_listener_for_service', {
|
|
7138
7138
|
service_name: SYSTEM_INBOX$2,
|
|
7139
7139
|
});
|
|
7140
7140
|
systemEntry.listener.stop();
|
|
@@ -7144,7 +7144,7 @@ class EnvelopeListenerManager extends TaskSpawner {
|
|
|
7144
7144
|
catch (error) {
|
|
7145
7145
|
if (!(error instanceof Error) ||
|
|
7146
7146
|
error.name !== 'TaskCancelledError') {
|
|
7147
|
-
logger$
|
|
7147
|
+
logger$17.debug('listener_task_stopped', {
|
|
7148
7148
|
service_name: SYSTEM_INBOX$2,
|
|
7149
7149
|
error: error instanceof Error ? error.message : String(error),
|
|
7150
7150
|
});
|
|
@@ -7161,13 +7161,13 @@ class EnvelopeListenerManager extends TaskSpawner {
|
|
|
7161
7161
|
}
|
|
7162
7162
|
async recoverUnhandledInboundEnvelopes() {
|
|
7163
7163
|
if (typeof this.deliveryTracker.listInbound !== 'function') {
|
|
7164
|
-
logger$
|
|
7164
|
+
logger$17.debug('delivery_tracker_missing_inbound_listing');
|
|
7165
7165
|
return;
|
|
7166
7166
|
}
|
|
7167
7167
|
const failedInbound = await this.deliveryTracker.listInbound((env) => env.status === EnvelopeStatus.RECEIVED ||
|
|
7168
7168
|
env.status === EnvelopeStatus.FAILED_TO_HANDLE);
|
|
7169
7169
|
if (!failedInbound.length) {
|
|
7170
|
-
logger$
|
|
7170
|
+
logger$17.debug('no_failed_inbound_envelopes_to_recover');
|
|
7171
7171
|
return;
|
|
7172
7172
|
}
|
|
7173
7173
|
const grouped = new Map();
|
|
@@ -7184,7 +7184,7 @@ class EnvelopeListenerManager extends TaskSpawner {
|
|
|
7184
7184
|
this.pendingRecoveryEnvelopes.set(serviceName, envelopes);
|
|
7185
7185
|
}
|
|
7186
7186
|
});
|
|
7187
|
-
logger$
|
|
7187
|
+
logger$17.debug('discovered_failed_inbound_envelopes', {
|
|
7188
7188
|
total: failedInbound.length,
|
|
7189
7189
|
services: Array.from(grouped.keys()),
|
|
7190
7190
|
});
|
|
@@ -7194,7 +7194,7 @@ class EnvelopeListenerManager extends TaskSpawner {
|
|
|
7194
7194
|
const pollTimeoutMs = options.pollTimeoutMs ??
|
|
7195
7195
|
options.poll_timeout_ms ??
|
|
7196
7196
|
DEFAULT_POLLING_TIMEOUT_MS;
|
|
7197
|
-
logger$
|
|
7197
|
+
logger$17.debug('listen_start', {
|
|
7198
7198
|
recipient: serviceName,
|
|
7199
7199
|
poll_timeout_ms: pollTimeoutMs ?? DEFAULT_POLLING_TIMEOUT_MS,
|
|
7200
7200
|
});
|
|
@@ -7225,7 +7225,7 @@ class EnvelopeListenerManager extends TaskSpawner {
|
|
|
7225
7225
|
tracked?.mailboxType === MailboxType.OUTBOX ||
|
|
7226
7226
|
envelope.frame?.['type'] === 'DeliveryAck';
|
|
7227
7227
|
if (!shouldInvoke) {
|
|
7228
|
-
logger$
|
|
7228
|
+
logger$17.debug('skipping_listener_handler', {
|
|
7229
7229
|
recipient: serviceName,
|
|
7230
7230
|
envelope_id: envelope.id,
|
|
7231
7231
|
tracked_status: tracked?.status,
|
|
@@ -7239,13 +7239,13 @@ class EnvelopeListenerManager extends TaskSpawner {
|
|
|
7239
7239
|
? undefined
|
|
7240
7240
|
: (tracked ?? undefined);
|
|
7241
7241
|
if (trackedForHandler && trackedForHandler.attempt > 0) {
|
|
7242
|
-
logger$
|
|
7242
|
+
logger$17.info('resuming_handler_retry_after_restart', {
|
|
7243
7243
|
envelope_id: envelope.id,
|
|
7244
7244
|
current_attempts: trackedForHandler.attempt,
|
|
7245
7245
|
service_name: serviceName,
|
|
7246
7246
|
});
|
|
7247
7247
|
}
|
|
7248
|
-
logger$
|
|
7248
|
+
logger$17.debug('forwarding_to_listener_handler', {
|
|
7249
7249
|
recipient: serviceName,
|
|
7250
7250
|
envelope_id: envelope.id,
|
|
7251
7251
|
frame_type: envelope.frame?.['type'],
|
|
@@ -7264,7 +7264,7 @@ class EnvelopeListenerManager extends TaskSpawner {
|
|
|
7264
7264
|
await channel.send(null);
|
|
7265
7265
|
}
|
|
7266
7266
|
catch (error) {
|
|
7267
|
-
logger$
|
|
7267
|
+
logger$17.debug('listener_stop_signal_failed', {
|
|
7268
7268
|
service_name: serviceName,
|
|
7269
7269
|
error: error instanceof Error ? error.message : String(error),
|
|
7270
7270
|
});
|
|
@@ -7273,7 +7273,7 @@ class EnvelopeListenerManager extends TaskSpawner {
|
|
|
7273
7273
|
await this.listenersLock.runExclusive(async () => {
|
|
7274
7274
|
const existing = this.listeners.get(serviceName);
|
|
7275
7275
|
if (existing) {
|
|
7276
|
-
logger$
|
|
7276
|
+
logger$17.debug('replacing_envelope_listener', { recipient: serviceName });
|
|
7277
7277
|
existing.listener.stop();
|
|
7278
7278
|
try {
|
|
7279
7279
|
await existing.listener.task.promise;
|
|
@@ -7291,13 +7291,13 @@ class EnvelopeListenerManager extends TaskSpawner {
|
|
|
7291
7291
|
return binding.address;
|
|
7292
7292
|
}
|
|
7293
7293
|
async listenRpc(serviceName, handler, options = {}) {
|
|
7294
|
-
logger$
|
|
7294
|
+
logger$17.debug('rpc_listen_start', { service_name: serviceName });
|
|
7295
7295
|
const rpcHandler = async (envelope, context) => {
|
|
7296
7296
|
const result = await this.rpcServerHandler.handleRpcRequest(envelope, context, handler, serviceName);
|
|
7297
7297
|
return result ?? null;
|
|
7298
7298
|
};
|
|
7299
7299
|
const address = await this.listen(serviceName, rpcHandler, options);
|
|
7300
|
-
logger$
|
|
7300
|
+
logger$17.debug('rpc_listen_bound', {
|
|
7301
7301
|
service_name: serviceName,
|
|
7302
7302
|
address: address.toString(),
|
|
7303
7303
|
});
|
|
@@ -7366,12 +7366,12 @@ class EnvelopeListenerManager extends TaskSpawner {
|
|
|
7366
7366
|
return cached;
|
|
7367
7367
|
});
|
|
7368
7368
|
if (!envelopes.length) {
|
|
7369
|
-
logger$
|
|
7369
|
+
logger$17.debug('no_cached_recovery_for_service', {
|
|
7370
7370
|
service_name: serviceName,
|
|
7371
7371
|
});
|
|
7372
7372
|
return;
|
|
7373
7373
|
}
|
|
7374
|
-
logger$
|
|
7374
|
+
logger$17.debug('recovering_unhandled_envelopes_on_listen', {
|
|
7375
7375
|
service_name: serviceName,
|
|
7376
7376
|
count: envelopes.length,
|
|
7377
7377
|
envelope_ids: envelopes.map((trackedEnvelope) => trackedEnvelope.envelopeId),
|
|
@@ -7382,7 +7382,7 @@ class EnvelopeListenerManager extends TaskSpawner {
|
|
|
7382
7382
|
async recoverServiceEnvelopes(serviceName, envelopes, handler) {
|
|
7383
7383
|
for (const tracked of envelopes) {
|
|
7384
7384
|
try {
|
|
7385
|
-
logger$
|
|
7385
|
+
logger$17.warning('recovering_unhandled_envelope', {
|
|
7386
7386
|
envelope_id: tracked.envelopeId,
|
|
7387
7387
|
service_name: serviceName,
|
|
7388
7388
|
current_attempts: tracked.attempt,
|
|
@@ -7391,13 +7391,13 @@ class EnvelopeListenerManager extends TaskSpawner {
|
|
|
7391
7391
|
const originalEnvelope = tracked.originalEnvelope;
|
|
7392
7392
|
const receiverPolicy = this.nodeLike.deliveryPolicy?.receiverRetryPolicy ?? undefined;
|
|
7393
7393
|
await this.executeHandlerWithRetries(handler, originalEnvelope, undefined, receiverPolicy, tracked, serviceName);
|
|
7394
|
-
logger$
|
|
7394
|
+
logger$17.debug('envelope_recovery_completed', {
|
|
7395
7395
|
envelope_id: tracked.envelopeId,
|
|
7396
7396
|
service_name: serviceName,
|
|
7397
7397
|
});
|
|
7398
7398
|
}
|
|
7399
7399
|
catch (error) {
|
|
7400
|
-
logger$
|
|
7400
|
+
logger$17.error('envelope_recovery_failed', {
|
|
7401
7401
|
envelope_id: tracked.envelopeId,
|
|
7402
7402
|
service_name: serviceName,
|
|
7403
7403
|
error: error instanceof Error ? error.message : String(error),
|
|
@@ -7443,7 +7443,7 @@ class EnvelopeListenerManager extends TaskSpawner {
|
|
|
7443
7443
|
await this.deliveryTracker.onEnvelopeHandled(trackedEnvelope);
|
|
7444
7444
|
}
|
|
7445
7445
|
if (currentAttempt > 0) {
|
|
7446
|
-
logger$
|
|
7446
|
+
logger$17.info('handler_retry_succeeded', {
|
|
7447
7447
|
envelope_id: envelope.id,
|
|
7448
7448
|
attempt: currentAttempt + 1,
|
|
7449
7449
|
total_attempts: currentAttempt + 1,
|
|
@@ -7459,7 +7459,7 @@ class EnvelopeListenerManager extends TaskSpawner {
|
|
|
7459
7459
|
await this.deliveryTracker.onEnvelopeHandleFailed(inboxName, trackedEnvelope, context, error instanceof Error ? error : new Error(String(error)), isFinalAttempt);
|
|
7460
7460
|
}
|
|
7461
7461
|
if (isFinalAttempt) {
|
|
7462
|
-
logger$
|
|
7462
|
+
logger$17.error('handler_execution_failed_exhausted_retries', {
|
|
7463
7463
|
envelope_id: envelope.id,
|
|
7464
7464
|
total_attempts: attemptNumber,
|
|
7465
7465
|
max_retries: retryPolicy?.maxRetries ?? 0,
|
|
@@ -7468,7 +7468,7 @@ class EnvelopeListenerManager extends TaskSpawner {
|
|
|
7468
7468
|
break;
|
|
7469
7469
|
}
|
|
7470
7470
|
const delayMs = retryPolicy?.nextDelayMs(attemptNumber) ?? 0;
|
|
7471
|
-
logger$
|
|
7471
|
+
logger$17.warning('handler_execution_failed_will_retry', {
|
|
7472
7472
|
envelope_id: envelope.id,
|
|
7473
7473
|
attempt: attemptNumber,
|
|
7474
7474
|
max_retries: retryPolicy?.maxRetries ?? 0,
|
|
@@ -7498,7 +7498,7 @@ class EnvelopeListenerManager extends TaskSpawner {
|
|
|
7498
7498
|
}
|
|
7499
7499
|
}
|
|
7500
7500
|
|
|
7501
|
-
const logger$
|
|
7501
|
+
const logger$16 = getLogger('naylence.fame.delivery.default_delivery_tracker');
|
|
7502
7502
|
const STREAM_END = Symbol('stream-end');
|
|
7503
7503
|
const SWEEPER_TICK = Symbol('tracker-sweeper-tick');
|
|
7504
7504
|
function createDeferred$2() {
|
|
@@ -7717,7 +7717,7 @@ class DefaultDeliveryTracker extends TaskSpawner {
|
|
|
7717
7717
|
const expectedResponseType = options.expectedResponseType;
|
|
7718
7718
|
const tracked = await this.lock.runExclusive(async () => {
|
|
7719
7719
|
if (this.ackFutures.has(envelope.id)) {
|
|
7720
|
-
logger$
|
|
7720
|
+
logger$16.debug('tracker_envelope_already_tracked', {
|
|
7721
7721
|
envp_id: envelope.id,
|
|
7722
7722
|
});
|
|
7723
7723
|
return null;
|
|
@@ -7727,7 +7727,7 @@ class DefaultDeliveryTracker extends TaskSpawner {
|
|
|
7727
7727
|
if (expectedResponseType & FameResponseType.REPLY ||
|
|
7728
7728
|
expectedResponseType & FameResponseType.STREAM) {
|
|
7729
7729
|
if (existingEnvId && existingEnvId !== envelope.id) {
|
|
7730
|
-
logger$
|
|
7730
|
+
logger$16.debug('envelope_already_tracked_for_replies', {
|
|
7731
7731
|
envp_id: envelope.id,
|
|
7732
7732
|
corr_id: corrId,
|
|
7733
7733
|
expected_response_type: expectedResponseType,
|
|
@@ -7776,7 +7776,7 @@ class DefaultDeliveryTracker extends TaskSpawner {
|
|
|
7776
7776
|
return null;
|
|
7777
7777
|
}
|
|
7778
7778
|
await this.scheduleTimer(tracked, options.retryPolicy ?? null, options.retryHandler ?? null);
|
|
7779
|
-
logger$
|
|
7779
|
+
logger$16.debug('tracker_registered_envelope', {
|
|
7780
7780
|
envp_id: envelope.id,
|
|
7781
7781
|
corr_id: tracked.originalEnvelope.corrId,
|
|
7782
7782
|
expected_response: tracked.expectedResponseType,
|
|
@@ -7800,21 +7800,21 @@ class DefaultDeliveryTracker extends TaskSpawner {
|
|
|
7800
7800
|
return this.awaitEnvelopeFuture(envelopeId, FameResponseType.REPLY | FameResponseType.STREAM, future, timeoutMs);
|
|
7801
7801
|
}
|
|
7802
7802
|
async onEnvelopeDelivered(inboxName, envelope, context) {
|
|
7803
|
-
logger$
|
|
7803
|
+
logger$16.debug('envelope_delivered', {
|
|
7804
7804
|
envp_id: envelope.id,
|
|
7805
7805
|
corr_id: envelope.corrId,
|
|
7806
7806
|
rtype: envelope.rtype ?? FameResponseType.NONE,
|
|
7807
7807
|
frame_type: envelope.frame?.type ?? 'unknown',
|
|
7808
7808
|
});
|
|
7809
7809
|
if (!envelope.corrId) {
|
|
7810
|
-
logger$
|
|
7810
|
+
logger$16.debug('envelope_delivered_no_corr_id', {
|
|
7811
7811
|
envelope_id: envelope.id,
|
|
7812
7812
|
});
|
|
7813
7813
|
return null;
|
|
7814
7814
|
}
|
|
7815
7815
|
if (this.isDeliveryAckFrame(envelope.frame)) {
|
|
7816
7816
|
if (!envelope.frame.refId) {
|
|
7817
|
-
logger$
|
|
7817
|
+
logger$16.debug('envelope_delivered_no_ref_id', {
|
|
7818
7818
|
envelope_id: envelope.id,
|
|
7819
7819
|
});
|
|
7820
7820
|
return null;
|
|
@@ -7851,7 +7851,7 @@ class DefaultDeliveryTracker extends TaskSpawner {
|
|
|
7851
7851
|
await inbox.set(envelope.id, tracked);
|
|
7852
7852
|
}
|
|
7853
7853
|
else {
|
|
7854
|
-
logger$
|
|
7854
|
+
logger$16.debug('tracker_duplicate_envelope_already_handled', {
|
|
7855
7855
|
envp_id: envelope.id,
|
|
7856
7856
|
status: tracked.status,
|
|
7857
7857
|
});
|
|
@@ -7893,7 +7893,7 @@ class DefaultDeliveryTracker extends TaskSpawner {
|
|
|
7893
7893
|
}
|
|
7894
7894
|
if (isFinalFailure) {
|
|
7895
7895
|
envelope.status = EnvelopeStatus.FAILED_TO_HANDLE;
|
|
7896
|
-
logger$
|
|
7896
|
+
logger$16.error('envelope_handle_failed_final', {
|
|
7897
7897
|
inbox_name: inboxName,
|
|
7898
7898
|
envp_id: envelope.originalEnvelope.id,
|
|
7899
7899
|
error: error?.message ?? 'unknown',
|
|
@@ -7904,7 +7904,7 @@ class DefaultDeliveryTracker extends TaskSpawner {
|
|
|
7904
7904
|
await inbox.delete(envelope.originalEnvelope.id);
|
|
7905
7905
|
return;
|
|
7906
7906
|
}
|
|
7907
|
-
logger$
|
|
7907
|
+
logger$16.warning('envelope_handle_failed_retry', {
|
|
7908
7908
|
inbox_name: inboxName,
|
|
7909
7909
|
envp_id: envelope.originalEnvelope.id,
|
|
7910
7910
|
error: error?.message ?? 'unknown',
|
|
@@ -7949,14 +7949,14 @@ class DefaultDeliveryTracker extends TaskSpawner {
|
|
|
7949
7949
|
if (handledViaFuture) {
|
|
7950
7950
|
await this.markDoneSince(this.ackFutures, refId, this.ackDoneSince);
|
|
7951
7951
|
await this.clearTimer(refId);
|
|
7952
|
-
logger$
|
|
7952
|
+
logger$16.debug('tracker_ack_resolved_without_tracked_envelope', {
|
|
7953
7953
|
envp_id: envelope.id,
|
|
7954
7954
|
ref_id: refId,
|
|
7955
7955
|
corr_id: envelope.corrId,
|
|
7956
7956
|
});
|
|
7957
7957
|
return;
|
|
7958
7958
|
}
|
|
7959
|
-
logger$
|
|
7959
|
+
logger$16.debug('tracker_ack_for_unknown_envelope', {
|
|
7960
7960
|
envp_id: envelope.id,
|
|
7961
7961
|
ref_id: refId,
|
|
7962
7962
|
corr_id: envelope.corrId,
|
|
@@ -7964,7 +7964,7 @@ class DefaultDeliveryTracker extends TaskSpawner {
|
|
|
7964
7964
|
return;
|
|
7965
7965
|
}
|
|
7966
7966
|
if (tracked.originalEnvelope.corrId !== envelope.corrId) {
|
|
7967
|
-
logger$
|
|
7967
|
+
logger$16.debug('tracker_ack_corr_id_mismatch', {
|
|
7968
7968
|
envp_id: envelope.id,
|
|
7969
7969
|
expected_corr_id: tracked.originalEnvelope.corrId,
|
|
7970
7970
|
actual_corr_id: envelope.corrId,
|
|
@@ -7989,7 +7989,7 @@ class DefaultDeliveryTracker extends TaskSpawner {
|
|
|
7989
7989
|
for (const handler of this.eventHandlers) {
|
|
7990
7990
|
await handler.onEnvelopeAcked?.(tracked);
|
|
7991
7991
|
}
|
|
7992
|
-
logger$
|
|
7992
|
+
logger$16.debug('tracker_envelope_acked', {
|
|
7993
7993
|
envp_id: tracked.originalEnvelope.id,
|
|
7994
7994
|
});
|
|
7995
7995
|
}
|
|
@@ -8006,13 +8006,13 @@ class DefaultDeliveryTracker extends TaskSpawner {
|
|
|
8006
8006
|
const outbox = this.ensureOutbox();
|
|
8007
8007
|
const tracked = await outbox.get(envelope.frame.refId);
|
|
8008
8008
|
if (!tracked) {
|
|
8009
|
-
logger$
|
|
8009
|
+
logger$16.debug('tracker_nack_for_unknown_envelope', {
|
|
8010
8010
|
envp_id: envelope.id,
|
|
8011
8011
|
});
|
|
8012
8012
|
return;
|
|
8013
8013
|
}
|
|
8014
8014
|
if (tracked.originalEnvelope.corrId !== envelope.corrId) {
|
|
8015
|
-
logger$
|
|
8015
|
+
logger$16.debug('tracker_nack_corr_id_mismatch', {
|
|
8016
8016
|
envp_id: envelope.id,
|
|
8017
8017
|
expected_corr_id: tracked.originalEnvelope.corrId,
|
|
8018
8018
|
actual_corr_id: envelope.corrId,
|
|
@@ -8054,7 +8054,7 @@ class DefaultDeliveryTracker extends TaskSpawner {
|
|
|
8054
8054
|
for (const handler of this.eventHandlers) {
|
|
8055
8055
|
await handler.onEnvelopeNacked?.(tracked, ackFrame.reason ?? null);
|
|
8056
8056
|
}
|
|
8057
|
-
logger$
|
|
8057
|
+
logger$16.debug('tracker_envelope_nacked', {
|
|
8058
8058
|
envp_id: tracked.originalEnvelope.id,
|
|
8059
8059
|
reason: ackFrame.reason,
|
|
8060
8060
|
});
|
|
@@ -8101,7 +8101,7 @@ class DefaultDeliveryTracker extends TaskSpawner {
|
|
|
8101
8101
|
for (const handler of this.eventHandlers) {
|
|
8102
8102
|
await handler.onEnvelopeReplied?.(trackedEnvelope, envelope);
|
|
8103
8103
|
}
|
|
8104
|
-
logger$
|
|
8104
|
+
logger$16.debug('tracked_envelope_replied', {
|
|
8105
8105
|
envp_id: trackedEnvelope.originalEnvelope.id,
|
|
8106
8106
|
corr_id: envelope.corrId,
|
|
8107
8107
|
});
|
|
@@ -8175,7 +8175,7 @@ class DefaultDeliveryTracker extends TaskSpawner {
|
|
|
8175
8175
|
async addToInboxDlq(trackedEnvelope, reason = null) {
|
|
8176
8176
|
const dlq = this.inboxDlq;
|
|
8177
8177
|
if (!dlq) {
|
|
8178
|
-
logger$
|
|
8178
|
+
logger$16.error('dlq_not_initialized', {
|
|
8179
8179
|
envp_id: trackedEnvelope.originalEnvelope.id,
|
|
8180
8180
|
});
|
|
8181
8181
|
return;
|
|
@@ -8190,7 +8190,7 @@ class DefaultDeliveryTracker extends TaskSpawner {
|
|
|
8190
8190
|
const deadLetteredAt = Date.now();
|
|
8191
8191
|
setMetaWithLegacy(trackedEnvelope.meta, 'deadLetteredAtMs', 'dead_lettered_at_ms', deadLetteredAt);
|
|
8192
8192
|
await dlq.set(trackedEnvelope.originalEnvelope.id, trackedEnvelope);
|
|
8193
|
-
logger$
|
|
8193
|
+
logger$16.warning('envelope_moved_to_dlq', {
|
|
8194
8194
|
envp_id: trackedEnvelope.originalEnvelope.id,
|
|
8195
8195
|
service_name: trackedEnvelope.serviceName,
|
|
8196
8196
|
});
|
|
@@ -8219,7 +8219,7 @@ class DefaultDeliveryTracker extends TaskSpawner {
|
|
|
8219
8219
|
const toDelete = Object.entries(items).filter(([, value]) => predicate ? predicate(value) : true);
|
|
8220
8220
|
await Promise.all(toDelete.map(([key]) => dlq.delete(key)));
|
|
8221
8221
|
if (toDelete.length) {
|
|
8222
|
-
logger$
|
|
8222
|
+
logger$16.debug('dlq_purged', { count: toDelete.length });
|
|
8223
8223
|
}
|
|
8224
8224
|
return toDelete.length;
|
|
8225
8225
|
}
|
|
@@ -8272,11 +8272,11 @@ class DefaultDeliveryTracker extends TaskSpawner {
|
|
|
8272
8272
|
}
|
|
8273
8273
|
this.futuresSweeper = null;
|
|
8274
8274
|
}
|
|
8275
|
-
logger$
|
|
8275
|
+
logger$16.debug('tracker_cleanup_completed');
|
|
8276
8276
|
}
|
|
8277
8277
|
async recoverPending() {
|
|
8278
8278
|
const pending = await this.listPending();
|
|
8279
|
-
logger$
|
|
8279
|
+
logger$16.debug('tracker_recovering_pending', { count: pending.length });
|
|
8280
8280
|
await this.lock.runExclusive(async () => {
|
|
8281
8281
|
for (const tracked of pending) {
|
|
8282
8282
|
if (tracked.expectedResponseType & FameResponseType.ACK) {
|
|
@@ -8302,7 +8302,7 @@ class DefaultDeliveryTracker extends TaskSpawner {
|
|
|
8302
8302
|
for (const tracked of pending) {
|
|
8303
8303
|
await this.scheduleTimer(tracked, null, null);
|
|
8304
8304
|
}
|
|
8305
|
-
logger$
|
|
8305
|
+
logger$16.debug('tracker_recovery_completed', { count: pending.length });
|
|
8306
8306
|
}
|
|
8307
8307
|
ensureOutbox() {
|
|
8308
8308
|
if (!this.outbox) {
|
|
@@ -8317,7 +8317,7 @@ class DefaultDeliveryTracker extends TaskSpawner {
|
|
|
8317
8317
|
return this.inbox;
|
|
8318
8318
|
}
|
|
8319
8319
|
async waitForPendingAcks() {
|
|
8320
|
-
logger$
|
|
8320
|
+
logger$16.debug('tracker_node_preparing_to_stop_waiting_for_pending_acks');
|
|
8321
8321
|
const outbox = this.outbox;
|
|
8322
8322
|
if (!outbox) {
|
|
8323
8323
|
return;
|
|
@@ -8329,7 +8329,7 @@ class DefaultDeliveryTracker extends TaskSpawner {
|
|
|
8329
8329
|
continue;
|
|
8330
8330
|
}
|
|
8331
8331
|
if (!future.done) {
|
|
8332
|
-
logger$
|
|
8332
|
+
logger$16.debug('tracker_pending_ack_future_detected', {
|
|
8333
8333
|
envelope_id: envelopeId,
|
|
8334
8334
|
});
|
|
8335
8335
|
pending.push({ envelopeId, future });
|
|
@@ -8337,10 +8337,10 @@ class DefaultDeliveryTracker extends TaskSpawner {
|
|
|
8337
8337
|
}
|
|
8338
8338
|
});
|
|
8339
8339
|
if (!pending.length) {
|
|
8340
|
-
logger$
|
|
8340
|
+
logger$16.debug('tracker_no_pending_acks_to_wait_for');
|
|
8341
8341
|
return;
|
|
8342
8342
|
}
|
|
8343
|
-
logger$
|
|
8343
|
+
logger$16.debug('tracker_waiting_for_pending_acks', { count: pending.length });
|
|
8344
8344
|
for (const entry of pending) {
|
|
8345
8345
|
if (!entry) {
|
|
8346
8346
|
continue;
|
|
@@ -8357,19 +8357,19 @@ class DefaultDeliveryTracker extends TaskSpawner {
|
|
|
8357
8357
|
}
|
|
8358
8358
|
try {
|
|
8359
8359
|
await this.awaitWithTimeout(entry.future.promise, remainingMs);
|
|
8360
|
-
logger$
|
|
8360
|
+
logger$16.debug('tracker_received_ack', {
|
|
8361
8361
|
envelope_id: entry.envelopeId,
|
|
8362
8362
|
});
|
|
8363
8363
|
await outbox.delete(entry.envelopeId);
|
|
8364
8364
|
}
|
|
8365
8365
|
catch (error) {
|
|
8366
8366
|
if (error instanceof Error && error.name === 'TimeoutError') {
|
|
8367
|
-
logger$
|
|
8367
|
+
logger$16.debug('tracker_ack_timeout_expired', {
|
|
8368
8368
|
envelope_id: entry.envelopeId,
|
|
8369
8369
|
});
|
|
8370
8370
|
}
|
|
8371
8371
|
else {
|
|
8372
|
-
logger$
|
|
8372
|
+
logger$16.debug('tracker_ack_wait_error', {
|
|
8373
8373
|
envelope_id: entry.envelopeId,
|
|
8374
8374
|
error: error instanceof Error ? error.message : String(error),
|
|
8375
8375
|
});
|
|
@@ -8377,13 +8377,13 @@ class DefaultDeliveryTracker extends TaskSpawner {
|
|
|
8377
8377
|
}
|
|
8378
8378
|
}
|
|
8379
8379
|
catch (error) {
|
|
8380
|
-
logger$
|
|
8380
|
+
logger$16.error('tracker_error_waiting_for_ack', {
|
|
8381
8381
|
envelope_id: entry.envelopeId,
|
|
8382
8382
|
error: error instanceof Error ? error.message : String(error),
|
|
8383
8383
|
});
|
|
8384
8384
|
}
|
|
8385
8385
|
}
|
|
8386
|
-
logger$
|
|
8386
|
+
logger$16.debug('tracker_finished_waiting_for_pending_acks');
|
|
8387
8387
|
}
|
|
8388
8388
|
async waitForPendingAckDispatches() {
|
|
8389
8389
|
while (this.pendingAckDispatches.size > 0) {
|
|
@@ -8441,7 +8441,7 @@ class DefaultDeliveryTracker extends TaskSpawner {
|
|
|
8441
8441
|
for (const handler of this.eventHandlers) {
|
|
8442
8442
|
await handler.onEnvelopeTimeout?.(currentTracked);
|
|
8443
8443
|
}
|
|
8444
|
-
logger$
|
|
8444
|
+
logger$16.debug('tracker_envelope_timed_out', {
|
|
8445
8445
|
envp_id: tracked.originalEnvelope.id,
|
|
8446
8446
|
});
|
|
8447
8447
|
return;
|
|
@@ -8454,7 +8454,7 @@ class DefaultDeliveryTracker extends TaskSpawner {
|
|
|
8454
8454
|
currentTracked.timeoutAtMs = nextTimeoutAt;
|
|
8455
8455
|
await outbox.set(tracked.originalEnvelope.id, currentTracked);
|
|
8456
8456
|
await this.scheduleTimer(currentTracked, retryPolicy, retryHandler);
|
|
8457
|
-
logger$
|
|
8457
|
+
logger$16.debug('tracker_retry_deferred_during_shutdown', {
|
|
8458
8458
|
envp_id: tracked.originalEnvelope.id,
|
|
8459
8459
|
defer_ms: shutdownDeferMs,
|
|
8460
8460
|
});
|
|
@@ -8477,7 +8477,7 @@ class DefaultDeliveryTracker extends TaskSpawner {
|
|
|
8477
8477
|
});
|
|
8478
8478
|
}
|
|
8479
8479
|
await this.scheduleTimer(currentTracked, retryPolicy, retryHandler);
|
|
8480
|
-
logger$
|
|
8480
|
+
logger$16.debug('envelope_delivery_retry_scheduled', {
|
|
8481
8481
|
envp_id: tracked.originalEnvelope.id,
|
|
8482
8482
|
attempt: currentTracked.attempt,
|
|
8483
8483
|
max_retries: retryPolicy.maxRetries,
|
|
@@ -8489,7 +8489,7 @@ class DefaultDeliveryTracker extends TaskSpawner {
|
|
|
8489
8489
|
currentTracked.timeoutAtMs = currentTracked.overallTimeoutAtMs;
|
|
8490
8490
|
await outbox.set(tracked.originalEnvelope.id, currentTracked);
|
|
8491
8491
|
await this.scheduleTimer(currentTracked, retryPolicy, retryHandler);
|
|
8492
|
-
logger$
|
|
8492
|
+
logger$16.debug('envelope_retries_exhausted_waiting_until_overall_timeout', {
|
|
8493
8493
|
envp_id: tracked.originalEnvelope.id,
|
|
8494
8494
|
attempt: currentTracked.attempt,
|
|
8495
8495
|
overall_timeout_at_ms: currentTracked.overallTimeoutAtMs,
|
|
@@ -8509,7 +8509,7 @@ class DefaultDeliveryTracker extends TaskSpawner {
|
|
|
8509
8509
|
for (const handler of this.eventHandlers) {
|
|
8510
8510
|
await handler.onEnvelopeTimeout?.(currentTracked);
|
|
8511
8511
|
}
|
|
8512
|
-
logger$
|
|
8512
|
+
logger$16.debug('tracker_envelope_timed_out', {
|
|
8513
8513
|
envp_id: tracked.originalEnvelope.id,
|
|
8514
8514
|
});
|
|
8515
8515
|
}
|
|
@@ -8517,7 +8517,7 @@ class DefaultDeliveryTracker extends TaskSpawner {
|
|
|
8517
8517
|
if (error instanceof TaskCancelledError) {
|
|
8518
8518
|
return;
|
|
8519
8519
|
}
|
|
8520
|
-
logger$
|
|
8520
|
+
logger$16.error('tracker_timer_error', {
|
|
8521
8521
|
envp_id: tracked.originalEnvelope.id,
|
|
8522
8522
|
error: error instanceof Error ? error.message : String(error),
|
|
8523
8523
|
});
|
|
@@ -8572,7 +8572,7 @@ class DefaultDeliveryTracker extends TaskSpawner {
|
|
|
8572
8572
|
if (timeoutSeconds !== null) {
|
|
8573
8573
|
return await this.awaitWithTimeout(future.promise, timeoutSeconds);
|
|
8574
8574
|
}
|
|
8575
|
-
logger$
|
|
8575
|
+
logger$16.debug('await_envelope_no_timeout_wait', {
|
|
8576
8576
|
envelope_id: envelopeId,
|
|
8577
8577
|
});
|
|
8578
8578
|
return await future.promise;
|
|
@@ -8581,7 +8581,7 @@ class DefaultDeliveryTracker extends TaskSpawner {
|
|
|
8581
8581
|
if (error instanceof Error && error.name !== 'TimeoutError') {
|
|
8582
8582
|
throw error;
|
|
8583
8583
|
}
|
|
8584
|
-
logger$
|
|
8584
|
+
logger$16.error('await_envelope_timeout_error', {
|
|
8585
8585
|
envelope_id: envelopeId,
|
|
8586
8586
|
timeout_ms: timeoutSeconds,
|
|
8587
8587
|
future_done: false,
|
|
@@ -8742,7 +8742,7 @@ class DefaultDeliveryTracker extends TaskSpawner {
|
|
|
8742
8742
|
this.replyDoneSince.delete(envId);
|
|
8743
8743
|
}
|
|
8744
8744
|
});
|
|
8745
|
-
logger$
|
|
8745
|
+
logger$16.debug('tracker_swept_completed_futures', {
|
|
8746
8746
|
ack_removed: toRemoveAck.length,
|
|
8747
8747
|
reply_removed: toRemoveReply.length,
|
|
8748
8748
|
grace_secs: this.futGcGraceSecs,
|
|
@@ -8756,7 +8756,7 @@ class DefaultDeliveryTracker extends TaskSpawner {
|
|
|
8756
8756
|
if (error instanceof Error && error.name === 'TimeoutError') {
|
|
8757
8757
|
continue;
|
|
8758
8758
|
}
|
|
8759
|
-
logger$
|
|
8759
|
+
logger$16.error('tracker_sweeper_error', {
|
|
8760
8760
|
error: error instanceof Error ? error.message : String(error),
|
|
8761
8761
|
});
|
|
8762
8762
|
}
|
|
@@ -8787,14 +8787,14 @@ class DefaultDeliveryTracker extends TaskSpawner {
|
|
|
8787
8787
|
}
|
|
8788
8788
|
const node = this.node;
|
|
8789
8789
|
if (!envelope.replyTo) {
|
|
8790
|
-
logger$
|
|
8790
|
+
logger$16.error('cannot_send_ack_no_reply_to', { envp_id: envelope.id });
|
|
8791
8791
|
return;
|
|
8792
8792
|
}
|
|
8793
8793
|
if (!envelope.corrId) {
|
|
8794
|
-
logger$
|
|
8794
|
+
logger$16.error('cannot_send_ack_no_corr_id', { envp_id: envelope.id });
|
|
8795
8795
|
return;
|
|
8796
8796
|
}
|
|
8797
|
-
logger$
|
|
8797
|
+
logger$16.debug('tracker_sending_ack', {
|
|
8798
8798
|
envp_id: envelope.id,
|
|
8799
8799
|
ref_id: envelope.id,
|
|
8800
8800
|
to: envelope.replyTo,
|
|
@@ -8814,7 +8814,7 @@ class DefaultDeliveryTracker extends TaskSpawner {
|
|
|
8814
8814
|
.send(ackEnvelope)
|
|
8815
8815
|
.then(() => undefined)
|
|
8816
8816
|
.catch((error) => {
|
|
8817
|
-
logger$
|
|
8817
|
+
logger$16.error('tracker_ack_dispatch_failed', {
|
|
8818
8818
|
envp_id: envelope.id,
|
|
8819
8819
|
error: error instanceof Error ? error.message : String(error),
|
|
8820
8820
|
});
|
|
@@ -8900,7 +8900,7 @@ class AsyncEvent {
|
|
|
8900
8900
|
}
|
|
8901
8901
|
}
|
|
8902
8902
|
|
|
8903
|
-
const logger$
|
|
8903
|
+
const logger$15 = getLogger('naylence.fame.node.root_session_manager');
|
|
8904
8904
|
function resolveOption$1(options, primary, ...aliases) {
|
|
8905
8905
|
const record = options;
|
|
8906
8906
|
const primaryKey = primary;
|
|
@@ -8981,7 +8981,7 @@ class RootSessionManager extends TaskSpawner {
|
|
|
8981
8981
|
this.onAdmissionFailed =
|
|
8982
8982
|
typeof onAdmissionFailed === 'function' ? onAdmissionFailed : undefined;
|
|
8983
8983
|
this.enableContinuousRefresh = enableContinuousRefresh ?? true;
|
|
8984
|
-
logger$
|
|
8984
|
+
logger$15.debug('created_root_session_manager');
|
|
8985
8985
|
}
|
|
8986
8986
|
get isReady() {
|
|
8987
8987
|
return this.readyEvent.isSet();
|
|
@@ -9006,7 +9006,7 @@ class RootSessionManager extends TaskSpawner {
|
|
|
9006
9006
|
if (this.admissionTask) {
|
|
9007
9007
|
return;
|
|
9008
9008
|
}
|
|
9009
|
-
logger$
|
|
9009
|
+
logger$15.debug('root_session_manager_starting');
|
|
9010
9010
|
this.stopEvent.clear();
|
|
9011
9011
|
this.readyEvent.clear();
|
|
9012
9012
|
const taskName = `root-admission-${this.admissionEpoch}`;
|
|
@@ -9026,10 +9026,10 @@ class RootSessionManager extends TaskSpawner {
|
|
|
9026
9026
|
await this.admissionTask.promise;
|
|
9027
9027
|
throw new FameConnectError('Root session manager failed to become ready');
|
|
9028
9028
|
}
|
|
9029
|
-
logger$
|
|
9029
|
+
logger$15.debug('root_session_manager_started');
|
|
9030
9030
|
}
|
|
9031
9031
|
async stop() {
|
|
9032
|
-
logger$
|
|
9032
|
+
logger$15.debug('root_session_manager_stopping');
|
|
9033
9033
|
this.stopEvent.set();
|
|
9034
9034
|
if (this.admissionTask) {
|
|
9035
9035
|
this.admissionTask.cancel();
|
|
@@ -9041,7 +9041,7 @@ class RootSessionManager extends TaskSpawner {
|
|
|
9041
9041
|
await this.consumeTask(this.expiryGuardTask);
|
|
9042
9042
|
this.expiryGuardTask = null;
|
|
9043
9043
|
}
|
|
9044
|
-
logger$
|
|
9044
|
+
logger$15.debug('root_session_manager_stopped');
|
|
9045
9045
|
}
|
|
9046
9046
|
async awaitReady(timeoutMs) {
|
|
9047
9047
|
if (this.isReady) {
|
|
@@ -9082,12 +9082,12 @@ class RootSessionManager extends TaskSpawner {
|
|
|
9082
9082
|
await this.onEpochChange(epoch);
|
|
9083
9083
|
}
|
|
9084
9084
|
else {
|
|
9085
|
-
logger$
|
|
9085
|
+
logger$15.debug('epoch_change_ignored_no_handler', { epoch });
|
|
9086
9086
|
}
|
|
9087
9087
|
}
|
|
9088
9088
|
static createForRootSentinel(node, admissionClient, requestedLogicals = [], enableContinuousRefresh = true, onEpochChange) {
|
|
9089
9089
|
const handleWelcome = async (frame) => {
|
|
9090
|
-
logger$
|
|
9090
|
+
logger$15.info('root_admission_successful', {
|
|
9091
9091
|
system_id: frame.systemId,
|
|
9092
9092
|
assigned_path: frame.assignedPath ?? null,
|
|
9093
9093
|
accepted_logicals: frame.acceptedLogicals ?? [],
|
|
@@ -9098,12 +9098,12 @@ class RootSessionManager extends TaskSpawner {
|
|
|
9098
9098
|
? grant.purpose
|
|
9099
9099
|
: undefined;
|
|
9100
9100
|
if (purpose) {
|
|
9101
|
-
logger$
|
|
9101
|
+
logger$15.debug('received_admission_grant', { purpose });
|
|
9102
9102
|
}
|
|
9103
9103
|
}
|
|
9104
9104
|
};
|
|
9105
9105
|
const handleFailure = async (error) => {
|
|
9106
|
-
logger$
|
|
9106
|
+
logger$15.error('root_admission_failed_permanently', {
|
|
9107
9107
|
error: error.message,
|
|
9108
9108
|
});
|
|
9109
9109
|
};
|
|
@@ -9132,10 +9132,10 @@ class RootSessionManager extends TaskSpawner {
|
|
|
9132
9132
|
this.readyEvent.set();
|
|
9133
9133
|
}
|
|
9134
9134
|
if (this.hadSuccessfulAdmission) {
|
|
9135
|
-
logger$
|
|
9135
|
+
logger$15.debug('root_admission_refreshed');
|
|
9136
9136
|
}
|
|
9137
9137
|
else {
|
|
9138
|
-
logger$
|
|
9138
|
+
logger$15.debug('root_admission_completed');
|
|
9139
9139
|
}
|
|
9140
9140
|
this.hadSuccessfulAdmission = true;
|
|
9141
9141
|
delay = RootSessionManager.BACKOFF_INITIAL;
|
|
@@ -9144,7 +9144,7 @@ class RootSessionManager extends TaskSpawner {
|
|
|
9144
9144
|
await this.startExpiryGuard(welcomeFrame);
|
|
9145
9145
|
const expiryTriggered = await this.waitForExpiryOrStop();
|
|
9146
9146
|
if (expiryTriggered && !this.stopEvent.isSet()) {
|
|
9147
|
-
logger$
|
|
9147
|
+
logger$15.debug('performing_scheduled_re_admission');
|
|
9148
9148
|
continue;
|
|
9149
9149
|
}
|
|
9150
9150
|
}
|
|
@@ -9156,7 +9156,7 @@ class RootSessionManager extends TaskSpawner {
|
|
|
9156
9156
|
}
|
|
9157
9157
|
const errorObject = error instanceof Error ? error : new Error(String(error));
|
|
9158
9158
|
const willRetry = attempts < RootSessionManager.RETRY_MAX_ATTEMPTS;
|
|
9159
|
-
logger$
|
|
9159
|
+
logger$15.warning('root_admission_failed', {
|
|
9160
9160
|
error: errorObject.message,
|
|
9161
9161
|
attempt: attempts,
|
|
9162
9162
|
will_retry: willRetry,
|
|
@@ -9174,7 +9174,7 @@ class RootSessionManager extends TaskSpawner {
|
|
|
9174
9174
|
}
|
|
9175
9175
|
}
|
|
9176
9176
|
if (attempts >= RootSessionManager.RETRY_MAX_ATTEMPTS) {
|
|
9177
|
-
logger$
|
|
9177
|
+
logger$15.error('root_admission_max_attempts_exceeded', {
|
|
9178
9178
|
max_attempts: RootSessionManager.RETRY_MAX_ATTEMPTS,
|
|
9179
9179
|
});
|
|
9180
9180
|
}
|
|
@@ -9251,7 +9251,7 @@ class RootSessionManager extends TaskSpawner {
|
|
|
9251
9251
|
}
|
|
9252
9252
|
async expiryGuard(welcomeFrame, signal) {
|
|
9253
9253
|
if (!welcomeFrame.expiresAt) {
|
|
9254
|
-
logger$
|
|
9254
|
+
logger$15.debug('no_admission_expiry_configured');
|
|
9255
9255
|
await Promise.race([this.stopEvent.wait(), this.waitForAbort(signal)]);
|
|
9256
9256
|
return;
|
|
9257
9257
|
}
|
|
@@ -9260,7 +9260,7 @@ class RootSessionManager extends TaskSpawner {
|
|
|
9260
9260
|
let delaySeconds = (expiresAt.getTime() - now.getTime()) / 1000 -
|
|
9261
9261
|
RootSessionManager.JWT_REFRESH_SAFETY;
|
|
9262
9262
|
delaySeconds = Math.max(delaySeconds, 0);
|
|
9263
|
-
logger$
|
|
9263
|
+
logger$15.debug('admission_expiry_guard_started', {
|
|
9264
9264
|
welcome_expires_at: expiresAt.toISOString(),
|
|
9265
9265
|
delay_seconds: delaySeconds,
|
|
9266
9266
|
refresh_safety_seconds: RootSessionManager.JWT_REFRESH_SAFETY,
|
|
@@ -9269,7 +9269,7 @@ class RootSessionManager extends TaskSpawner {
|
|
|
9269
9269
|
if (this.stopEvent.isSet() || signal?.aborted) {
|
|
9270
9270
|
return;
|
|
9271
9271
|
}
|
|
9272
|
-
logger$
|
|
9272
|
+
logger$15.debug('admission_expiry_triggered_refresh', {
|
|
9273
9273
|
expires_at: expiresAt.toISOString(),
|
|
9274
9274
|
current_time: new Date().toISOString(),
|
|
9275
9275
|
seconds_before_expiry: RootSessionManager.JWT_REFRESH_SAFETY,
|
|
@@ -9284,7 +9284,7 @@ class RootSessionManager extends TaskSpawner {
|
|
|
9284
9284
|
return;
|
|
9285
9285
|
}
|
|
9286
9286
|
const errorObject = error instanceof Error ? error : new Error(String(error));
|
|
9287
|
-
logger$
|
|
9287
|
+
logger$15.debug('background_task_error', {
|
|
9288
9288
|
task_name: task.name,
|
|
9289
9289
|
error: errorObject.message,
|
|
9290
9290
|
});
|
|
@@ -9325,7 +9325,7 @@ RootSessionManager.JWT_REFRESH_SAFETY = 60.0;
|
|
|
9325
9325
|
* Concrete implementations must define supported grant types and provide grant-to-connector
|
|
9326
9326
|
* conversion logic.
|
|
9327
9327
|
*/
|
|
9328
|
-
const logger$
|
|
9328
|
+
const logger$14 = getLogger('naylence.fame.connector.connector_factory');
|
|
9329
9329
|
const CONNECTOR_FACTORY_BASE_TYPE = 'ConnectorFactory';
|
|
9330
9330
|
/**
|
|
9331
9331
|
* Abstract base class for connector factories
|
|
@@ -9361,7 +9361,7 @@ class ConnectorFactory {
|
|
|
9361
9361
|
}
|
|
9362
9362
|
}
|
|
9363
9363
|
catch (error) {
|
|
9364
|
-
logger$
|
|
9364
|
+
logger$14.warning(`Failed to evaluate grant with factory ${factoryInfo.constructor.name}: ${error}`);
|
|
9365
9365
|
continue;
|
|
9366
9366
|
}
|
|
9367
9367
|
}
|
|
@@ -9404,7 +9404,7 @@ class ConnectorFactory {
|
|
|
9404
9404
|
}
|
|
9405
9405
|
}
|
|
9406
9406
|
catch (error) {
|
|
9407
|
-
logger$
|
|
9407
|
+
logger$14.warning(`Failed to create connector config from grant: ${error}`);
|
|
9408
9408
|
continue;
|
|
9409
9409
|
}
|
|
9410
9410
|
}
|
|
@@ -9471,20 +9471,20 @@ class ConnectorFactory {
|
|
|
9471
9471
|
return existing;
|
|
9472
9472
|
}
|
|
9473
9473
|
if (existing && !this.isGrantAware(existing)) {
|
|
9474
|
-
logger$
|
|
9474
|
+
logger$14.warning(`Factory ${factoryInfo.constructor.name} is registered under ${CONNECTOR_FACTORY_BASE_TYPE} but is missing grant conversion APIs; skipping.`);
|
|
9475
9475
|
return null;
|
|
9476
9476
|
}
|
|
9477
9477
|
try {
|
|
9478
9478
|
const instance = new factoryInfo.constructor();
|
|
9479
9479
|
if (!this.isGrantAware(instance)) {
|
|
9480
|
-
logger$
|
|
9480
|
+
logger$14.warning(`Factory ${factoryInfo.constructor.name} does not implement grant conversion APIs required by ${CONNECTOR_FACTORY_BASE_TYPE}; skipping.`);
|
|
9481
9481
|
return null;
|
|
9482
9482
|
}
|
|
9483
9483
|
factoryInfo.instance = instance;
|
|
9484
9484
|
return instance;
|
|
9485
9485
|
}
|
|
9486
9486
|
catch (error) {
|
|
9487
|
-
logger$
|
|
9487
|
+
logger$14.warning(`Failed to instantiate factory ${factoryInfo.constructor.name} while resolving grant conversion APIs: ${error}`);
|
|
9488
9488
|
return null;
|
|
9489
9489
|
}
|
|
9490
9490
|
}
|
|
@@ -9587,7 +9587,7 @@ class TaskCancellationError extends Error {
|
|
|
9587
9587
|
this.name = 'TaskCancellationError';
|
|
9588
9588
|
}
|
|
9589
9589
|
}
|
|
9590
|
-
const logger$
|
|
9590
|
+
const logger$13 = getLogger('naylence.fame.connector.base_async_connector');
|
|
9591
9591
|
// Environment variables
|
|
9592
9592
|
const ENV_VAR_FAME_FLOW_CONTROL = 'FAME_FLOW_CONTROL';
|
|
9593
9593
|
const FLOW_CONTROL_ENABLED = typeof process !== 'undefined' && process?.env
|
|
@@ -9670,7 +9670,7 @@ class BaseAsyncConnector extends TaskSpawner {
|
|
|
9670
9670
|
if (this._state !== newState) {
|
|
9671
9671
|
const oldState = this._state;
|
|
9672
9672
|
this._state = newState;
|
|
9673
|
-
logger$
|
|
9673
|
+
logger$13.debug('connector_state_transition', {
|
|
9674
9674
|
connector_id: this._connectorFlowId,
|
|
9675
9675
|
old_state: oldState,
|
|
9676
9676
|
new_state: newState,
|
|
@@ -9709,12 +9709,12 @@ class BaseAsyncConnector extends TaskSpawner {
|
|
|
9709
9709
|
* Stop the connector gracefully
|
|
9710
9710
|
*/
|
|
9711
9711
|
async stop() {
|
|
9712
|
-
logger$
|
|
9712
|
+
logger$13.debug('stopping_connector', {
|
|
9713
9713
|
current_state: this._state,
|
|
9714
9714
|
connector_id: this._connectorFlowId,
|
|
9715
9715
|
});
|
|
9716
9716
|
if (!ConnectorStateUtils.canStop(this._state)) {
|
|
9717
|
-
logger$
|
|
9717
|
+
logger$13.debug('connector_stop_already_stopped', {
|
|
9718
9718
|
current_state: this._state,
|
|
9719
9719
|
connector_id: this._connectorFlowId,
|
|
9720
9720
|
});
|
|
@@ -9725,7 +9725,7 @@ class BaseAsyncConnector extends TaskSpawner {
|
|
|
9725
9725
|
if (this._lastError) {
|
|
9726
9726
|
throw this._lastError;
|
|
9727
9727
|
}
|
|
9728
|
-
logger$
|
|
9728
|
+
logger$13.debug('connector_stopped', {
|
|
9729
9729
|
current_state: this._state,
|
|
9730
9730
|
connector_id: this._connectorFlowId,
|
|
9731
9731
|
});
|
|
@@ -9734,19 +9734,19 @@ class BaseAsyncConnector extends TaskSpawner {
|
|
|
9734
9734
|
* Pause the connector (suspends heartbeat and housekeeping, but keeps connection alive)
|
|
9735
9735
|
*/
|
|
9736
9736
|
async pause() {
|
|
9737
|
-
logger$
|
|
9737
|
+
logger$13.debug('pausing_connector', {
|
|
9738
9738
|
current_state: this._state,
|
|
9739
9739
|
connector_id: this._connectorFlowId,
|
|
9740
9740
|
});
|
|
9741
9741
|
if (this._state !== ConnectorState.STARTED) {
|
|
9742
|
-
logger$
|
|
9742
|
+
logger$13.debug('connector_pause_invalid_state', {
|
|
9743
9743
|
current_state: this._state,
|
|
9744
9744
|
connector_id: this._connectorFlowId,
|
|
9745
9745
|
});
|
|
9746
9746
|
return;
|
|
9747
9747
|
}
|
|
9748
9748
|
this._setState(ConnectorState.PAUSED);
|
|
9749
|
-
logger$
|
|
9749
|
+
logger$13.debug('connector_paused', {
|
|
9750
9750
|
current_state: this._state,
|
|
9751
9751
|
connector_id: this._connectorFlowId,
|
|
9752
9752
|
});
|
|
@@ -9755,19 +9755,19 @@ class BaseAsyncConnector extends TaskSpawner {
|
|
|
9755
9755
|
* Resume the connector from paused state
|
|
9756
9756
|
*/
|
|
9757
9757
|
async resume() {
|
|
9758
|
-
logger$
|
|
9758
|
+
logger$13.debug('resuming_connector', {
|
|
9759
9759
|
current_state: this._state,
|
|
9760
9760
|
connector_id: this._connectorFlowId,
|
|
9761
9761
|
});
|
|
9762
9762
|
if (this._state !== ConnectorState.PAUSED) {
|
|
9763
|
-
logger$
|
|
9763
|
+
logger$13.debug('connector_resume_invalid_state', {
|
|
9764
9764
|
current_state: this._state,
|
|
9765
9765
|
connector_id: this._connectorFlowId,
|
|
9766
9766
|
});
|
|
9767
9767
|
return;
|
|
9768
9768
|
}
|
|
9769
9769
|
this._setState(ConnectorState.STARTED);
|
|
9770
|
-
logger$
|
|
9770
|
+
logger$13.debug('connector_resumed', {
|
|
9771
9771
|
current_state: this._state,
|
|
9772
9772
|
connector_id: this._connectorFlowId,
|
|
9773
9773
|
});
|
|
@@ -9777,7 +9777,7 @@ class BaseAsyncConnector extends TaskSpawner {
|
|
|
9777
9777
|
*/
|
|
9778
9778
|
async close(code = 1000, reason = 'normal closure') {
|
|
9779
9779
|
if (!ConnectorStateUtils.canClose(this._state)) {
|
|
9780
|
-
logger$
|
|
9780
|
+
logger$13.warning('connector_close_invalid_state', {
|
|
9781
9781
|
current_state: this._state,
|
|
9782
9782
|
connector_id: this._connectorFlowId,
|
|
9783
9783
|
});
|
|
@@ -9858,7 +9858,7 @@ class BaseAsyncConnector extends TaskSpawner {
|
|
|
9858
9858
|
// Add to queue and notify send loop
|
|
9859
9859
|
this._sendQueue.push(raw);
|
|
9860
9860
|
// Log for debugging
|
|
9861
|
-
logger$
|
|
9861
|
+
logger$13.debug('send_envelope_queued', {
|
|
9862
9862
|
queue_length: this._sendQueue.length,
|
|
9863
9863
|
max_queue_size: this._maxQueueSize,
|
|
9864
9864
|
});
|
|
@@ -9907,14 +9907,14 @@ class BaseAsyncConnector extends TaskSpawner {
|
|
|
9907
9907
|
const item = this._sendQueue[0];
|
|
9908
9908
|
if (!item)
|
|
9909
9909
|
continue;
|
|
9910
|
-
logger$
|
|
9910
|
+
logger$13.debug('send_loop_processing_item', {
|
|
9911
9911
|
queue_length_before_send: this._sendQueue.length,
|
|
9912
9912
|
});
|
|
9913
9913
|
// Send through transport (this may block)
|
|
9914
9914
|
await this._transportSendBytes(item);
|
|
9915
9915
|
// Only remove from queue after successful send
|
|
9916
9916
|
this._sendQueue.shift();
|
|
9917
|
-
logger$
|
|
9917
|
+
logger$13.debug('send_loop_item_sent', {
|
|
9918
9918
|
queue_length_after_send: this._sendQueue.length,
|
|
9919
9919
|
});
|
|
9920
9920
|
}
|
|
@@ -9927,14 +9927,14 @@ class BaseAsyncConnector extends TaskSpawner {
|
|
|
9927
9927
|
}
|
|
9928
9928
|
else if (error instanceof TaskCancellationError) {
|
|
9929
9929
|
// Task cancellation is expected during shutdown - log as debug, not critical
|
|
9930
|
-
logger$
|
|
9930
|
+
logger$13.debug('send loop cancelled', {
|
|
9931
9931
|
connector: this.constructor.name,
|
|
9932
9932
|
reason: error.message,
|
|
9933
9933
|
});
|
|
9934
9934
|
// Don't re-throw - this is normal during shutdown
|
|
9935
9935
|
}
|
|
9936
9936
|
else {
|
|
9937
|
-
logger$
|
|
9937
|
+
logger$13.critical('unexpected exception in send loop', {
|
|
9938
9938
|
connector: this.constructor.name,
|
|
9939
9939
|
error: error instanceof Error ? error.message : String(error),
|
|
9940
9940
|
});
|
|
@@ -9975,7 +9975,7 @@ class BaseAsyncConnector extends TaskSpawner {
|
|
|
9975
9975
|
env = JSON.parse(jsonStr);
|
|
9976
9976
|
}
|
|
9977
9977
|
catch (error) {
|
|
9978
|
-
logger$
|
|
9978
|
+
logger$13.error('Invalid envelope', {
|
|
9979
9979
|
message: message.toString(),
|
|
9980
9980
|
error: error instanceof Error ? error.message : String(error),
|
|
9981
9981
|
});
|
|
@@ -9999,7 +9999,7 @@ class BaseAsyncConnector extends TaskSpawner {
|
|
|
9999
9999
|
};
|
|
10000
10000
|
await withEnvelopeContextAsync(envelopeContext, async () => {
|
|
10001
10001
|
const prettyEnvelope = prettyModel$1(env);
|
|
10002
|
-
logger$
|
|
10002
|
+
logger$13.trace('connector_received_envelope', {
|
|
10003
10003
|
envelope: env,
|
|
10004
10004
|
pretty: prettyEnvelope,
|
|
10005
10005
|
});
|
|
@@ -10028,7 +10028,7 @@ class BaseAsyncConnector extends TaskSpawner {
|
|
|
10028
10028
|
if (error instanceof TaskCancellationError) {
|
|
10029
10029
|
throw error;
|
|
10030
10030
|
}
|
|
10031
|
-
logger$
|
|
10031
|
+
logger$13.error('handler_failed', {
|
|
10032
10032
|
error: error instanceof Error ? error.message : String(error),
|
|
10033
10033
|
envelope_id: env.id ?? null,
|
|
10034
10034
|
trace_id: env.traceId ?? null,
|
|
@@ -10049,14 +10049,14 @@ class BaseAsyncConnector extends TaskSpawner {
|
|
|
10049
10049
|
}
|
|
10050
10050
|
else if (error instanceof TaskCancellationError) {
|
|
10051
10051
|
// Task cancellation is expected during shutdown - log as debug, not critical
|
|
10052
|
-
logger$
|
|
10052
|
+
logger$13.debug('receive loop cancelled', {
|
|
10053
10053
|
connector: this.constructor.name,
|
|
10054
10054
|
reason: error.message,
|
|
10055
10055
|
});
|
|
10056
10056
|
// Don't re-throw - this is normal during shutdown
|
|
10057
10057
|
}
|
|
10058
10058
|
else {
|
|
10059
|
-
logger$
|
|
10059
|
+
logger$13.critical('unexpected_error_in recv_loop', {
|
|
10060
10060
|
error: error instanceof Error ? error.message : String(error),
|
|
10061
10061
|
});
|
|
10062
10062
|
throw error;
|
|
@@ -10072,7 +10072,7 @@ class BaseAsyncConnector extends TaskSpawner {
|
|
|
10072
10072
|
async _maybeEmitCredit(flowId, traceId) {
|
|
10073
10073
|
const remainingCredits = this._flowCtrl.getCredits(flowId);
|
|
10074
10074
|
const needsRefill = this._flowCtrl.needsRefill(flowId);
|
|
10075
|
-
logger$
|
|
10075
|
+
logger$13.debug('maybe_emit_credit_check', {
|
|
10076
10076
|
connector_id: this._connectorFlowId,
|
|
10077
10077
|
flow_id: flowId,
|
|
10078
10078
|
trace_id: traceId ?? null,
|
|
@@ -10088,7 +10088,7 @@ class BaseAsyncConnector extends TaskSpawner {
|
|
|
10088
10088
|
}
|
|
10089
10089
|
const delta = this._initialWindow;
|
|
10090
10090
|
this._flowCtrl.addCredits(flowId, delta);
|
|
10091
|
-
logger$
|
|
10091
|
+
logger$13.debug('maybe_emit_credit_emit', {
|
|
10092
10092
|
connector_id: this._connectorFlowId,
|
|
10093
10093
|
flow_id: flowId,
|
|
10094
10094
|
trace_id: traceId ?? null,
|
|
@@ -10108,7 +10108,7 @@ class BaseAsyncConnector extends TaskSpawner {
|
|
|
10108
10108
|
});
|
|
10109
10109
|
try {
|
|
10110
10110
|
await this.send(ackEnv);
|
|
10111
|
-
logger$
|
|
10111
|
+
logger$13.debug('maybe_emit_credit_sent', {
|
|
10112
10112
|
connector_id: this._connectorFlowId,
|
|
10113
10113
|
flow_id: flowId,
|
|
10114
10114
|
trace_id: traceId ?? null,
|
|
@@ -10116,7 +10116,7 @@ class BaseAsyncConnector extends TaskSpawner {
|
|
|
10116
10116
|
});
|
|
10117
10117
|
}
|
|
10118
10118
|
catch (error) {
|
|
10119
|
-
logger$
|
|
10119
|
+
logger$13.error('maybe_emit_credit_send_failed', {
|
|
10120
10120
|
connector_id: this._connectorFlowId,
|
|
10121
10121
|
flow_id: flowId,
|
|
10122
10122
|
trace_id: traceId ?? null,
|
|
@@ -10141,13 +10141,13 @@ class BaseAsyncConnector extends TaskSpawner {
|
|
|
10141
10141
|
*/
|
|
10142
10142
|
async _shutdown(code, reason, gracePeriod, exc) {
|
|
10143
10143
|
if (this._closed) {
|
|
10144
|
-
logger$
|
|
10144
|
+
logger$13.debug('shutdown_already_closed', {
|
|
10145
10145
|
connector_id: this._connectorFlowId,
|
|
10146
10146
|
current_state: this._state,
|
|
10147
10147
|
});
|
|
10148
10148
|
return;
|
|
10149
10149
|
}
|
|
10150
|
-
logger$
|
|
10150
|
+
logger$13.debug('connector_shutdown_starting', {
|
|
10151
10151
|
connector_id: this._connectorFlowId,
|
|
10152
10152
|
connector_type: this.constructor.name,
|
|
10153
10153
|
code,
|
|
@@ -10177,19 +10177,19 @@ class BaseAsyncConnector extends TaskSpawner {
|
|
|
10177
10177
|
this._sendPromiseResolve = undefined;
|
|
10178
10178
|
}
|
|
10179
10179
|
// Close transport
|
|
10180
|
-
logger$
|
|
10180
|
+
logger$13.debug('connector_closing_transport', {
|
|
10181
10181
|
connector_id: this._connectorFlowId,
|
|
10182
10182
|
connector_type: this.constructor.name,
|
|
10183
10183
|
timestamp: new Date().toISOString(),
|
|
10184
10184
|
});
|
|
10185
10185
|
await this._transportClose(code, reason);
|
|
10186
|
-
logger$
|
|
10186
|
+
logger$13.debug('connector_transport_closed', {
|
|
10187
10187
|
connector_id: this._connectorFlowId,
|
|
10188
10188
|
connector_type: this.constructor.name,
|
|
10189
10189
|
timestamp: new Date().toISOString(),
|
|
10190
10190
|
});
|
|
10191
10191
|
// Shutdown spawned tasks
|
|
10192
|
-
logger$
|
|
10192
|
+
logger$13.debug('connector_shutting_down_tasks', {
|
|
10193
10193
|
connector_id: this._connectorFlowId,
|
|
10194
10194
|
connector_type: this.constructor.name,
|
|
10195
10195
|
grace_period_ms: effectiveGracePeriod * 1000,
|
|
@@ -10201,14 +10201,14 @@ class BaseAsyncConnector extends TaskSpawner {
|
|
|
10201
10201
|
gracePeriod: effectiveGracePeriod * 1000, // Convert to milliseconds
|
|
10202
10202
|
joinTimeout: this._shutdownJoinTimeout,
|
|
10203
10203
|
});
|
|
10204
|
-
logger$
|
|
10204
|
+
logger$13.debug('connector_tasks_shutdown_complete', {
|
|
10205
10205
|
connector_id: this._connectorFlowId,
|
|
10206
10206
|
connector_type: this.constructor.name,
|
|
10207
10207
|
timestamp: new Date().toISOString(),
|
|
10208
10208
|
});
|
|
10209
10209
|
}
|
|
10210
10210
|
catch (error) {
|
|
10211
|
-
logger$
|
|
10211
|
+
logger$13.warning('task_shutdown_error', {
|
|
10212
10212
|
connector_id: this._connectorFlowId,
|
|
10213
10213
|
error: error instanceof Error ? error.message : String(error),
|
|
10214
10214
|
});
|
|
@@ -10221,7 +10221,7 @@ class BaseAsyncConnector extends TaskSpawner {
|
|
|
10221
10221
|
if (this._closeResolver) {
|
|
10222
10222
|
this._closeResolver();
|
|
10223
10223
|
}
|
|
10224
|
-
logger$
|
|
10224
|
+
logger$13.debug('connector_shutdown_complete', {
|
|
10225
10225
|
connector_id: this._connectorFlowId,
|
|
10226
10226
|
connector_type: this.constructor.name,
|
|
10227
10227
|
final_state: this._state,
|
|
@@ -10297,7 +10297,7 @@ class BoundedAsyncQueue {
|
|
|
10297
10297
|
}
|
|
10298
10298
|
}
|
|
10299
10299
|
|
|
10300
|
-
const logger$
|
|
10300
|
+
const logger$12 = getLogger('naylence.fame.connector.broadcast_channel_connector');
|
|
10301
10301
|
const BROADCAST_CHANNEL_CONNECTOR_TYPE = 'broadcast-channel-connector';
|
|
10302
10302
|
const DEFAULT_CHANNEL$7 = 'naylence-fabric';
|
|
10303
10303
|
const DEFAULT_INBOX_CAPACITY$7 = 2048;
|
|
@@ -10386,7 +10386,7 @@ let BroadcastChannelConnector$2 = class BroadcastChannelConnector extends BaseAs
|
|
|
10386
10386
|
this.localNodeId = normalizedLocalNodeId;
|
|
10387
10387
|
this.targetNodeId = BroadcastChannelConnector.normalizeTargetNodeId(config.initialTargetNodeId);
|
|
10388
10388
|
this.channel = new BroadcastChannel(this.channelName);
|
|
10389
|
-
logger$
|
|
10389
|
+
logger$12.debug('broadcast_channel_connector_created', {
|
|
10390
10390
|
channel: this.channelName,
|
|
10391
10391
|
connector_id: this.connectorId,
|
|
10392
10392
|
local_node_id: this.localNodeId,
|
|
@@ -10398,7 +10398,7 @@ let BroadcastChannelConnector$2 = class BroadcastChannelConnector extends BaseAs
|
|
|
10398
10398
|
this.onMsg = (event) => {
|
|
10399
10399
|
// Guard: Don't process if listener was unregistered
|
|
10400
10400
|
if (!this.listenerRegistered) {
|
|
10401
|
-
logger$
|
|
10401
|
+
logger$12.warning('broadcast_channel_message_after_unregister', {
|
|
10402
10402
|
channel: this.channelName,
|
|
10403
10403
|
connector_id: this.connectorId,
|
|
10404
10404
|
timestamp: new Date().toISOString(),
|
|
@@ -10406,7 +10406,7 @@ let BroadcastChannelConnector$2 = class BroadcastChannelConnector extends BaseAs
|
|
|
10406
10406
|
return;
|
|
10407
10407
|
}
|
|
10408
10408
|
const message = event.data;
|
|
10409
|
-
logger$
|
|
10409
|
+
logger$12.debug('broadcast_channel_raw_event', {
|
|
10410
10410
|
channel: this.channelName,
|
|
10411
10411
|
connector_id: this.connectorId,
|
|
10412
10412
|
message_type: message && typeof message === 'object'
|
|
@@ -10422,7 +10422,7 @@ let BroadcastChannelConnector$2 = class BroadcastChannelConnector extends BaseAs
|
|
|
10422
10422
|
const busMessage = message;
|
|
10423
10423
|
const senderNodeId = BroadcastChannelConnector.normalizeNodeId(busMessage.senderNodeId);
|
|
10424
10424
|
if (!senderNodeId) {
|
|
10425
|
-
logger$
|
|
10425
|
+
logger$12.debug('broadcast_channel_message_rejected', {
|
|
10426
10426
|
channel: this.channelName,
|
|
10427
10427
|
connector_id: this.connectorId,
|
|
10428
10428
|
reason: 'missing_sender_node_id',
|
|
@@ -10430,7 +10430,7 @@ let BroadcastChannelConnector$2 = class BroadcastChannelConnector extends BaseAs
|
|
|
10430
10430
|
return;
|
|
10431
10431
|
}
|
|
10432
10432
|
if (senderNodeId === this.localNodeId) {
|
|
10433
|
-
logger$
|
|
10433
|
+
logger$12.debug('broadcast_channel_message_rejected', {
|
|
10434
10434
|
channel: this.channelName,
|
|
10435
10435
|
connector_id: this.connectorId,
|
|
10436
10436
|
reason: 'self_echo',
|
|
@@ -10444,14 +10444,14 @@ let BroadcastChannelConnector$2 = class BroadcastChannelConnector extends BaseAs
|
|
|
10444
10444
|
}
|
|
10445
10445
|
const payload = BroadcastChannelConnector.coercePayload(busMessage.payload);
|
|
10446
10446
|
if (!payload) {
|
|
10447
|
-
logger$
|
|
10447
|
+
logger$12.debug('broadcast_channel_payload_rejected', {
|
|
10448
10448
|
channel: this.channelName,
|
|
10449
10449
|
connector_id: this.connectorId,
|
|
10450
10450
|
reason: 'unrecognized_payload_type',
|
|
10451
10451
|
});
|
|
10452
10452
|
return;
|
|
10453
10453
|
}
|
|
10454
|
-
logger$
|
|
10454
|
+
logger$12.debug('broadcast_channel_message_received', {
|
|
10455
10455
|
channel: this.channelName,
|
|
10456
10456
|
sender_id: message?.senderId,
|
|
10457
10457
|
sender_node_id: senderNodeId,
|
|
@@ -10480,14 +10480,14 @@ let BroadcastChannelConnector$2 = class BroadcastChannelConnector extends BaseAs
|
|
|
10480
10480
|
}
|
|
10481
10481
|
catch (error) {
|
|
10482
10482
|
if (error instanceof QueueFullError) {
|
|
10483
|
-
logger$
|
|
10483
|
+
logger$12.warning('broadcast_channel_receive_queue_full', {
|
|
10484
10484
|
channel: this.channelName,
|
|
10485
10485
|
inbox_capacity: this.inboxCapacity,
|
|
10486
10486
|
inbox_remaining_capacity: this.inbox.remainingCapacity,
|
|
10487
10487
|
});
|
|
10488
10488
|
}
|
|
10489
10489
|
else {
|
|
10490
|
-
logger$
|
|
10490
|
+
logger$12.error('broadcast_channel_receive_error', {
|
|
10491
10491
|
channel: this.channelName,
|
|
10492
10492
|
error: error instanceof Error ? error.message : String(error),
|
|
10493
10493
|
});
|
|
@@ -10501,7 +10501,7 @@ let BroadcastChannelConnector$2 = class BroadcastChannelConnector extends BaseAs
|
|
|
10501
10501
|
// Setup visibility change monitoring
|
|
10502
10502
|
this.visibilityChangeHandler = () => {
|
|
10503
10503
|
const isHidden = document.hidden;
|
|
10504
|
-
logger$
|
|
10504
|
+
logger$12.debug('broadcast_channel_visibility_changed', {
|
|
10505
10505
|
channel: this.channelName,
|
|
10506
10506
|
connector_id: this.connectorId,
|
|
10507
10507
|
visibility: isHidden ? 'hidden' : 'visible',
|
|
@@ -10510,7 +10510,7 @@ let BroadcastChannelConnector$2 = class BroadcastChannelConnector extends BaseAs
|
|
|
10510
10510
|
// Pause/resume connector based on visibility
|
|
10511
10511
|
if (isHidden && this.state === ConnectorState.STARTED) {
|
|
10512
10512
|
this.pause().catch((err) => {
|
|
10513
|
-
logger$
|
|
10513
|
+
logger$12.warning('broadcast_channel_pause_failed', {
|
|
10514
10514
|
channel: this.channelName,
|
|
10515
10515
|
connector_id: this.connectorId,
|
|
10516
10516
|
error: err instanceof Error ? err.message : String(err),
|
|
@@ -10519,7 +10519,7 @@ let BroadcastChannelConnector$2 = class BroadcastChannelConnector extends BaseAs
|
|
|
10519
10519
|
}
|
|
10520
10520
|
else if (!isHidden && this.state === ConnectorState.PAUSED) {
|
|
10521
10521
|
this.resume().catch((err) => {
|
|
10522
|
-
logger$
|
|
10522
|
+
logger$12.warning('broadcast_channel_resume_failed', {
|
|
10523
10523
|
channel: this.channelName,
|
|
10524
10524
|
connector_id: this.connectorId,
|
|
10525
10525
|
error: err instanceof Error ? err.message : String(err),
|
|
@@ -10533,7 +10533,7 @@ let BroadcastChannelConnector$2 = class BroadcastChannelConnector extends BaseAs
|
|
|
10533
10533
|
// Track page lifecycle events to detect browser unload/discard
|
|
10534
10534
|
if (typeof window !== 'undefined') {
|
|
10535
10535
|
const lifecycleLogger = (event) => {
|
|
10536
|
-
logger$
|
|
10536
|
+
logger$12.debug('broadcast_channel_page_lifecycle', {
|
|
10537
10537
|
channel: this.channelName,
|
|
10538
10538
|
connector_id: this.connectorId,
|
|
10539
10539
|
event_type: event.type,
|
|
@@ -10549,7 +10549,7 @@ let BroadcastChannelConnector$2 = class BroadcastChannelConnector extends BaseAs
|
|
|
10549
10549
|
document.addEventListener('resume', lifecycleLogger);
|
|
10550
10550
|
}
|
|
10551
10551
|
// Log initial state with detailed visibility info
|
|
10552
|
-
logger$
|
|
10552
|
+
logger$12.debug('broadcast_channel_initial_visibility', {
|
|
10553
10553
|
channel: this.channelName,
|
|
10554
10554
|
connector_id: this.connectorId,
|
|
10555
10555
|
visibility: document.hidden ? 'hidden' : 'visible',
|
|
@@ -10581,14 +10581,14 @@ let BroadcastChannelConnector$2 = class BroadcastChannelConnector extends BaseAs
|
|
|
10581
10581
|
}
|
|
10582
10582
|
catch (error) {
|
|
10583
10583
|
if (error instanceof QueueFullError) {
|
|
10584
|
-
logger$
|
|
10584
|
+
logger$12.warning('broadcast_channel_push_queue_full', {
|
|
10585
10585
|
channel: this.channelName,
|
|
10586
10586
|
inbox_capacity: this.inboxCapacity,
|
|
10587
10587
|
inbox_remaining_capacity: this.inbox.remainingCapacity,
|
|
10588
10588
|
});
|
|
10589
10589
|
throw error;
|
|
10590
10590
|
}
|
|
10591
|
-
logger$
|
|
10591
|
+
logger$12.error('broadcast_channel_push_failed', {
|
|
10592
10592
|
channel: this.channelName,
|
|
10593
10593
|
error: error instanceof Error ? error.message : String(error),
|
|
10594
10594
|
});
|
|
@@ -10598,7 +10598,7 @@ let BroadcastChannelConnector$2 = class BroadcastChannelConnector extends BaseAs
|
|
|
10598
10598
|
async _transportSendBytes(data) {
|
|
10599
10599
|
ensureBroadcastEnvironment();
|
|
10600
10600
|
const targetNodeId = this.targetNodeId ?? '*';
|
|
10601
|
-
logger$
|
|
10601
|
+
logger$12.debug('broadcast_channel_message_sending', {
|
|
10602
10602
|
channel: this.channelName,
|
|
10603
10603
|
sender_id: this.connectorId,
|
|
10604
10604
|
sender_node_id: this.localNodeId,
|
|
@@ -10619,7 +10619,7 @@ let BroadcastChannelConnector$2 = class BroadcastChannelConnector extends BaseAs
|
|
|
10619
10619
|
return item;
|
|
10620
10620
|
}
|
|
10621
10621
|
async _transportClose(code, reason) {
|
|
10622
|
-
logger$
|
|
10622
|
+
logger$12.debug('broadcast_channel_transport_closing', {
|
|
10623
10623
|
channel: this.channelName,
|
|
10624
10624
|
connector_id: this.connectorId,
|
|
10625
10625
|
code,
|
|
@@ -10628,14 +10628,14 @@ let BroadcastChannelConnector$2 = class BroadcastChannelConnector extends BaseAs
|
|
|
10628
10628
|
timestamp: new Date().toISOString(),
|
|
10629
10629
|
});
|
|
10630
10630
|
if (this.listenerRegistered) {
|
|
10631
|
-
logger$
|
|
10631
|
+
logger$12.debug('broadcast_channel_removing_listener', {
|
|
10632
10632
|
channel: this.channelName,
|
|
10633
10633
|
connector_id: this.connectorId,
|
|
10634
10634
|
timestamp: new Date().toISOString(),
|
|
10635
10635
|
});
|
|
10636
10636
|
this.channel.removeEventListener('message', this.onMsg);
|
|
10637
10637
|
this.listenerRegistered = false;
|
|
10638
|
-
logger$
|
|
10638
|
+
logger$12.debug('broadcast_channel_listener_removed', {
|
|
10639
10639
|
channel: this.channelName,
|
|
10640
10640
|
connector_id: this.connectorId,
|
|
10641
10641
|
timestamp: new Date().toISOString(),
|
|
@@ -10648,13 +10648,13 @@ let BroadcastChannelConnector$2 = class BroadcastChannelConnector extends BaseAs
|
|
|
10648
10648
|
this.visibilityChangeListenerRegistered = false;
|
|
10649
10649
|
this.visibilityChangeHandler = undefined;
|
|
10650
10650
|
}
|
|
10651
|
-
logger$
|
|
10651
|
+
logger$12.debug('broadcast_channel_closing', {
|
|
10652
10652
|
channel: this.channelName,
|
|
10653
10653
|
connector_id: this.connectorId,
|
|
10654
10654
|
timestamp: new Date().toISOString(),
|
|
10655
10655
|
});
|
|
10656
10656
|
this.channel.close();
|
|
10657
|
-
logger$
|
|
10657
|
+
logger$12.debug('broadcast_channel_closed', {
|
|
10658
10658
|
channel: this.channelName,
|
|
10659
10659
|
connector_id: this.connectorId,
|
|
10660
10660
|
timestamp: new Date().toISOString(),
|
|
@@ -10678,7 +10678,7 @@ let BroadcastChannelConnector$2 = class BroadcastChannelConnector extends BaseAs
|
|
|
10678
10678
|
if (targetNodeId &&
|
|
10679
10679
|
targetNodeId !== '*' &&
|
|
10680
10680
|
targetNodeId !== this.localNodeId) {
|
|
10681
|
-
logger$
|
|
10681
|
+
logger$12.debug('broadcast_channel_message_rejected', {
|
|
10682
10682
|
channel: this.channelName,
|
|
10683
10683
|
connector_id: this.connectorId,
|
|
10684
10684
|
reason: 'wildcard_target_mismatch',
|
|
@@ -10694,7 +10694,7 @@ let BroadcastChannelConnector$2 = class BroadcastChannelConnector extends BaseAs
|
|
|
10694
10694
|
if (expectedSender &&
|
|
10695
10695
|
expectedSender !== '*' &&
|
|
10696
10696
|
senderNodeId !== expectedSender) {
|
|
10697
|
-
logger$
|
|
10697
|
+
logger$12.debug('broadcast_channel_message_rejected', {
|
|
10698
10698
|
channel: this.channelName,
|
|
10699
10699
|
connector_id: this.connectorId,
|
|
10700
10700
|
reason: 'unexpected_sender',
|
|
@@ -10707,7 +10707,7 @@ let BroadcastChannelConnector$2 = class BroadcastChannelConnector extends BaseAs
|
|
|
10707
10707
|
if (targetNodeId &&
|
|
10708
10708
|
targetNodeId !== '*' &&
|
|
10709
10709
|
targetNodeId !== this.localNodeId) {
|
|
10710
|
-
logger$
|
|
10710
|
+
logger$12.debug('broadcast_channel_message_rejected', {
|
|
10711
10711
|
channel: this.channelName,
|
|
10712
10712
|
connector_id: this.connectorId,
|
|
10713
10713
|
reason: 'unexpected_target',
|
|
@@ -10732,7 +10732,7 @@ let BroadcastChannelConnector$2 = class BroadcastChannelConnector extends BaseAs
|
|
|
10732
10732
|
return 'unknown';
|
|
10733
10733
|
}
|
|
10734
10734
|
logInboxSnapshot(event, extra = {}) {
|
|
10735
|
-
logger$
|
|
10735
|
+
logger$12.debug(event, {
|
|
10736
10736
|
channel: this.channelName,
|
|
10737
10737
|
connector_id: this.connectorId,
|
|
10738
10738
|
connector_state: this.state,
|
|
@@ -10748,7 +10748,7 @@ let BroadcastChannelConnector$2 = class BroadcastChannelConnector extends BaseAs
|
|
|
10748
10748
|
await super.start(inboundHandler);
|
|
10749
10749
|
// After transitioning to STARTED, check if tab is already hidden
|
|
10750
10750
|
if (typeof document !== 'undefined' && document.hidden) {
|
|
10751
|
-
logger$
|
|
10751
|
+
logger$12.debug('broadcast_channel_start_in_hidden_tab', {
|
|
10752
10752
|
channel: this.channelName,
|
|
10753
10753
|
connector_id: this.connectorId,
|
|
10754
10754
|
document_hidden: document.hidden,
|
|
@@ -10758,7 +10758,7 @@ let BroadcastChannelConnector$2 = class BroadcastChannelConnector extends BaseAs
|
|
|
10758
10758
|
});
|
|
10759
10759
|
// Immediately pause if tab is hidden at start time
|
|
10760
10760
|
await this.pause().catch((err) => {
|
|
10761
|
-
logger$
|
|
10761
|
+
logger$12.warning('broadcast_channel_initial_pause_failed', {
|
|
10762
10762
|
channel: this.channelName,
|
|
10763
10763
|
connector_id: this.connectorId,
|
|
10764
10764
|
error: err instanceof Error ? err.message : String(err),
|
|
@@ -10776,7 +10776,7 @@ let BroadcastChannelConnector$2 = class BroadcastChannelConnector extends BaseAs
|
|
|
10776
10776
|
return;
|
|
10777
10777
|
}
|
|
10778
10778
|
this.targetNodeId = normalized;
|
|
10779
|
-
logger$
|
|
10779
|
+
logger$12.debug('broadcast_channel_target_updated', {
|
|
10780
10780
|
channel: this.channelName,
|
|
10781
10781
|
connector_id: this.connectorId,
|
|
10782
10782
|
local_node_id: this.localNodeId,
|
|
@@ -10786,7 +10786,7 @@ let BroadcastChannelConnector$2 = class BroadcastChannelConnector extends BaseAs
|
|
|
10786
10786
|
}
|
|
10787
10787
|
setWildcardTarget() {
|
|
10788
10788
|
this.targetNodeId = '*';
|
|
10789
|
-
logger$
|
|
10789
|
+
logger$12.debug('broadcast_channel_target_updated', {
|
|
10790
10790
|
channel: this.channelName,
|
|
10791
10791
|
connector_id: this.connectorId,
|
|
10792
10792
|
local_node_id: this.localNodeId,
|
|
@@ -10959,7 +10959,7 @@ function broadcastChannelGrantToConnectorConfig(grant) {
|
|
|
10959
10959
|
return config;
|
|
10960
10960
|
}
|
|
10961
10961
|
|
|
10962
|
-
const logger$
|
|
10962
|
+
const logger$11 = getLogger('naylence.fame.node.upstream_session_manager');
|
|
10963
10963
|
function isPlainRecord$4(value) {
|
|
10964
10964
|
if (typeof value !== 'object' || value === null) {
|
|
10965
10965
|
return false;
|
|
@@ -11080,7 +11080,7 @@ class UpstreamSessionManager extends TaskSpawner {
|
|
|
11080
11080
|
this.wrappedHandler = this.makeHeartbeatEnabledHandler(options.inboundHandler);
|
|
11081
11081
|
// Store the connection retry policy (can be null, in which case default behavior applies)
|
|
11082
11082
|
this.connectionRetryPolicy = options.retryPolicy ?? null;
|
|
11083
|
-
logger$
|
|
11083
|
+
logger$11.debug('created_upstream_session_manager', {
|
|
11084
11084
|
target_system_id: this.targetSystemId,
|
|
11085
11085
|
has_retry_policy: this.connectionRetryPolicy !== null,
|
|
11086
11086
|
});
|
|
@@ -11089,23 +11089,23 @@ class UpstreamSessionManager extends TaskSpawner {
|
|
|
11089
11089
|
return this.targetSystemId;
|
|
11090
11090
|
}
|
|
11091
11091
|
setupVisibilityListener() {
|
|
11092
|
-
logger$
|
|
11092
|
+
logger$11.debug('setup_visibility_listener_called', {
|
|
11093
11093
|
has_document: typeof document !== 'undefined',
|
|
11094
11094
|
});
|
|
11095
11095
|
if (typeof document !== 'undefined' && document.addEventListener) {
|
|
11096
11096
|
this._visibilityHandler = () => {
|
|
11097
|
-
logger$
|
|
11097
|
+
logger$11.debug('visibility_change_event_fired', {
|
|
11098
11098
|
state: document.visibilityState,
|
|
11099
11099
|
});
|
|
11100
11100
|
if (document.visibilityState === 'visible') {
|
|
11101
|
-
logger$
|
|
11101
|
+
logger$11.debug('visibility_change_detected_waking_up');
|
|
11102
11102
|
this.wakeEvent.set();
|
|
11103
11103
|
}
|
|
11104
11104
|
};
|
|
11105
11105
|
document.addEventListener('visibilitychange', this._visibilityHandler);
|
|
11106
11106
|
}
|
|
11107
11107
|
else {
|
|
11108
|
-
logger$
|
|
11108
|
+
logger$11.debug('setup_visibility_listener_skipped_no_document');
|
|
11109
11109
|
}
|
|
11110
11110
|
}
|
|
11111
11111
|
teardownVisibilityListener() {
|
|
@@ -11138,13 +11138,13 @@ class UpstreamSessionManager extends TaskSpawner {
|
|
|
11138
11138
|
}
|
|
11139
11139
|
throw new FameConnectError('Upstream session manager failed to attach');
|
|
11140
11140
|
}
|
|
11141
|
-
logger$
|
|
11141
|
+
logger$11.debug('upstream_session_manager_started');
|
|
11142
11142
|
}
|
|
11143
11143
|
getActiveConnector() {
|
|
11144
11144
|
return this.connector;
|
|
11145
11145
|
}
|
|
11146
11146
|
async stop() {
|
|
11147
|
-
logger$
|
|
11147
|
+
logger$11.debug('upstream_session_manager_stopping');
|
|
11148
11148
|
this.teardownVisibilityListener();
|
|
11149
11149
|
this.stopEvent.set();
|
|
11150
11150
|
this.currentStopSubtasks?.set();
|
|
@@ -11155,7 +11155,7 @@ class UpstreamSessionManager extends TaskSpawner {
|
|
|
11155
11155
|
}
|
|
11156
11156
|
catch (error) {
|
|
11157
11157
|
if (!(error instanceof TaskCancelledError)) {
|
|
11158
|
-
logger$
|
|
11158
|
+
logger$11.debug('fsm_task_stopped_with_error', {
|
|
11159
11159
|
error: error.message,
|
|
11160
11160
|
});
|
|
11161
11161
|
}
|
|
@@ -11164,13 +11164,13 @@ class UpstreamSessionManager extends TaskSpawner {
|
|
|
11164
11164
|
}
|
|
11165
11165
|
if (this.connector) {
|
|
11166
11166
|
await this.connector.stop().catch((error) => {
|
|
11167
|
-
logger$
|
|
11167
|
+
logger$11.debug('connector_stop_error', {
|
|
11168
11168
|
error: error.message,
|
|
11169
11169
|
});
|
|
11170
11170
|
});
|
|
11171
11171
|
this.connector = null;
|
|
11172
11172
|
}
|
|
11173
|
-
logger$
|
|
11173
|
+
logger$11.debug('upstream_session_manager_stopped');
|
|
11174
11174
|
}
|
|
11175
11175
|
async send(envelope) {
|
|
11176
11176
|
if (this.messageQueue.length >= UpstreamSessionManager.TX_QUEUE_MAX) {
|
|
@@ -11219,7 +11219,7 @@ class UpstreamSessionManager extends TaskSpawner {
|
|
|
11219
11219
|
const shouldFailFast = this.shouldFailFastOnError(error);
|
|
11220
11220
|
if (error instanceof FameTransportClose ||
|
|
11221
11221
|
error instanceof FameConnectError) {
|
|
11222
|
-
logger$
|
|
11222
|
+
logger$11.warning('upstream_link_closed', {
|
|
11223
11223
|
error: error.message,
|
|
11224
11224
|
will_retry: !shouldFailFast,
|
|
11225
11225
|
attempt: this.initialAttempts,
|
|
@@ -11232,13 +11232,13 @@ class UpstreamSessionManager extends TaskSpawner {
|
|
|
11232
11232
|
else {
|
|
11233
11233
|
const err = error;
|
|
11234
11234
|
if (err.name === 'OAuth2PkceRedirectInitiatedError') {
|
|
11235
|
-
logger$
|
|
11235
|
+
logger$11.info('upstream_link_redirecting', {
|
|
11236
11236
|
error: err.message,
|
|
11237
11237
|
will_retry: true,
|
|
11238
11238
|
});
|
|
11239
11239
|
}
|
|
11240
11240
|
else {
|
|
11241
|
-
logger$
|
|
11241
|
+
logger$11.warning('upstream_link_closed', {
|
|
11242
11242
|
error: err.message,
|
|
11243
11243
|
will_retry: !shouldFailFast,
|
|
11244
11244
|
attempt: this.initialAttempts,
|
|
@@ -11282,7 +11282,7 @@ class UpstreamSessionManager extends TaskSpawner {
|
|
|
11282
11282
|
// If sleep was interrupted by visibility change (user returned to tab),
|
|
11283
11283
|
// reset backoff to initial delay for immediate retry with fresh backoff
|
|
11284
11284
|
if (wasWoken) {
|
|
11285
|
-
logger$
|
|
11285
|
+
logger$11.debug('backoff_reset_on_visibility_change', {
|
|
11286
11286
|
previous_delay: delay,
|
|
11287
11287
|
new_delay: UpstreamSessionManager.BACKOFF_INITIAL,
|
|
11288
11288
|
});
|
|
@@ -11301,7 +11301,7 @@ class UpstreamSessionManager extends TaskSpawner {
|
|
|
11301
11301
|
// Check if wake event is already set (e.g., visibility just changed)
|
|
11302
11302
|
if (this.wakeEvent.isSet()) {
|
|
11303
11303
|
this.wakeEvent.clear();
|
|
11304
|
-
logger$
|
|
11304
|
+
logger$11.debug('sleep_skipped_wake_event_pending');
|
|
11305
11305
|
return true;
|
|
11306
11306
|
}
|
|
11307
11307
|
let timeout;
|
|
@@ -11318,7 +11318,7 @@ class UpstreamSessionManager extends TaskSpawner {
|
|
|
11318
11318
|
]);
|
|
11319
11319
|
const wasWoken = this.wakeEvent.isSet();
|
|
11320
11320
|
if (wasWoken) {
|
|
11321
|
-
logger$
|
|
11321
|
+
logger$11.debug('sleep_interrupted_by_wake_event');
|
|
11322
11322
|
this.wakeEvent.clear();
|
|
11323
11323
|
}
|
|
11324
11324
|
if (timeout !== undefined) {
|
|
@@ -11381,7 +11381,7 @@ class UpstreamSessionManager extends TaskSpawner {
|
|
|
11381
11381
|
await connector.start(this.wrappedHandler);
|
|
11382
11382
|
this.connector = connector;
|
|
11383
11383
|
const callbackGrants = this.node.gatherSupportedCallbackGrants();
|
|
11384
|
-
logger$
|
|
11384
|
+
logger$11.debug('callback_grants_before_augmentation', {
|
|
11385
11385
|
count: callbackGrants.length,
|
|
11386
11386
|
types: callbackGrants.map((g) => g.type),
|
|
11387
11387
|
});
|
|
@@ -11391,7 +11391,7 @@ class UpstreamSessionManager extends TaskSpawner {
|
|
|
11391
11391
|
const broadcastCallbackGrant = shouldAddBroadcastGrant
|
|
11392
11392
|
? this.createBroadcastCallbackGrant(grant)
|
|
11393
11393
|
: null;
|
|
11394
|
-
logger$
|
|
11394
|
+
logger$11.debug('broadcast_callback_grant_check', {
|
|
11395
11395
|
should_add: shouldAddBroadcastGrant,
|
|
11396
11396
|
grant_created: !!broadcastCallbackGrant,
|
|
11397
11397
|
});
|
|
@@ -11410,12 +11410,12 @@ class UpstreamSessionManager extends TaskSpawner {
|
|
|
11410
11410
|
const isDuplicate = callbackGrants.some((existing) => JSON.stringify(existing) === JSON.stringify(grant));
|
|
11411
11411
|
if (!isDuplicate) {
|
|
11412
11412
|
callbackGrants.push(grant);
|
|
11413
|
-
logger$
|
|
11413
|
+
logger$11.debug('added_connection_grant_as_callback', {
|
|
11414
11414
|
type: grant.type,
|
|
11415
11415
|
});
|
|
11416
11416
|
}
|
|
11417
11417
|
else {
|
|
11418
|
-
logger$
|
|
11418
|
+
logger$11.debug('skipped_duplicate_connection_grant', {
|
|
11419
11419
|
type: grant.type,
|
|
11420
11420
|
});
|
|
11421
11421
|
}
|
|
@@ -11427,12 +11427,12 @@ class UpstreamSessionManager extends TaskSpawner {
|
|
|
11427
11427
|
if (broadcastCallbackGrant &&
|
|
11428
11428
|
this.shouldAdvertiseBroadcastGrant(grant, callbackGrants)) {
|
|
11429
11429
|
callbackGrants.push(broadcastCallbackGrant);
|
|
11430
|
-
logger$
|
|
11430
|
+
logger$11.debug('added_broadcast_callback_grant');
|
|
11431
11431
|
}
|
|
11432
11432
|
else if (broadcastCallbackGrant) {
|
|
11433
|
-
logger$
|
|
11433
|
+
logger$11.debug('skipped_duplicate_broadcast_callback_grant');
|
|
11434
11434
|
}
|
|
11435
|
-
logger$
|
|
11435
|
+
logger$11.debug('callback_grants_after_augmentation', {
|
|
11436
11436
|
count: callbackGrants.length,
|
|
11437
11437
|
types: callbackGrants.map((g) => g.type),
|
|
11438
11438
|
});
|
|
@@ -11445,7 +11445,7 @@ class UpstreamSessionManager extends TaskSpawner {
|
|
|
11445
11445
|
targetAware.setTargetNodeId(this.targetSystemId);
|
|
11446
11446
|
}
|
|
11447
11447
|
catch (error) {
|
|
11448
|
-
logger$
|
|
11448
|
+
logger$11.warning('broadcast_channel_target_apply_failed', {
|
|
11449
11449
|
error: error instanceof Error ? error.message : String(error),
|
|
11450
11450
|
target_node_id: this.targetSystemId,
|
|
11451
11451
|
});
|
|
@@ -11467,14 +11467,14 @@ class UpstreamSessionManager extends TaskSpawner {
|
|
|
11467
11467
|
});
|
|
11468
11468
|
}
|
|
11469
11469
|
else {
|
|
11470
|
-
logger$
|
|
11470
|
+
logger$11.warning('parent_epoch_changed', { epoch });
|
|
11471
11471
|
}
|
|
11472
11472
|
}
|
|
11473
11473
|
if (!this.readyEvent.isSet()) {
|
|
11474
11474
|
this.readyEvent.set();
|
|
11475
11475
|
}
|
|
11476
11476
|
if (this.messageQueue.length > 0) {
|
|
11477
|
-
logger$
|
|
11477
|
+
logger$11.debug('flushing_buffered_frames', {
|
|
11478
11478
|
queue_size: this.messageQueue.length,
|
|
11479
11479
|
});
|
|
11480
11480
|
this.queueEvent.set();
|
|
@@ -11491,12 +11491,12 @@ class UpstreamSessionManager extends TaskSpawner {
|
|
|
11491
11491
|
name: `expiry-guard-${this.connectEpoch}`,
|
|
11492
11492
|
});
|
|
11493
11493
|
if (this.hadSuccessfulAttach) {
|
|
11494
|
-
logger$
|
|
11494
|
+
logger$11.debug('reconnected_to_upstream', {
|
|
11495
11495
|
attach_expires_at: attachInfo.attachExpiresAt?.toISOString?.() ?? null,
|
|
11496
11496
|
});
|
|
11497
11497
|
}
|
|
11498
11498
|
else {
|
|
11499
|
-
logger$
|
|
11499
|
+
logger$11.debug('connected_to_upstream', {
|
|
11500
11500
|
attach_expires_at: attachInfo.attachExpiresAt?.toISOString?.() ?? null,
|
|
11501
11501
|
});
|
|
11502
11502
|
}
|
|
@@ -11514,18 +11514,18 @@ class UpstreamSessionManager extends TaskSpawner {
|
|
|
11514
11514
|
this.currentStopSubtasks = null;
|
|
11515
11515
|
await Promise.allSettled(tasks.map((task) => task.promise));
|
|
11516
11516
|
if (this.connector) {
|
|
11517
|
-
logger$
|
|
11517
|
+
logger$11.debug('upstream_stopping_old_connector', {
|
|
11518
11518
|
connect_epoch: this.connectEpoch,
|
|
11519
11519
|
target_system_id: this.targetSystemId,
|
|
11520
11520
|
timestamp: new Date().toISOString(),
|
|
11521
11521
|
});
|
|
11522
11522
|
await this.connector.stop().catch((err) => {
|
|
11523
|
-
logger$
|
|
11523
|
+
logger$11.warning('upstream_connector_stop_error', {
|
|
11524
11524
|
connect_epoch: this.connectEpoch,
|
|
11525
11525
|
error: err instanceof Error ? err.message : String(err),
|
|
11526
11526
|
});
|
|
11527
11527
|
});
|
|
11528
|
-
logger$
|
|
11528
|
+
logger$11.debug('upstream_old_connector_stopped', {
|
|
11529
11529
|
connect_epoch: this.connectEpoch,
|
|
11530
11530
|
target_system_id: this.targetSystemId,
|
|
11531
11531
|
timestamp: new Date().toISOString(),
|
|
@@ -11578,7 +11578,7 @@ class UpstreamSessionManager extends TaskSpawner {
|
|
|
11578
11578
|
});
|
|
11579
11579
|
}
|
|
11580
11580
|
catch (error) {
|
|
11581
|
-
logger$
|
|
11581
|
+
logger$11.debug('broadcast_callback_grant_generation_failed', {
|
|
11582
11582
|
error: error instanceof Error ? error.message : String(error),
|
|
11583
11583
|
});
|
|
11584
11584
|
return null;
|
|
@@ -11633,7 +11633,7 @@ class UpstreamSessionManager extends TaskSpawner {
|
|
|
11633
11633
|
}
|
|
11634
11634
|
}
|
|
11635
11635
|
async heartbeatLoop(connector, stopEvt, signal) {
|
|
11636
|
-
logger$
|
|
11636
|
+
logger$11.debug('starting_heartbeat_loop');
|
|
11637
11637
|
const intervalMs = UpstreamSessionManager.HEARTBEAT_INTERVAL * 1000;
|
|
11638
11638
|
const graceMs = intervalMs * UpstreamSessionManager.HEARTBEAT_GRACE;
|
|
11639
11639
|
this.lastHeartbeatAckTime = Date.now();
|
|
@@ -11669,7 +11669,7 @@ class UpstreamSessionManager extends TaskSpawner {
|
|
|
11669
11669
|
// Skip heartbeat if connector is paused (e.g., tab is hidden)
|
|
11670
11670
|
// Keep ack time current so we don't timeout immediately after resuming
|
|
11671
11671
|
if (currentState === ConnectorState.PAUSED) {
|
|
11672
|
-
logger$
|
|
11672
|
+
logger$11.debug('skipping_heartbeat_connector_paused', {
|
|
11673
11673
|
connector_state: currentState,
|
|
11674
11674
|
});
|
|
11675
11675
|
this.lastHeartbeatAckTime = Date.now();
|
|
@@ -11678,14 +11678,14 @@ class UpstreamSessionManager extends TaskSpawner {
|
|
|
11678
11678
|
// Reset ack time if just resumed from pause (prevents immediate timeout)
|
|
11679
11679
|
if (previousState === ConnectorState.PAUSED &&
|
|
11680
11680
|
currentState === ConnectorState.STARTED) {
|
|
11681
|
-
logger$
|
|
11681
|
+
logger$11.debug('connector_just_resumed_resetting_ack_time', {
|
|
11682
11682
|
previous_state: previousState,
|
|
11683
11683
|
current_state: currentState,
|
|
11684
11684
|
});
|
|
11685
11685
|
this.lastHeartbeatAckTime = Date.now();
|
|
11686
11686
|
}
|
|
11687
11687
|
const envelope = await this.makeHeartbeatEnvelope();
|
|
11688
|
-
logger$
|
|
11688
|
+
logger$11.debug('sending_heartbeat', {
|
|
11689
11689
|
hb_corr_id: envelope.corrId,
|
|
11690
11690
|
hb_env_id: envelope.id,
|
|
11691
11691
|
});
|
|
@@ -11711,7 +11711,7 @@ class UpstreamSessionManager extends TaskSpawner {
|
|
|
11711
11711
|
throw new FameConnectError('missed heartbeat acknowledgement');
|
|
11712
11712
|
}
|
|
11713
11713
|
}
|
|
11714
|
-
logger$
|
|
11714
|
+
logger$11.debug('completed_heartbeat_loop');
|
|
11715
11715
|
}
|
|
11716
11716
|
async messagePumpLoop(connector, stopEvt, signal) {
|
|
11717
11717
|
while (!stopEvt.isSet() && !signal?.aborted) {
|
|
@@ -11728,19 +11728,19 @@ class UpstreamSessionManager extends TaskSpawner {
|
|
|
11728
11728
|
if (!envelope) {
|
|
11729
11729
|
continue;
|
|
11730
11730
|
}
|
|
11731
|
-
logger$
|
|
11731
|
+
logger$11.debug('upstream_pump_sending_envelope', {
|
|
11732
11732
|
envelopeId: envelope.id,
|
|
11733
11733
|
type: envelope.frame?.type,
|
|
11734
11734
|
});
|
|
11735
11735
|
try {
|
|
11736
11736
|
await connector.send(envelope);
|
|
11737
|
-
logger$
|
|
11737
|
+
logger$11.debug('upstream_pump_sent_envelope', {
|
|
11738
11738
|
envelopeId: envelope.id,
|
|
11739
11739
|
});
|
|
11740
11740
|
}
|
|
11741
11741
|
catch (error) {
|
|
11742
11742
|
if (error instanceof FameMessageTooLarge) {
|
|
11743
|
-
logger$
|
|
11743
|
+
logger$11.error('failed_to_send_message', { error: error.message });
|
|
11744
11744
|
await this.handleMessageTooLarge(envelope, error.message);
|
|
11745
11745
|
}
|
|
11746
11746
|
else if (error instanceof FameTransportClose) {
|
|
@@ -11802,7 +11802,7 @@ class UpstreamSessionManager extends TaskSpawner {
|
|
|
11802
11802
|
await fabric.send(ackEnvelope);
|
|
11803
11803
|
}
|
|
11804
11804
|
catch (error) {
|
|
11805
|
-
logger$
|
|
11805
|
+
logger$11.warning('failed_to_send_nack', {
|
|
11806
11806
|
error: error.message,
|
|
11807
11807
|
});
|
|
11808
11808
|
}
|
|
@@ -11816,7 +11816,7 @@ class UpstreamSessionManager extends TaskSpawner {
|
|
|
11816
11816
|
timestamps.push(info.attachExpiresAt);
|
|
11817
11817
|
}
|
|
11818
11818
|
if (!timestamps.length) {
|
|
11819
|
-
logger$
|
|
11819
|
+
logger$11.debug('no_ttl_expiry_configured');
|
|
11820
11820
|
await this.waitEvent(stopEvt, signal);
|
|
11821
11821
|
return;
|
|
11822
11822
|
}
|
|
@@ -11825,7 +11825,7 @@ class UpstreamSessionManager extends TaskSpawner {
|
|
|
11825
11825
|
let delaySeconds = (earliest.getTime() - now.getTime()) / 1000 -
|
|
11826
11826
|
UpstreamSessionManager.JWT_REFRESH_SAFETY;
|
|
11827
11827
|
delaySeconds = Math.max(delaySeconds, UpstreamSessionManager.JWT_REFRESH_SAFETY);
|
|
11828
|
-
logger$
|
|
11828
|
+
logger$11.debug('ttl_expiry_guard_started', {
|
|
11829
11829
|
welcome_expires_at: welcome.frame.expiresAt ?? null,
|
|
11830
11830
|
attach_expires_at: info.attachExpiresAt?.toISOString?.() ?? null,
|
|
11831
11831
|
earliest_expiry: earliest.toISOString(),
|
|
@@ -11853,7 +11853,7 @@ class UpstreamSessionManager extends TaskSpawner {
|
|
|
11853
11853
|
}
|
|
11854
11854
|
}
|
|
11855
11855
|
if (!stopEvt.isSet()) {
|
|
11856
|
-
logger$
|
|
11856
|
+
logger$11.debug('ttl_expiry_triggered_reconnect', {
|
|
11857
11857
|
expires_at: earliest.toISOString(),
|
|
11858
11858
|
current_time: new Date().toISOString(),
|
|
11859
11859
|
seconds_before_expiry: UpstreamSessionManager.JWT_REFRESH_SAFETY,
|
|
@@ -11898,7 +11898,7 @@ class UpstreamSessionManager extends TaskSpawner {
|
|
|
11898
11898
|
}
|
|
11899
11899
|
await this.node.dispatchEnvelopeEvent('onEnvelopeReceived', this.node, env, context);
|
|
11900
11900
|
if (env.frame.type === 'NodeHeartbeatAck') {
|
|
11901
|
-
logger$
|
|
11901
|
+
logger$11.debug('received_heartbeat_ack', {
|
|
11902
11902
|
hb_ack_env_id: env.id,
|
|
11903
11903
|
hb_ack_corr_id: env.corrId,
|
|
11904
11904
|
hb_routing_epoch: env.frame.routingEpoch,
|
|
@@ -11912,7 +11912,7 @@ class UpstreamSessionManager extends TaskSpawner {
|
|
|
11912
11912
|
await this.onEpochChange(epoch);
|
|
11913
11913
|
}
|
|
11914
11914
|
else {
|
|
11915
|
-
logger$
|
|
11915
|
+
logger$11.warning('parent_epoch_changed', { epoch });
|
|
11916
11916
|
}
|
|
11917
11917
|
}
|
|
11918
11918
|
return;
|
|
@@ -11931,7 +11931,7 @@ UpstreamSessionManager.TX_QUEUE_MAX = 512;
|
|
|
11931
11931
|
UpstreamSessionManager.BACKOFF_INITIAL = 1; // seconds
|
|
11932
11932
|
UpstreamSessionManager.BACKOFF_CAP = 30; // seconds
|
|
11933
11933
|
|
|
11934
|
-
const logger$
|
|
11934
|
+
const logger$10 = getLogger('naylence.fame.node.admission.noop_admission_client');
|
|
11935
11935
|
class NoopAdmissionClient {
|
|
11936
11936
|
constructor(options = {}) {
|
|
11937
11937
|
this.hasUpstream = false;
|
|
@@ -11945,7 +11945,7 @@ class NoopAdmissionClient {
|
|
|
11945
11945
|
const acceptedLogicals = this.autoAcceptLogicals
|
|
11946
11946
|
? [...(requestedLogicals ?? [])]
|
|
11947
11947
|
: [];
|
|
11948
|
-
logger$
|
|
11948
|
+
logger$10.debug('noop_admission_hello', {
|
|
11949
11949
|
systemId: effectiveSystemId,
|
|
11950
11950
|
instanceId,
|
|
11951
11951
|
requestedLogicals,
|
|
@@ -11963,7 +11963,7 @@ class NoopAdmissionClient {
|
|
|
11963
11963
|
});
|
|
11964
11964
|
}
|
|
11965
11965
|
async close() {
|
|
11966
|
-
logger$
|
|
11966
|
+
logger$10.debug('noop_admission_close');
|
|
11967
11967
|
}
|
|
11968
11968
|
}
|
|
11969
11969
|
|
|
@@ -12169,7 +12169,7 @@ class DefaultServiceManager {
|
|
|
12169
12169
|
}
|
|
12170
12170
|
|
|
12171
12171
|
const SYSTEM_INBOX$1 = '__sys__';
|
|
12172
|
-
const logger
|
|
12172
|
+
const logger$$ = getLogger('naylence.fame.node.node');
|
|
12173
12173
|
function isSnakeCase(name) {
|
|
12174
12174
|
return name.includes('_');
|
|
12175
12175
|
}
|
|
@@ -12439,7 +12439,7 @@ class FameNode extends TaskSpawner {
|
|
|
12439
12439
|
confirmIdentity(systemId, source) {
|
|
12440
12440
|
if (this._confirmedId) {
|
|
12441
12441
|
if (this._confirmedId !== systemId) {
|
|
12442
|
-
logger
|
|
12442
|
+
logger$$.error('node_identity_mismatch', {
|
|
12443
12443
|
current_id: this._confirmedId,
|
|
12444
12444
|
new_id: systemId,
|
|
12445
12445
|
source,
|
|
@@ -12451,14 +12451,14 @@ class FameNode extends TaskSpawner {
|
|
|
12451
12451
|
const isReassignment = this._provisionalId !== systemId;
|
|
12452
12452
|
this._confirmedId = systemId;
|
|
12453
12453
|
if (isReassignment) {
|
|
12454
|
-
logger
|
|
12454
|
+
logger$$.debug('node_identity_reassigned', {
|
|
12455
12455
|
system_id: systemId,
|
|
12456
12456
|
previous_id: this._provisionalId,
|
|
12457
12457
|
source,
|
|
12458
12458
|
});
|
|
12459
12459
|
}
|
|
12460
12460
|
else {
|
|
12461
|
-
logger
|
|
12461
|
+
logger$$.debug('node_identity_confirmed', {
|
|
12462
12462
|
system_id: systemId,
|
|
12463
12463
|
source,
|
|
12464
12464
|
});
|
|
@@ -12526,7 +12526,7 @@ class FameNode extends TaskSpawner {
|
|
|
12526
12526
|
return;
|
|
12527
12527
|
}
|
|
12528
12528
|
if (frameType === 'NodeHeartbeat') {
|
|
12529
|
-
logger
|
|
12529
|
+
logger$$.debug('received_heartbeat_frame', {
|
|
12530
12530
|
envelopeId: envelope.id,
|
|
12531
12531
|
corrId: envelope.corrId ?? null,
|
|
12532
12532
|
});
|
|
@@ -12538,7 +12538,7 @@ class FameNode extends TaskSpawner {
|
|
|
12538
12538
|
await this.handleDeliveryAck(envelope, context);
|
|
12539
12539
|
return;
|
|
12540
12540
|
}
|
|
12541
|
-
logger
|
|
12541
|
+
logger$$.debug('unhandled_system_frame', {
|
|
12542
12542
|
envelopeId: envelope.id,
|
|
12543
12543
|
frameType,
|
|
12544
12544
|
});
|
|
@@ -12550,13 +12550,13 @@ class FameNode extends TaskSpawner {
|
|
|
12550
12550
|
}
|
|
12551
12551
|
await this._deliveryTracker.onEnvelopeDelivered(SYSTEM_INBOX$1, envelope, context);
|
|
12552
12552
|
if (frame.ok !== false) {
|
|
12553
|
-
logger
|
|
12553
|
+
logger$$.debug('delivery_ack_received', {
|
|
12554
12554
|
envelopeId: envelope.id,
|
|
12555
12555
|
corrId: envelope.corrId ?? null,
|
|
12556
12556
|
});
|
|
12557
12557
|
return;
|
|
12558
12558
|
}
|
|
12559
|
-
logger
|
|
12559
|
+
logger$$.warning('delivery_nack_received', {
|
|
12560
12560
|
envelopeId: envelope.id,
|
|
12561
12561
|
corrId: envelope.corrId ?? null,
|
|
12562
12562
|
code: frame.code ?? null,
|
|
@@ -12566,7 +12566,7 @@ class FameNode extends TaskSpawner {
|
|
|
12566
12566
|
await this.onDeliveryNack(frame, envelope, context);
|
|
12567
12567
|
}
|
|
12568
12568
|
async onDeliveryNack(frame, envelope, _context) {
|
|
12569
|
-
logger
|
|
12569
|
+
logger$$.debug('delivery_nack_processed', {
|
|
12570
12570
|
envelopeId: envelope.id,
|
|
12571
12571
|
code: frame.code ?? null,
|
|
12572
12572
|
reason: frame.reason ?? null,
|
|
@@ -12681,7 +12681,7 @@ class FameNode extends TaskSpawner {
|
|
|
12681
12681
|
await this._bindingManager.restore();
|
|
12682
12682
|
await this._envelopeListenerManager.start();
|
|
12683
12683
|
this._isStarted = true;
|
|
12684
|
-
logger
|
|
12684
|
+
logger$$.debug('node_started', {
|
|
12685
12685
|
node_id: this.id,
|
|
12686
12686
|
sid: this.sid,
|
|
12687
12687
|
path: this.physicalPath,
|
|
@@ -12713,7 +12713,7 @@ class FameNode extends TaskSpawner {
|
|
|
12713
12713
|
await this._serviceManager.stop();
|
|
12714
12714
|
await this.dispatchEvent('onNodeStopped', this);
|
|
12715
12715
|
this._isStarted = false;
|
|
12716
|
-
logger
|
|
12716
|
+
logger$$.debug('node_stopped', {
|
|
12717
12717
|
node_id: this.id,
|
|
12718
12718
|
});
|
|
12719
12719
|
}
|
|
@@ -12903,20 +12903,20 @@ class FameNode extends TaskSpawner {
|
|
|
12903
12903
|
await this.forwardUpstream(processedEnvelope, context);
|
|
12904
12904
|
}
|
|
12905
12905
|
else {
|
|
12906
|
-
logger
|
|
12906
|
+
logger$$.error('attempted_upstream_loop', {
|
|
12907
12907
|
envelopeId: processedEnvelope.id,
|
|
12908
12908
|
});
|
|
12909
12909
|
}
|
|
12910
12910
|
return;
|
|
12911
12911
|
}
|
|
12912
12912
|
if (!processedEnvelope.to) {
|
|
12913
|
-
logger
|
|
12913
|
+
logger$$.error('dropping_envelope_without_destination', {
|
|
12914
12914
|
envelopeId: processedEnvelope.id,
|
|
12915
12915
|
capabilities: processedEnvelope.capabilities ?? [],
|
|
12916
12916
|
});
|
|
12917
12917
|
return;
|
|
12918
12918
|
}
|
|
12919
|
-
logger
|
|
12919
|
+
logger$$.warning('no_local_handler_for_address', {
|
|
12920
12920
|
address: processedEnvelope.to.toString?.() ?? String(processedEnvelope.to),
|
|
12921
12921
|
originType: context?.originType ?? null,
|
|
12922
12922
|
});
|
|
@@ -13040,7 +13040,7 @@ class FameNode extends TaskSpawner {
|
|
|
13040
13040
|
}
|
|
13041
13041
|
}
|
|
13042
13042
|
catch (error) {
|
|
13043
|
-
logger
|
|
13043
|
+
logger$$.warning('callback_grant_collection_failed', {
|
|
13044
13044
|
error: error instanceof Error ? error.message : String(error),
|
|
13045
13045
|
});
|
|
13046
13046
|
}
|
|
@@ -13103,7 +13103,7 @@ class FameNode extends TaskSpawner {
|
|
|
13103
13103
|
await store.set('self', record);
|
|
13104
13104
|
}
|
|
13105
13105
|
catch (error) {
|
|
13106
|
-
logger
|
|
13106
|
+
logger$$.warning('node_meta_persist_failed', {
|
|
13107
13107
|
error: error instanceof Error ? error.message : String(error),
|
|
13108
13108
|
});
|
|
13109
13109
|
}
|
|
@@ -13241,44 +13241,12 @@ class ConnectionRetryPolicyFactory extends AbstractResourceFactory {
|
|
|
13241
13241
|
}
|
|
13242
13242
|
}
|
|
13243
13243
|
|
|
13244
|
-
|
|
13245
|
-
|
|
13246
|
-
|
|
13247
|
-
|
|
13248
|
-
|
|
13249
|
-
|
|
13250
|
-
throw new Error('Failed to create token provider from configuration');
|
|
13251
|
-
}
|
|
13252
|
-
return provider;
|
|
13253
|
-
}
|
|
13254
|
-
let provider = null;
|
|
13255
|
-
try {
|
|
13256
|
-
provider = await createDefaultResource(TOKEN_PROVIDER_FACTORY_BASE_TYPE, null, options);
|
|
13257
|
-
}
|
|
13258
|
-
catch (error) {
|
|
13259
|
-
const message = 'Failed to create default token provider' +
|
|
13260
|
-
(error instanceof Error && error.message ? `: ${error.message}` : '');
|
|
13261
|
-
throw new Error(message);
|
|
13262
|
-
}
|
|
13263
|
-
if (!provider) {
|
|
13264
|
-
throw new Error('Failed to create default token provider');
|
|
13265
|
-
}
|
|
13266
|
-
return provider;
|
|
13267
|
-
}
|
|
13268
|
-
}
|
|
13269
|
-
|
|
13270
|
-
function isTokenProvider(candidate) {
|
|
13271
|
-
return (typeof candidate === 'object' &&
|
|
13272
|
-
candidate !== null &&
|
|
13273
|
-
typeof candidate.getToken === 'function');
|
|
13274
|
-
}
|
|
13275
|
-
function isIdentityExposingTokenProvider(candidate) {
|
|
13276
|
-
return (isTokenProvider(candidate) &&
|
|
13277
|
-
typeof candidate.getIdentity ===
|
|
13278
|
-
'function');
|
|
13279
|
-
}
|
|
13280
|
-
|
|
13281
|
-
const logger$$ = getLogger('naylence.fame.node.default_node_identity_policy');
|
|
13244
|
+
/**
|
|
13245
|
+
* Default node identity policy that preserves the current node ID.
|
|
13246
|
+
*
|
|
13247
|
+
* This policy does NOT derive identity from tokens or grants.
|
|
13248
|
+
* For token-subject-based identity, use TokenSubjectNodeIdentityPolicy.
|
|
13249
|
+
*/
|
|
13282
13250
|
class DefaultNodeIdentityPolicy {
|
|
13283
13251
|
async resolveInitialNodeId(context) {
|
|
13284
13252
|
if (context.configuredId) {
|
|
@@ -13290,44 +13258,10 @@ class DefaultNodeIdentityPolicy {
|
|
|
13290
13258
|
return await generateIdAsync({ mode: 'fingerprint' });
|
|
13291
13259
|
}
|
|
13292
13260
|
async resolveAdmissionNodeId(context) {
|
|
13293
|
-
|
|
13294
|
-
|
|
13295
|
-
for (const grant of context.grants) {
|
|
13296
|
-
try {
|
|
13297
|
-
const auth = grant.auth;
|
|
13298
|
-
if (!auth) {
|
|
13299
|
-
continue;
|
|
13300
|
-
}
|
|
13301
|
-
const tokenProviderConfig = (auth.tokenProvider ??
|
|
13302
|
-
auth.token_provider);
|
|
13303
|
-
if (!tokenProviderConfig ||
|
|
13304
|
-
typeof tokenProviderConfig.type !== 'string') {
|
|
13305
|
-
continue;
|
|
13306
|
-
}
|
|
13307
|
-
const provider = await TokenProviderFactory.createTokenProvider(tokenProviderConfig);
|
|
13308
|
-
if (isIdentityExposingTokenProvider(provider)) {
|
|
13309
|
-
const identity = await provider.getIdentity();
|
|
13310
|
-
if (identity && identity.subject) {
|
|
13311
|
-
logger$$.debug('identity_extracted_from_grant', {
|
|
13312
|
-
identity_id: identity.subject,
|
|
13313
|
-
grant_type: grant.type,
|
|
13314
|
-
});
|
|
13315
|
-
return identity.subject;
|
|
13316
|
-
}
|
|
13317
|
-
}
|
|
13318
|
-
}
|
|
13319
|
-
catch (error) {
|
|
13320
|
-
logger$$.warning('identity_extraction_failed', {
|
|
13321
|
-
error: error instanceof Error ? error.message : String(error),
|
|
13322
|
-
grant_type: grant.type,
|
|
13323
|
-
});
|
|
13324
|
-
}
|
|
13325
|
-
}
|
|
13326
|
-
}
|
|
13327
|
-
if (!context.currentNodeId) {
|
|
13328
|
-
return await generateIdAsync({ mode: 'fingerprint' });
|
|
13261
|
+
if (context.currentNodeId) {
|
|
13262
|
+
return context.currentNodeId;
|
|
13329
13263
|
}
|
|
13330
|
-
return
|
|
13264
|
+
return await generateIdAsync({ mode: 'fingerprint' });
|
|
13331
13265
|
}
|
|
13332
13266
|
}
|
|
13333
13267
|
|
|
@@ -16090,6 +16024,43 @@ var defaultNodeIdentityPolicyFactory = /*#__PURE__*/Object.freeze({
|
|
|
16090
16024
|
default: DefaultNodeIdentityPolicyFactory
|
|
16091
16025
|
});
|
|
16092
16026
|
|
|
16027
|
+
const TOKEN_PROVIDER_FACTORY_BASE_TYPE = 'TokenProviderFactory';
|
|
16028
|
+
class TokenProviderFactory extends AbstractResourceFactory {
|
|
16029
|
+
static async createTokenProvider(config, options = {}) {
|
|
16030
|
+
if (config) {
|
|
16031
|
+
const provider = await createResource$1(TOKEN_PROVIDER_FACTORY_BASE_TYPE, config, options);
|
|
16032
|
+
if (!provider) {
|
|
16033
|
+
throw new Error('Failed to create token provider from configuration');
|
|
16034
|
+
}
|
|
16035
|
+
return provider;
|
|
16036
|
+
}
|
|
16037
|
+
let provider = null;
|
|
16038
|
+
try {
|
|
16039
|
+
provider = await createDefaultResource(TOKEN_PROVIDER_FACTORY_BASE_TYPE, null, options);
|
|
16040
|
+
}
|
|
16041
|
+
catch (error) {
|
|
16042
|
+
const message = 'Failed to create default token provider' +
|
|
16043
|
+
(error instanceof Error && error.message ? `: ${error.message}` : '');
|
|
16044
|
+
throw new Error(message);
|
|
16045
|
+
}
|
|
16046
|
+
if (!provider) {
|
|
16047
|
+
throw new Error('Failed to create default token provider');
|
|
16048
|
+
}
|
|
16049
|
+
return provider;
|
|
16050
|
+
}
|
|
16051
|
+
}
|
|
16052
|
+
|
|
16053
|
+
function isTokenProvider(candidate) {
|
|
16054
|
+
return (typeof candidate === 'object' &&
|
|
16055
|
+
candidate !== null &&
|
|
16056
|
+
typeof candidate.getToken === 'function');
|
|
16057
|
+
}
|
|
16058
|
+
function isIdentityExposingTokenProvider(candidate) {
|
|
16059
|
+
return (isTokenProvider(candidate) &&
|
|
16060
|
+
typeof candidate.getIdentity ===
|
|
16061
|
+
'function');
|
|
16062
|
+
}
|
|
16063
|
+
|
|
16093
16064
|
const logger$W = getLogger('naylence.fame.node.token_subject_node_identity_policy');
|
|
16094
16065
|
class TokenSubjectNodeIdentityPolicy {
|
|
16095
16066
|
async resolveInitialNodeId(context) {
|