@naylence/runtime 0.3.15 → 0.3.17
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 +663 -442
- package/dist/browser/index.mjs +659 -443
- package/dist/cjs/naylence/fame/factory-manifest.js +2 -0
- package/dist/cjs/naylence/fame/node/connection-retry-policy-factory.js +22 -0
- package/dist/cjs/naylence/fame/node/connection-retry-policy.js +2 -0
- package/dist/cjs/naylence/fame/node/default-connection-retry-policy-factory.js +36 -0
- package/dist/cjs/naylence/fame/node/default-connection-retry-policy.js +51 -0
- package/dist/cjs/naylence/fame/node/factory-commons.js +15 -0
- package/dist/cjs/naylence/fame/node/index.js +6 -1
- package/dist/cjs/naylence/fame/node/node-config.js +4 -0
- package/dist/cjs/naylence/fame/node/node-factory.js +1 -0
- package/dist/cjs/naylence/fame/node/node.js +3 -0
- package/dist/cjs/naylence/fame/node/upstream-session-manager.js +63 -23
- package/dist/cjs/naylence/fame/security/auth/oauth2-authorizer-factory.js +7 -0
- package/dist/cjs/naylence/fame/security/auth/oauth2-authorizer.js +41 -0
- package/dist/cjs/naylence/fame/sentinel/sentinel.js +2 -0
- package/dist/cjs/version.js +2 -2
- package/dist/esm/naylence/fame/factory-manifest.js +2 -0
- package/dist/esm/naylence/fame/node/connection-retry-policy-factory.js +18 -0
- package/dist/esm/naylence/fame/node/connection-retry-policy.js +1 -0
- package/dist/esm/naylence/fame/node/default-connection-retry-policy-factory.js +32 -0
- package/dist/esm/naylence/fame/node/default-connection-retry-policy.js +47 -0
- package/dist/esm/naylence/fame/node/factory-commons.js +15 -0
- package/dist/esm/naylence/fame/node/index.js +4 -0
- package/dist/esm/naylence/fame/node/node-config.js +4 -0
- package/dist/esm/naylence/fame/node/node-factory.js +1 -0
- package/dist/esm/naylence/fame/node/node.js +3 -0
- package/dist/esm/naylence/fame/node/upstream-session-manager.js +63 -23
- package/dist/esm/naylence/fame/security/auth/oauth2-authorizer-factory.js +7 -0
- package/dist/esm/naylence/fame/security/auth/oauth2-authorizer.js +42 -1
- package/dist/esm/naylence/fame/sentinel/sentinel.js +2 -0
- package/dist/esm/version.js +2 -2
- package/dist/node/index.cjs +663 -442
- package/dist/node/index.mjs +659 -443
- package/dist/node/node.cjs +687 -466
- package/dist/node/node.mjs +683 -467
- package/dist/types/naylence/fame/factory-manifest.d.ts +1 -1
- package/dist/types/naylence/fame/node/connection-retry-policy-factory.d.ts +20 -0
- package/dist/types/naylence/fame/node/connection-retry-policy.d.ts +44 -0
- package/dist/types/naylence/fame/node/default-connection-retry-policy-factory.d.ts +15 -0
- package/dist/types/naylence/fame/node/default-connection-retry-policy.d.ts +36 -0
- package/dist/types/naylence/fame/node/factory-commons.d.ts +2 -0
- package/dist/types/naylence/fame/node/index.d.ts +4 -0
- package/dist/types/naylence/fame/node/node-config.d.ts +2 -0
- package/dist/types/naylence/fame/node/node.d.ts +3 -0
- package/dist/types/naylence/fame/node/upstream-session-manager.d.ts +13 -0
- package/dist/types/naylence/fame/security/auth/oauth2-authorizer-factory.d.ts +2 -0
- package/dist/types/naylence/fame/security/auth/oauth2-authorizer.d.ts +3 -0
- package/dist/types/naylence/fame/sentinel/sentinel.d.ts +1 -0
- package/dist/types/version.d.ts +1 -1
- package/package.json +1 -1
package/dist/browser/index.cjs
CHANGED
|
@@ -122,6 +122,7 @@ const MODULES = [
|
|
|
122
122
|
"./node/admission/direct-admission-client-factory.js",
|
|
123
123
|
"./node/admission/noop-admission-client-factory.js",
|
|
124
124
|
"./node/admission/welcome-service-client-factory.js",
|
|
125
|
+
"./node/default-connection-retry-policy-factory.js",
|
|
125
126
|
"./node/default-node-identity-policy-factory.js",
|
|
126
127
|
"./node/node-factory.js",
|
|
127
128
|
"./node/node-identity-policy-profile-factory.js",
|
|
@@ -200,6 +201,7 @@ const MODULE_LOADERS = {
|
|
|
200
201
|
"./node/admission/direct-admission-client-factory.js": () => Promise.resolve().then(function () { return directAdmissionClientFactory; }),
|
|
201
202
|
"./node/admission/noop-admission-client-factory.js": () => Promise.resolve().then(function () { return noopAdmissionClientFactory; }),
|
|
202
203
|
"./node/admission/welcome-service-client-factory.js": () => Promise.resolve().then(function () { return welcomeServiceClientFactory; }),
|
|
204
|
+
"./node/default-connection-retry-policy-factory.js": () => Promise.resolve().then(function () { return defaultConnectionRetryPolicyFactory; }),
|
|
203
205
|
"./node/default-node-identity-policy-factory.js": () => Promise.resolve().then(function () { return defaultNodeIdentityPolicyFactory; }),
|
|
204
206
|
"./node/node-factory.js": () => Promise.resolve().then(function () { return nodeFactory; }),
|
|
205
207
|
"./node/node-identity-policy-profile-factory.js": () => Promise.resolve().then(function () { return nodeIdentityPolicyProfileFactory; }),
|
|
@@ -513,12 +515,12 @@ async function ensureRuntimeFactoriesRegistered(registry = factory.Registry) {
|
|
|
513
515
|
}
|
|
514
516
|
|
|
515
517
|
// This file is auto-generated during build - do not edit manually
|
|
516
|
-
// Generated from package.json version: 0.3.
|
|
518
|
+
// Generated from package.json version: 0.3.17
|
|
517
519
|
/**
|
|
518
520
|
* The package version, injected at build time.
|
|
519
521
|
* @internal
|
|
520
522
|
*/
|
|
521
|
-
const VERSION = '0.3.
|
|
523
|
+
const VERSION = '0.3.17';
|
|
522
524
|
|
|
523
525
|
let initialized = false;
|
|
524
526
|
const runtimePlugin = {
|
|
@@ -1363,7 +1365,7 @@ class TaskCancelledError extends Error {
|
|
|
1363
1365
|
* Provides functionality similar to Python's asyncio TaskSpawner with proper
|
|
1364
1366
|
* error handling, cancellation, and graceful shutdown capabilities.
|
|
1365
1367
|
*/
|
|
1366
|
-
const logger$
|
|
1368
|
+
const logger$1h = getLogger('naylence.fame.util.task_spawner');
|
|
1367
1369
|
function firstDefined(source, keys) {
|
|
1368
1370
|
for (const key of keys) {
|
|
1369
1371
|
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
@@ -1524,7 +1526,7 @@ class TaskSpawner {
|
|
|
1524
1526
|
const taskId = `task-${++this._taskCounter}`;
|
|
1525
1527
|
const taskName = normalizedOptions.name || `unnamed-${taskId}`;
|
|
1526
1528
|
const timeout = normalizedOptions.timeout ?? this._config.defaultTimeout;
|
|
1527
|
-
logger$
|
|
1529
|
+
logger$1h.debug('starting_background_task', {
|
|
1528
1530
|
task_name: taskName,
|
|
1529
1531
|
task_id: taskId,
|
|
1530
1532
|
});
|
|
@@ -1541,7 +1543,7 @@ class TaskSpawner {
|
|
|
1541
1543
|
task.promise
|
|
1542
1544
|
.then(() => {
|
|
1543
1545
|
if (!this._suppressCompletionLogging) {
|
|
1544
|
-
logger$
|
|
1546
|
+
logger$1h.debug('task_completed_successfully', {
|
|
1545
1547
|
task_name: taskName,
|
|
1546
1548
|
task_id: taskId,
|
|
1547
1549
|
duration_ms: Date.now() - task.startTime,
|
|
@@ -1595,7 +1597,7 @@ class TaskSpawner {
|
|
|
1595
1597
|
error.name === 'AbortError' ||
|
|
1596
1598
|
error.message === 'Task cancelled' ||
|
|
1597
1599
|
error.message === 'Aborted') {
|
|
1598
|
-
logger$
|
|
1600
|
+
logger$1h.debug('task_cancelled', {
|
|
1599
1601
|
task_name: taskName,
|
|
1600
1602
|
note: 'Task cancelled as requested',
|
|
1601
1603
|
});
|
|
@@ -1603,7 +1605,7 @@ class TaskSpawner {
|
|
|
1603
1605
|
}
|
|
1604
1606
|
// Handle timeout
|
|
1605
1607
|
if (error instanceof TaskTimeoutError) {
|
|
1606
|
-
logger$
|
|
1608
|
+
logger$1h.warning('task_timed_out', {
|
|
1607
1609
|
task_name: taskName,
|
|
1608
1610
|
error: error.message,
|
|
1609
1611
|
});
|
|
@@ -1615,7 +1617,7 @@ class TaskSpawner {
|
|
|
1615
1617
|
// Handle known WebSocket shutdown race condition (similar to Python version)
|
|
1616
1618
|
if (error.message.includes("await wasn't used with future") ||
|
|
1617
1619
|
error.message.includes('WebSocket closed during receive')) {
|
|
1618
|
-
logger$
|
|
1620
|
+
logger$1h.debug('task_shutdown_race_condition_handled', {
|
|
1619
1621
|
task_name: taskName,
|
|
1620
1622
|
note: 'Normal WebSocket close timing during shutdown - not an error',
|
|
1621
1623
|
});
|
|
@@ -1625,7 +1627,7 @@ class TaskSpawner {
|
|
|
1625
1627
|
if (error.name === 'FameTransportClose' ||
|
|
1626
1628
|
error.message.includes('normal closure') ||
|
|
1627
1629
|
error.message.includes('Connection closed')) {
|
|
1628
|
-
logger$
|
|
1630
|
+
logger$1h.debug('task_shutdown_completed_normally', {
|
|
1629
1631
|
task_name: taskName,
|
|
1630
1632
|
note: 'Task closed normally during shutdown',
|
|
1631
1633
|
});
|
|
@@ -1633,7 +1635,7 @@ class TaskSpawner {
|
|
|
1633
1635
|
}
|
|
1634
1636
|
// Handle PKCE redirect "errors" as info
|
|
1635
1637
|
if (error.name === 'OAuth2PkceRedirectInitiatedError') {
|
|
1636
|
-
logger$
|
|
1638
|
+
logger$1h.debug('background_task_redirecting', {
|
|
1637
1639
|
task_name: taskName,
|
|
1638
1640
|
note: 'Task interrupted for PKCE redirect',
|
|
1639
1641
|
});
|
|
@@ -1646,14 +1648,14 @@ class TaskSpawner {
|
|
|
1646
1648
|
// Log retriable errors as warnings (they'll be retried by upstream logic)
|
|
1647
1649
|
// Log non-retriable errors as errors (fatal failures)
|
|
1648
1650
|
if (isRetriableError) {
|
|
1649
|
-
logger$
|
|
1651
|
+
logger$1h.warning('background_task_failed', {
|
|
1650
1652
|
task_name: taskName,
|
|
1651
1653
|
error: error.message,
|
|
1652
1654
|
retriable: true,
|
|
1653
1655
|
});
|
|
1654
1656
|
}
|
|
1655
1657
|
else {
|
|
1656
|
-
logger$
|
|
1658
|
+
logger$1h.error('background_task_failed', {
|
|
1657
1659
|
task_name: taskName,
|
|
1658
1660
|
error: error.message,
|
|
1659
1661
|
stack: error.stack,
|
|
@@ -1672,11 +1674,11 @@ class TaskSpawner {
|
|
|
1672
1674
|
async shutdownTasks(options = {}) {
|
|
1673
1675
|
const { gracePeriod, cancelHanging, joinTimeout } = normalizeShutdownOptions(options);
|
|
1674
1676
|
if (this._tasks.size === 0) {
|
|
1675
|
-
logger$
|
|
1677
|
+
logger$1h.debug('shutdown_tasks_no_tasks_to_shutdown');
|
|
1676
1678
|
return;
|
|
1677
1679
|
}
|
|
1678
1680
|
this._suppressCompletionLogging = true;
|
|
1679
|
-
logger$
|
|
1681
|
+
logger$1h.debug('shutting_down_tasks', {
|
|
1680
1682
|
task_count: this._tasks.size,
|
|
1681
1683
|
task_names: Array.from(this._tasks.values()).map((t) => t.name),
|
|
1682
1684
|
grace_period_ms: gracePeriod,
|
|
@@ -1691,7 +1693,7 @@ class TaskSpawner {
|
|
|
1691
1693
|
if (cancelHanging) {
|
|
1692
1694
|
const stillRunning = tasks.filter((task) => task.getState() === TaskState.RUNNING && !completed.has(task));
|
|
1693
1695
|
if (stillRunning.length > 0) {
|
|
1694
|
-
logger$
|
|
1696
|
+
logger$1h.debug('tasks_did_not_complete_within_grace_period', {
|
|
1695
1697
|
hanging_count: stillRunning.length,
|
|
1696
1698
|
});
|
|
1697
1699
|
// Wait for them to finish with individual timeouts
|
|
@@ -1701,7 +1703,7 @@ class TaskSpawner {
|
|
|
1701
1703
|
}
|
|
1702
1704
|
catch (error) {
|
|
1703
1705
|
if (error instanceof TaskTimeoutError) {
|
|
1704
|
-
logger$
|
|
1706
|
+
logger$1h.warning('task_did_not_shutdown', {
|
|
1705
1707
|
task_name: task.name || task.id,
|
|
1706
1708
|
join_timeout_ms: joinTimeout,
|
|
1707
1709
|
});
|
|
@@ -1712,7 +1714,7 @@ class TaskSpawner {
|
|
|
1712
1714
|
}
|
|
1713
1715
|
else if (!(error instanceof TaskCancelledError)) {
|
|
1714
1716
|
/* istanbul ignore next - unreachable defensive branch */
|
|
1715
|
-
logger$
|
|
1717
|
+
logger$1h.error('task_raised_during_cancellation', {
|
|
1716
1718
|
task_name: task.name || task.id,
|
|
1717
1719
|
error: error instanceof Error ? error.message : String(error),
|
|
1718
1720
|
});
|
|
@@ -2849,7 +2851,7 @@ async function safeImport(loader, dependencyNameOrOptions, maybeOptions) {
|
|
|
2849
2851
|
* condition/promise and ensure at most one notifier coroutine exists for a
|
|
2850
2852
|
* flow at any time.
|
|
2851
2853
|
*/
|
|
2852
|
-
const logger$
|
|
2854
|
+
const logger$1g = getLogger('naylence.fame.flow.flow_controller');
|
|
2853
2855
|
/**
|
|
2854
2856
|
* Simple condition variable implementation for TypeScript/Node.js
|
|
2855
2857
|
* Similar to Python's asyncio.Condition
|
|
@@ -2983,7 +2985,7 @@ class FlowController {
|
|
|
2983
2985
|
const newBalance = Math.max(0, Math.min(this.initialWindow, prev + delta));
|
|
2984
2986
|
this.credits.set(flowId, newBalance);
|
|
2985
2987
|
const crossedZero = prev <= 0 && newBalance > 0;
|
|
2986
|
-
logger$
|
|
2988
|
+
logger$1g.debug('flow_controller_add_credits', {
|
|
2987
2989
|
flow_id: flowId,
|
|
2988
2990
|
delta,
|
|
2989
2991
|
prev_balance: prev,
|
|
@@ -3003,12 +3005,12 @@ class FlowController {
|
|
|
3003
3005
|
async acquire(flowId) {
|
|
3004
3006
|
this.ensureFlow(flowId);
|
|
3005
3007
|
const condition = this.conditions.get(flowId);
|
|
3006
|
-
logger$
|
|
3008
|
+
logger$1g.debug('flow_controller_acquire_attempt', {
|
|
3007
3009
|
flow_id: flowId,
|
|
3008
3010
|
current_balance: this.credits.get(flowId),
|
|
3009
3011
|
});
|
|
3010
3012
|
while (this.credits.get(flowId) <= 0) {
|
|
3011
|
-
logger$
|
|
3013
|
+
logger$1g.debug('flow_controller_waiting_for_credits', {
|
|
3012
3014
|
flow_id: flowId,
|
|
3013
3015
|
current_balance: this.credits.get(flowId),
|
|
3014
3016
|
});
|
|
@@ -3016,12 +3018,12 @@ class FlowController {
|
|
|
3016
3018
|
}
|
|
3017
3019
|
const newBalance = this.credits.get(flowId) - 1;
|
|
3018
3020
|
this.credits.set(flowId, newBalance);
|
|
3019
|
-
logger$
|
|
3021
|
+
logger$1g.debug('flow_controller_acquire_success', {
|
|
3020
3022
|
flow_id: flowId,
|
|
3021
3023
|
new_balance: newBalance,
|
|
3022
3024
|
});
|
|
3023
3025
|
if (newBalance <= this.lowWatermark) {
|
|
3024
|
-
logger$
|
|
3026
|
+
logger$1g.debug('flow_controller_acquire_below_low_watermark', {
|
|
3025
3027
|
flow_id: flowId,
|
|
3026
3028
|
low_watermark: this.lowWatermark,
|
|
3027
3029
|
});
|
|
@@ -3045,7 +3047,7 @@ class FlowController {
|
|
|
3045
3047
|
const current = this.credits.get(flowId);
|
|
3046
3048
|
const remaining = Math.max(current - credits, 0);
|
|
3047
3049
|
this.credits.set(flowId, remaining);
|
|
3048
|
-
logger$
|
|
3050
|
+
logger$1g.debug('flow_controller_consume', {
|
|
3049
3051
|
flow_id: flowId,
|
|
3050
3052
|
requested: credits,
|
|
3051
3053
|
prev_balance: current,
|
|
@@ -3071,7 +3073,7 @@ class FlowController {
|
|
|
3071
3073
|
this.windowIds.delete(flowId);
|
|
3072
3074
|
this.credits.set(flowId, this.initialWindow);
|
|
3073
3075
|
this.wakeWaiters(flowId);
|
|
3074
|
-
logger$
|
|
3076
|
+
logger$1g.debug('flow_controller_flow_reset', {
|
|
3075
3077
|
flow_id: flowId,
|
|
3076
3078
|
reset_balance: this.initialWindow,
|
|
3077
3079
|
});
|
|
@@ -3359,7 +3361,7 @@ class InMemoryBinding {
|
|
|
3359
3361
|
* TypeScript port of Python's InMemoryFanoutBroker that extends TaskSpawner
|
|
3360
3362
|
* to manage multiple WriteChannel subscribers with concurrent message distribution.
|
|
3361
3363
|
*/
|
|
3362
|
-
const logger$
|
|
3364
|
+
const logger$1f = getLogger('naylence.fame.channel.in_memory.in_memory_fanout_broker');
|
|
3363
3365
|
// Sentinel object for shutdown signaling
|
|
3364
3366
|
const SENTINEL = Symbol('fanout-broker-sentinel');
|
|
3365
3367
|
function isCloseable(obj) {
|
|
@@ -3412,7 +3414,7 @@ class InMemoryFanoutBroker extends TaskSpawner {
|
|
|
3412
3414
|
}
|
|
3413
3415
|
catch (error) {
|
|
3414
3416
|
// Ignore errors when sending sentinel (sink might be closed)
|
|
3415
|
-
logger$
|
|
3417
|
+
logger$1f.debug('error_sending_sentinel', {
|
|
3416
3418
|
error: error.message,
|
|
3417
3419
|
});
|
|
3418
3420
|
}
|
|
@@ -3426,7 +3428,7 @@ class InMemoryFanoutBroker extends TaskSpawner {
|
|
|
3426
3428
|
await sub.close();
|
|
3427
3429
|
}
|
|
3428
3430
|
catch (error) {
|
|
3429
|
-
logger$
|
|
3431
|
+
logger$1f.error('error_closing_subscriber', {
|
|
3430
3432
|
subscriber: sub.toString(),
|
|
3431
3433
|
error: error.message,
|
|
3432
3434
|
});
|
|
@@ -3466,7 +3468,7 @@ class InMemoryFanoutBroker extends TaskSpawner {
|
|
|
3466
3468
|
[envelope, context] = core.extractEnvelopeAndContext(msg);
|
|
3467
3469
|
}
|
|
3468
3470
|
catch (error) {
|
|
3469
|
-
logger$
|
|
3471
|
+
logger$1f.debug('failed_to_extract_envelope', {
|
|
3470
3472
|
error: error.message,
|
|
3471
3473
|
});
|
|
3472
3474
|
continue;
|
|
@@ -3488,7 +3490,7 @@ class InMemoryFanoutBroker extends TaskSpawner {
|
|
|
3488
3490
|
await sub.send(messageToSend);
|
|
3489
3491
|
}
|
|
3490
3492
|
catch (error) {
|
|
3491
|
-
logger$
|
|
3493
|
+
logger$1f.error('error_sending_to_subscriber', {
|
|
3492
3494
|
subscriber: sub.toString(),
|
|
3493
3495
|
error: error.message,
|
|
3494
3496
|
action: 'unsubscribing',
|
|
@@ -3504,7 +3506,7 @@ class InMemoryFanoutBroker extends TaskSpawner {
|
|
|
3504
3506
|
}
|
|
3505
3507
|
catch (error) {
|
|
3506
3508
|
// Critical broker-level error: log and back off, but keep the loop running
|
|
3507
|
-
logger$
|
|
3509
|
+
logger$1f.critical('receive_loop_failed_unexpectedly', {
|
|
3508
3510
|
error: error.message,
|
|
3509
3511
|
stack: error.stack,
|
|
3510
3512
|
});
|
|
@@ -3722,7 +3724,7 @@ class EnvCredentialProviderFactory extends CredentialProviderFactory {
|
|
|
3722
3724
|
return new EnvCredentialProvider(resolved.varName);
|
|
3723
3725
|
}
|
|
3724
3726
|
}
|
|
3725
|
-
const FACTORY_META$
|
|
3727
|
+
const FACTORY_META$1c = {
|
|
3726
3728
|
base: CREDENTIAL_PROVIDER_FACTORY_BASE_TYPE,
|
|
3727
3729
|
key: 'EnvCredentialProvider',
|
|
3728
3730
|
};
|
|
@@ -3730,7 +3732,7 @@ const FACTORY_META$1b = {
|
|
|
3730
3732
|
var envCredentialProviderFactory = /*#__PURE__*/Object.freeze({
|
|
3731
3733
|
__proto__: null,
|
|
3732
3734
|
EnvCredentialProviderFactory: EnvCredentialProviderFactory,
|
|
3733
|
-
FACTORY_META: FACTORY_META$
|
|
3735
|
+
FACTORY_META: FACTORY_META$1c,
|
|
3734
3736
|
default: EnvCredentialProviderFactory,
|
|
3735
3737
|
normalizeEnvConfig: normalizeEnvConfig
|
|
3736
3738
|
});
|
|
@@ -3828,14 +3830,14 @@ class PromptCredentialProviderFactory extends CredentialProviderFactory {
|
|
|
3828
3830
|
return new PromptCredentialProvider(resolved.credentialName);
|
|
3829
3831
|
}
|
|
3830
3832
|
}
|
|
3831
|
-
const FACTORY_META$
|
|
3833
|
+
const FACTORY_META$1b = {
|
|
3832
3834
|
base: CREDENTIAL_PROVIDER_FACTORY_BASE_TYPE,
|
|
3833
3835
|
key: 'PromptCredentialProvider',
|
|
3834
3836
|
};
|
|
3835
3837
|
|
|
3836
3838
|
var promptCredentialProviderFactory = /*#__PURE__*/Object.freeze({
|
|
3837
3839
|
__proto__: null,
|
|
3838
|
-
FACTORY_META: FACTORY_META$
|
|
3840
|
+
FACTORY_META: FACTORY_META$1b,
|
|
3839
3841
|
PromptCredentialProviderFactory: PromptCredentialProviderFactory,
|
|
3840
3842
|
default: PromptCredentialProviderFactory,
|
|
3841
3843
|
normalizePromptConfig: normalizePromptConfig
|
|
@@ -3889,14 +3891,14 @@ class SecretStoreCredentialProviderFactory extends CredentialProviderFactory {
|
|
|
3889
3891
|
return new SecretStoreCredentialProvider(resolved.secretName);
|
|
3890
3892
|
}
|
|
3891
3893
|
}
|
|
3892
|
-
const FACTORY_META$
|
|
3894
|
+
const FACTORY_META$1a = {
|
|
3893
3895
|
base: CREDENTIAL_PROVIDER_FACTORY_BASE_TYPE,
|
|
3894
3896
|
key: 'SecretStoreCredentialProvider',
|
|
3895
3897
|
};
|
|
3896
3898
|
|
|
3897
3899
|
var secretStoreCredentialProviderFactory = /*#__PURE__*/Object.freeze({
|
|
3898
3900
|
__proto__: null,
|
|
3899
|
-
FACTORY_META: FACTORY_META$
|
|
3901
|
+
FACTORY_META: FACTORY_META$1a,
|
|
3900
3902
|
SecretStoreCredentialProviderFactory: SecretStoreCredentialProviderFactory,
|
|
3901
3903
|
default: SecretStoreCredentialProviderFactory,
|
|
3902
3904
|
normalizeSecretStoreConfig: normalizeSecretStoreConfig
|
|
@@ -3945,14 +3947,14 @@ class StaticCredentialProviderFactory extends CredentialProviderFactory {
|
|
|
3945
3947
|
return new StaticCredentialProvider(resolved.credentialValue);
|
|
3946
3948
|
}
|
|
3947
3949
|
}
|
|
3948
|
-
const FACTORY_META$
|
|
3950
|
+
const FACTORY_META$19 = {
|
|
3949
3951
|
base: CREDENTIAL_PROVIDER_FACTORY_BASE_TYPE,
|
|
3950
3952
|
key: 'StaticCredentialProvider',
|
|
3951
3953
|
};
|
|
3952
3954
|
|
|
3953
3955
|
var staticCredentialProviderFactory = /*#__PURE__*/Object.freeze({
|
|
3954
3956
|
__proto__: null,
|
|
3955
|
-
FACTORY_META: FACTORY_META$
|
|
3957
|
+
FACTORY_META: FACTORY_META$19,
|
|
3956
3958
|
StaticCredentialProviderFactory: StaticCredentialProviderFactory,
|
|
3957
3959
|
default: StaticCredentialProviderFactory,
|
|
3958
3960
|
normalizeStaticConfig: normalizeStaticConfig
|
|
@@ -5180,7 +5182,7 @@ function normalizeResponseType(value) {
|
|
|
5180
5182
|
return value;
|
|
5181
5183
|
}
|
|
5182
5184
|
|
|
5183
|
-
const logger$
|
|
5185
|
+
const logger$1e = getLogger('naylence.fame.node.binding_manager');
|
|
5184
5186
|
const SYSTEM_INBOX$3 = '__sys__';
|
|
5185
5187
|
const DEFAULT_ACK_TIMEOUT_MS = 20000;
|
|
5186
5188
|
class BindingStoreEntryRecord {
|
|
@@ -5266,7 +5268,7 @@ class BindingManager {
|
|
|
5266
5268
|
if (!this.bindings.has(key)) {
|
|
5267
5269
|
const binding = this.bindingFactory(new core.FameAddress(key));
|
|
5268
5270
|
this.bindings.set(key, binding);
|
|
5269
|
-
logger$
|
|
5271
|
+
logger$1e.debug('restored_binding', { address: key });
|
|
5270
5272
|
}
|
|
5271
5273
|
}
|
|
5272
5274
|
if (!this.hasUpstream) {
|
|
@@ -5276,13 +5278,13 @@ class BindingManager {
|
|
|
5276
5278
|
await this.readvertiseCapabilitiesUpstream();
|
|
5277
5279
|
}
|
|
5278
5280
|
async bind(participant, capabilities) {
|
|
5279
|
-
logger$
|
|
5281
|
+
logger$1e.debug('binding_participant', { participant });
|
|
5280
5282
|
const { prefixAddress, addresses, propagateAddress, capabilityAddress } = this.computeBindingAddresses(participant);
|
|
5281
5283
|
for (const address of addresses) {
|
|
5282
5284
|
if (!this.bindings.has(address)) {
|
|
5283
5285
|
const binding = this.bindingFactory(new core.FameAddress(address));
|
|
5284
5286
|
this.bindings.set(address, binding);
|
|
5285
|
-
logger$
|
|
5287
|
+
logger$1e.debug('bound_address', { address, participant });
|
|
5286
5288
|
}
|
|
5287
5289
|
}
|
|
5288
5290
|
let propagatedAddress = null;
|
|
@@ -5311,7 +5313,7 @@ class BindingManager {
|
|
|
5311
5313
|
await this.unbindAddressUpstream(propagatedAddress);
|
|
5312
5314
|
}
|
|
5313
5315
|
catch (rollbackError) {
|
|
5314
|
-
logger$
|
|
5316
|
+
logger$1e.error('bind_rollback_failed', {
|
|
5315
5317
|
address: propagatedAddress.toString(),
|
|
5316
5318
|
error: rollbackError.message,
|
|
5317
5319
|
});
|
|
@@ -5330,7 +5332,7 @@ class BindingManager {
|
|
|
5330
5332
|
physicalPath: null,
|
|
5331
5333
|
});
|
|
5332
5334
|
}
|
|
5333
|
-
logger$
|
|
5335
|
+
logger$1e.debug('bind_success', {
|
|
5334
5336
|
participant,
|
|
5335
5337
|
address: prefixAddress.toString(),
|
|
5336
5338
|
capabilities,
|
|
@@ -5366,7 +5368,7 @@ class BindingManager {
|
|
|
5366
5368
|
await this.bindingStore.delete(address);
|
|
5367
5369
|
}
|
|
5368
5370
|
}
|
|
5369
|
-
logger$
|
|
5371
|
+
logger$1e.debug('unbind_success', {
|
|
5370
5372
|
participant,
|
|
5371
5373
|
address: prefixAddress.toString(),
|
|
5372
5374
|
totalBindings: this.bindings.size,
|
|
@@ -5396,7 +5398,7 @@ class BindingManager {
|
|
|
5396
5398
|
await this.bindAddressUpstream(new core.FameAddress(address));
|
|
5397
5399
|
}
|
|
5398
5400
|
catch (error) {
|
|
5399
|
-
logger$
|
|
5401
|
+
logger$1e.error('rebind_failed', {
|
|
5400
5402
|
address,
|
|
5401
5403
|
error: error.message,
|
|
5402
5404
|
});
|
|
@@ -5415,7 +5417,7 @@ class BindingManager {
|
|
|
5415
5417
|
await this.advertiseCapabilities(new core.FameAddress(address), Array.from(capabilities));
|
|
5416
5418
|
}
|
|
5417
5419
|
catch (error) {
|
|
5418
|
-
logger$
|
|
5420
|
+
logger$1e.error('capability_replay_failed', {
|
|
5419
5421
|
address,
|
|
5420
5422
|
error: error.message,
|
|
5421
5423
|
});
|
|
@@ -5682,7 +5684,7 @@ class BindingManager {
|
|
|
5682
5684
|
}
|
|
5683
5685
|
}
|
|
5684
5686
|
|
|
5685
|
-
const logger$
|
|
5687
|
+
const logger$1d = getLogger('naylence.fame.node.response_context_manager');
|
|
5686
5688
|
function cloneSecurityContext(source) {
|
|
5687
5689
|
if (!source) {
|
|
5688
5690
|
return undefined;
|
|
@@ -5710,7 +5712,7 @@ class ResponseContextManager {
|
|
|
5710
5712
|
security: responseSecurity,
|
|
5711
5713
|
expectedResponseType: core.FameResponseType.NONE,
|
|
5712
5714
|
};
|
|
5713
|
-
logger$
|
|
5715
|
+
logger$1d.debug('created_response_context', {
|
|
5714
5716
|
request_id: requestEnvelope.id,
|
|
5715
5717
|
inherited_crypto_level: responseSecurity?.inboundCryptoLevel ?? null,
|
|
5716
5718
|
channel_id: responseSecurity?.cryptoChannelId ?? null,
|
|
@@ -5730,14 +5732,14 @@ class ResponseContextManager {
|
|
|
5730
5732
|
responseContext.fromSystemId = this.getId();
|
|
5731
5733
|
}
|
|
5732
5734
|
// Envelope-level metadata is intentionally omitted to defer to context usage.
|
|
5733
|
-
logger$
|
|
5735
|
+
logger$1d.debug('ensured_response_metadata', {
|
|
5734
5736
|
response_id: responseEnvelope.id,
|
|
5735
5737
|
request_id: requestEnvelope.id,
|
|
5736
5738
|
});
|
|
5737
5739
|
}
|
|
5738
5740
|
}
|
|
5739
5741
|
|
|
5740
|
-
const logger$
|
|
5742
|
+
const logger$1c = getLogger('naylence.fame.node.streaming_response_handler');
|
|
5741
5743
|
function isObject(value) {
|
|
5742
5744
|
return typeof value === 'object' && value !== null;
|
|
5743
5745
|
}
|
|
@@ -5856,12 +5858,12 @@ class StreamingResponseHandler {
|
|
|
5856
5858
|
}
|
|
5857
5859
|
async handleStreamingFameMessageResponses(responses, requestEnvelope, requestContext) {
|
|
5858
5860
|
const asyncResponses = toAsyncIterable(responses);
|
|
5859
|
-
logger$
|
|
5861
|
+
logger$1c.debug('handling_streaming_fame_message_responses', {
|
|
5860
5862
|
request_id: requestEnvelope.id,
|
|
5861
5863
|
});
|
|
5862
5864
|
for await (const response of asyncResponses) {
|
|
5863
5865
|
if (!response?.envelope) {
|
|
5864
|
-
logger$
|
|
5866
|
+
logger$1c.warning('invalid_streaming_response_type', {
|
|
5865
5867
|
request_id: requestEnvelope.id,
|
|
5866
5868
|
actual_type: typeof response,
|
|
5867
5869
|
});
|
|
@@ -5875,7 +5877,7 @@ class StreamingResponseHandler {
|
|
|
5875
5877
|
}
|
|
5876
5878
|
async handleStreamingResponse(result, requestEnvelope, requestContext, replyTo, requestId) {
|
|
5877
5879
|
const iterable = toAsyncIterable(result);
|
|
5878
|
-
logger$
|
|
5880
|
+
logger$1c.debug('handling_streaming_response', {
|
|
5879
5881
|
request_id: requestId,
|
|
5880
5882
|
reply_to: replyTo,
|
|
5881
5883
|
});
|
|
@@ -5886,7 +5888,7 @@ class StreamingResponseHandler {
|
|
|
5886
5888
|
await this.sendRpcResponse(null, requestEnvelope, requestContext, replyTo, requestId);
|
|
5887
5889
|
}
|
|
5888
5890
|
catch (error) {
|
|
5889
|
-
logger$
|
|
5891
|
+
logger$1c.error('streaming_response_handler_error', {
|
|
5890
5892
|
request_id: requestId,
|
|
5891
5893
|
error: error instanceof Error ? error.message : String(error),
|
|
5892
5894
|
});
|
|
@@ -5913,7 +5915,7 @@ class StreamingResponseHandler {
|
|
|
5913
5915
|
});
|
|
5914
5916
|
const responseContext = this.responseContextManager.createResponseContext(requestEnvelope, requestContext);
|
|
5915
5917
|
this.responseContextManager.ensureResponseMetadata(responseEnvelope, requestEnvelope, responseContext);
|
|
5916
|
-
logger$
|
|
5918
|
+
logger$1c.debug('sending_streaming_rpc_response', {
|
|
5917
5919
|
request_id: requestId,
|
|
5918
5920
|
response_envelope_id: responseEnvelope.id,
|
|
5919
5921
|
reply_to: replyTo,
|
|
@@ -5926,7 +5928,7 @@ class StreamingResponseHandler {
|
|
|
5926
5928
|
}
|
|
5927
5929
|
}
|
|
5928
5930
|
|
|
5929
|
-
const logger$
|
|
5931
|
+
const logger$1b = getLogger('naylence.fame.node.channel_polling_manager');
|
|
5930
5932
|
class ChannelPollingManager {
|
|
5931
5933
|
constructor(deliverWrapper, responseContextManager, streamingResponseHandler) {
|
|
5932
5934
|
this.deliverWrapper = deliverWrapper;
|
|
@@ -5934,7 +5936,7 @@ class ChannelPollingManager {
|
|
|
5934
5936
|
this.streamingResponseHandler = streamingResponseHandler;
|
|
5935
5937
|
}
|
|
5936
5938
|
async startPollingLoop(serviceName, channel, handler, stopState, pollTimeoutMs = core.DEFAULT_POLLING_TIMEOUT_MS) {
|
|
5937
|
-
logger$
|
|
5939
|
+
logger$1b.debug('poll_loop_started', {
|
|
5938
5940
|
recipient: serviceName,
|
|
5939
5941
|
});
|
|
5940
5942
|
try {
|
|
@@ -5942,7 +5944,7 @@ class ChannelPollingManager {
|
|
|
5942
5944
|
while (true) {
|
|
5943
5945
|
if (this.isStopRequested(stopState) && !draining) {
|
|
5944
5946
|
draining = true;
|
|
5945
|
-
logger$
|
|
5947
|
+
logger$1b.debug('poll_loop_draining_pending_messages', {
|
|
5946
5948
|
recipient: serviceName,
|
|
5947
5949
|
});
|
|
5948
5950
|
}
|
|
@@ -5952,7 +5954,7 @@ class ChannelPollingManager {
|
|
|
5952
5954
|
}
|
|
5953
5955
|
catch (error) {
|
|
5954
5956
|
if (error instanceof FameTransportClose) {
|
|
5955
|
-
logger$
|
|
5957
|
+
logger$1b.debug('channel_closed', {
|
|
5956
5958
|
recipient: serviceName,
|
|
5957
5959
|
message: error.message,
|
|
5958
5960
|
});
|
|
@@ -5965,7 +5967,7 @@ class ChannelPollingManager {
|
|
|
5965
5967
|
continue;
|
|
5966
5968
|
}
|
|
5967
5969
|
if (error instanceof Error && error.name === 'AbortError') {
|
|
5968
|
-
logger$
|
|
5970
|
+
logger$1b.debug('listener_cancelled', {
|
|
5969
5971
|
recipient: serviceName,
|
|
5970
5972
|
});
|
|
5971
5973
|
throw error;
|
|
@@ -5977,13 +5979,13 @@ class ChannelPollingManager {
|
|
|
5977
5979
|
continue;
|
|
5978
5980
|
}
|
|
5979
5981
|
if (error instanceof Error && error.message === 'Channel is closed') {
|
|
5980
|
-
logger$
|
|
5982
|
+
logger$1b.debug('channel_closed', {
|
|
5981
5983
|
recipient: serviceName,
|
|
5982
5984
|
});
|
|
5983
5985
|
break;
|
|
5984
5986
|
}
|
|
5985
5987
|
if (error instanceof Error && error.name === 'TaskCancelledError') {
|
|
5986
|
-
logger$
|
|
5988
|
+
logger$1b.debug('listener_cancelled', {
|
|
5987
5989
|
recipient: serviceName,
|
|
5988
5990
|
});
|
|
5989
5991
|
throw error;
|
|
@@ -5995,12 +5997,12 @@ class ChannelPollingManager {
|
|
|
5995
5997
|
continue;
|
|
5996
5998
|
}
|
|
5997
5999
|
if (error instanceof Error && error.message.includes('closed')) {
|
|
5998
|
-
logger$
|
|
6000
|
+
logger$1b.debug('channel_closed', {
|
|
5999
6001
|
recipient: serviceName,
|
|
6000
6002
|
});
|
|
6001
6003
|
break;
|
|
6002
6004
|
}
|
|
6003
|
-
logger$
|
|
6005
|
+
logger$1b.error('transport_error', {
|
|
6004
6006
|
recipient: serviceName,
|
|
6005
6007
|
error: error instanceof Error ? error.message : String(error),
|
|
6006
6008
|
});
|
|
@@ -6016,7 +6018,7 @@ class ChannelPollingManager {
|
|
|
6016
6018
|
}
|
|
6017
6019
|
}
|
|
6018
6020
|
finally {
|
|
6019
|
-
logger$
|
|
6021
|
+
logger$1b.debug('poll_loop_exiting', {
|
|
6020
6022
|
recipient: serviceName,
|
|
6021
6023
|
});
|
|
6022
6024
|
}
|
|
@@ -6029,7 +6031,7 @@ class ChannelPollingManager {
|
|
|
6029
6031
|
await this.processHandlerResult(result, envelope, deliveryContext, serviceName);
|
|
6030
6032
|
}
|
|
6031
6033
|
catch (error) {
|
|
6032
|
-
logger$
|
|
6034
|
+
logger$1b.error('handler_crashed', {
|
|
6033
6035
|
recipient: serviceName,
|
|
6034
6036
|
error: error instanceof Error ? error.message : String(error),
|
|
6035
6037
|
});
|
|
@@ -6043,7 +6045,7 @@ class ChannelPollingManager {
|
|
|
6043
6045
|
return;
|
|
6044
6046
|
}
|
|
6045
6047
|
if (this.streamingResponseHandler.isStreamingFameMessageResponse(result)) {
|
|
6046
|
-
logger$
|
|
6048
|
+
logger$1b.debug('handling_streaming_fame_message_responses', {
|
|
6047
6049
|
service_name: serviceName,
|
|
6048
6050
|
envelope_id: envelope.id,
|
|
6049
6051
|
});
|
|
@@ -6051,7 +6053,7 @@ class ChannelPollingManager {
|
|
|
6051
6053
|
}
|
|
6052
6054
|
}
|
|
6053
6055
|
async handleMessageResponse(response, requestEnvelope, requestContext, serviceName) {
|
|
6054
|
-
logger$
|
|
6056
|
+
logger$1b.debug('delivering_envelope_response_message', {
|
|
6055
6057
|
service_name: serviceName,
|
|
6056
6058
|
response_envelope_id: response.envelope.id,
|
|
6057
6059
|
});
|
|
@@ -6071,7 +6073,7 @@ class ChannelPollingManager {
|
|
|
6071
6073
|
}
|
|
6072
6074
|
}
|
|
6073
6075
|
|
|
6074
|
-
const logger$
|
|
6076
|
+
const logger$1a = getLogger('naylence.fame.node.rpc_server_handler');
|
|
6075
6077
|
function isPlainRecord$6(value) {
|
|
6076
6078
|
if (typeof value !== 'object' || value === null) {
|
|
6077
6079
|
return false;
|
|
@@ -6115,13 +6117,13 @@ class RPCServerHandler {
|
|
|
6115
6117
|
}
|
|
6116
6118
|
async handleRpcRequest(envelope, handlerContext, handler, serviceName) {
|
|
6117
6119
|
if (!this.isDataFrame(envelope.frame)) {
|
|
6118
|
-
logger$
|
|
6120
|
+
logger$1a.warning('rpc_request_missing_data_frame', {
|
|
6119
6121
|
service_name: serviceName,
|
|
6120
6122
|
envelope_id: envelope.id,
|
|
6121
6123
|
});
|
|
6122
6124
|
return;
|
|
6123
6125
|
}
|
|
6124
|
-
logger$
|
|
6126
|
+
logger$1a.debug('rpc_request_received', {
|
|
6125
6127
|
service_name: serviceName,
|
|
6126
6128
|
envelope_id: envelope.id,
|
|
6127
6129
|
trace_id: envelope.traceId,
|
|
@@ -6133,7 +6135,7 @@ class RPCServerHandler {
|
|
|
6133
6135
|
request = core.parseRequest(envelope.frame.payload);
|
|
6134
6136
|
params = cloneParams(request.params);
|
|
6135
6137
|
const paramKeys = Object.keys(params);
|
|
6136
|
-
logger$
|
|
6138
|
+
logger$1a.debug('parsed_rpc_request', {
|
|
6137
6139
|
service_name: serviceName,
|
|
6138
6140
|
method: request.method,
|
|
6139
6141
|
request_id: request.id,
|
|
@@ -6142,7 +6144,7 @@ class RPCServerHandler {
|
|
|
6142
6144
|
});
|
|
6143
6145
|
}
|
|
6144
6146
|
catch (error) {
|
|
6145
|
-
logger$
|
|
6147
|
+
logger$1a.warning('request_decode_error', {
|
|
6146
6148
|
service_name: serviceName,
|
|
6147
6149
|
envelope_id: envelope.id,
|
|
6148
6150
|
error: error instanceof Error ? error.message : String(error),
|
|
@@ -6150,7 +6152,7 @@ class RPCServerHandler {
|
|
|
6150
6152
|
return;
|
|
6151
6153
|
}
|
|
6152
6154
|
if (request.id == null) {
|
|
6153
|
-
logger$
|
|
6155
|
+
logger$1a.warning('request_missing_id', {
|
|
6154
6156
|
service_name: serviceName,
|
|
6155
6157
|
envelope_id: envelope.id,
|
|
6156
6158
|
});
|
|
@@ -6158,7 +6160,7 @@ class RPCServerHandler {
|
|
|
6158
6160
|
}
|
|
6159
6161
|
const replyTo = this.resolveReplyTo(envelope, params);
|
|
6160
6162
|
if (!replyTo) {
|
|
6161
|
-
logger$
|
|
6163
|
+
logger$1a.warning('missing_reply_to', {
|
|
6162
6164
|
service_name: serviceName,
|
|
6163
6165
|
envelope_id: envelope.id,
|
|
6164
6166
|
request_id: request.id,
|
|
@@ -6167,13 +6169,13 @@ class RPCServerHandler {
|
|
|
6167
6169
|
}
|
|
6168
6170
|
let handlerResult;
|
|
6169
6171
|
try {
|
|
6170
|
-
logger$
|
|
6172
|
+
logger$1a.debug('calling_rpc_handler', {
|
|
6171
6173
|
service_name: serviceName,
|
|
6172
6174
|
method: request.method,
|
|
6173
6175
|
request_id: request.id,
|
|
6174
6176
|
});
|
|
6175
6177
|
handlerResult = await handler(request.method, params);
|
|
6176
|
-
logger$
|
|
6178
|
+
logger$1a.debug('rpc_handler_returned', {
|
|
6177
6179
|
service_name: serviceName,
|
|
6178
6180
|
method: request.method,
|
|
6179
6181
|
request_id: request.id,
|
|
@@ -6182,7 +6184,7 @@ class RPCServerHandler {
|
|
|
6182
6184
|
});
|
|
6183
6185
|
}
|
|
6184
6186
|
catch (error) {
|
|
6185
|
-
logger$
|
|
6187
|
+
logger$1a.error('rpc_handler_error', {
|
|
6186
6188
|
service_name: serviceName,
|
|
6187
6189
|
request_id: request.id,
|
|
6188
6190
|
envelope_id: envelope.id,
|
|
@@ -6192,7 +6194,7 @@ class RPCServerHandler {
|
|
|
6192
6194
|
return this.createTraditionalResponse(response, request.id, envelope, replyTo, handlerContext, serviceName);
|
|
6193
6195
|
}
|
|
6194
6196
|
if (core.isFameMessageResponse(handlerResult)) {
|
|
6195
|
-
logger$
|
|
6197
|
+
logger$1a.debug('returning_response_message', {
|
|
6196
6198
|
service_name: serviceName,
|
|
6197
6199
|
request_id: request.id,
|
|
6198
6200
|
response_envelope_id: handlerResult.envelope.id,
|
|
@@ -6200,7 +6202,7 @@ class RPCServerHandler {
|
|
|
6200
6202
|
return handlerResult;
|
|
6201
6203
|
}
|
|
6202
6204
|
if (this.streamingResponseHandler.isStreamingResult(handlerResult)) {
|
|
6203
|
-
logger$
|
|
6205
|
+
logger$1a.debug('handling_streaming_response', {
|
|
6204
6206
|
service_name: serviceName,
|
|
6205
6207
|
request_id: request.id,
|
|
6206
6208
|
envelope_id: envelope.id,
|
|
@@ -6229,7 +6231,7 @@ class RPCServerHandler {
|
|
|
6229
6231
|
return null;
|
|
6230
6232
|
}
|
|
6231
6233
|
async createTraditionalResponse(payload, requestId, requestEnvelope, replyTo, handlerContext, serviceName) {
|
|
6232
|
-
logger$
|
|
6234
|
+
logger$1a.debug('creating_traditional_response_envelope', {
|
|
6233
6235
|
service_name: serviceName,
|
|
6234
6236
|
request_id: requestId,
|
|
6235
6237
|
envelope_id: requestEnvelope.id,
|
|
@@ -6253,7 +6255,7 @@ class RPCServerHandler {
|
|
|
6253
6255
|
if (requestEnvelope.id) {
|
|
6254
6256
|
responseContext.meta['response-to-id'] = requestEnvelope.id;
|
|
6255
6257
|
}
|
|
6256
|
-
logger$
|
|
6258
|
+
logger$1a.debug('returning_traditional_response', {
|
|
6257
6259
|
service_name: serviceName,
|
|
6258
6260
|
request_id: requestId,
|
|
6259
6261
|
envelope_id: requestEnvelope.id,
|
|
@@ -6318,7 +6320,7 @@ function normalizeErrorCode(code) {
|
|
|
6318
6320
|
return code;
|
|
6319
6321
|
}
|
|
6320
6322
|
|
|
6321
|
-
const logger$
|
|
6323
|
+
const logger$19 = getLogger('naylence.fame.node.rpc_client_manager');
|
|
6322
6324
|
function isPlainRecord$5(value) {
|
|
6323
6325
|
if (typeof value !== 'object' || value === null) {
|
|
6324
6326
|
return false;
|
|
@@ -6535,7 +6537,7 @@ class RPCClientManager {
|
|
|
6535
6537
|
const metaReason = tracked.meta?.['nack_reason'];
|
|
6536
6538
|
const formattedMessage = formatDeliveryErrorMessage(typeof metaCode === 'string' ? metaCode : 'DELIVERY_ERROR', reason ??
|
|
6537
6539
|
(typeof metaReason === 'string' ? metaReason : undefined));
|
|
6538
|
-
logger$
|
|
6540
|
+
logger$19.debug('pending_request_rejected_by_delivery_nack', {
|
|
6539
6541
|
envelope_id: envelopeId,
|
|
6540
6542
|
request_id: requestId,
|
|
6541
6543
|
code: typeof metaCode === 'string' ? metaCode : 'DELIVERY_ERROR',
|
|
@@ -6558,7 +6560,7 @@ class RPCClientManager {
|
|
|
6558
6560
|
this.trackerWithEvents.removeEventHandler?.(this.trackerEventHandler);
|
|
6559
6561
|
}
|
|
6560
6562
|
catch (error) {
|
|
6561
|
-
logger$
|
|
6563
|
+
logger$19.debug('rpc_tracker_handler_remove_failed', {
|
|
6562
6564
|
error: error instanceof Error ? error.message : String(error),
|
|
6563
6565
|
});
|
|
6564
6566
|
}
|
|
@@ -6601,7 +6603,7 @@ class RPCClientManager {
|
|
|
6601
6603
|
this.rpcListenerAddress = await this.listenCallback(recipient, handler);
|
|
6602
6604
|
this.rpcBound = true;
|
|
6603
6605
|
this.boundPhysicalPath = currentPhysicalPath;
|
|
6604
|
-
logger$
|
|
6606
|
+
logger$19.debug('rpc_reply_listener_bound', {
|
|
6605
6607
|
reply_recipient: recipient,
|
|
6606
6608
|
reply_address: this.rpcReplyAddress?.toString(),
|
|
6607
6609
|
listener_address: this.rpcListenerAddress?.toString(),
|
|
@@ -6695,7 +6697,7 @@ class RPCClientManager {
|
|
|
6695
6697
|
const finalizePromise = this.notifyStreamClosed(envelopeId);
|
|
6696
6698
|
if (finalizePromise) {
|
|
6697
6699
|
finalizePromise.catch((notifyError) => {
|
|
6698
|
-
logger$
|
|
6700
|
+
logger$19.debug('stream_tracker_finalize_failed', {
|
|
6699
6701
|
request_id: requestId,
|
|
6700
6702
|
envelope_id: envelopeId,
|
|
6701
6703
|
error: notifyError instanceof Error
|
|
@@ -6756,7 +6758,7 @@ class RPCClientManager {
|
|
|
6756
6758
|
return iterator;
|
|
6757
6759
|
}
|
|
6758
6760
|
async sendRpcRequest(requestId, envelope, expectedResponseType, timeoutMs) {
|
|
6759
|
-
logger$
|
|
6761
|
+
logger$19.debug('sending_rpc_request', {
|
|
6760
6762
|
envp_id: envelope.id,
|
|
6761
6763
|
corr_id: envelope.corrId,
|
|
6762
6764
|
request_id: requestId,
|
|
@@ -6772,7 +6774,7 @@ class RPCClientManager {
|
|
|
6772
6774
|
}
|
|
6773
6775
|
}
|
|
6774
6776
|
catch (error) {
|
|
6775
|
-
logger$
|
|
6777
|
+
logger$19.warning('delivery_tracker_track_failed', {
|
|
6776
6778
|
request_id: requestId,
|
|
6777
6779
|
error: error instanceof Error ? error.message : String(error),
|
|
6778
6780
|
});
|
|
@@ -6785,14 +6787,14 @@ class RPCClientManager {
|
|
|
6785
6787
|
await this.deliverWrapper()(envelope, context);
|
|
6786
6788
|
}
|
|
6787
6789
|
async handleReplyEnvelope(envelope) {
|
|
6788
|
-
logger$
|
|
6790
|
+
logger$19.debug('handle_reply_envelope_received', {
|
|
6789
6791
|
envelope_id: envelope.id,
|
|
6790
6792
|
corr_id: envelope.corrId,
|
|
6791
6793
|
frame_type: envelope.frame?.['type'],
|
|
6792
6794
|
});
|
|
6793
6795
|
let requestId = envelope.corrId ?? envelope.id;
|
|
6794
6796
|
if (!requestId) {
|
|
6795
|
-
logger$
|
|
6797
|
+
logger$19.warning('reply_envelope_missing_corr_id', {
|
|
6796
6798
|
envelope_id: envelope.id,
|
|
6797
6799
|
});
|
|
6798
6800
|
return;
|
|
@@ -6810,12 +6812,12 @@ class RPCClientManager {
|
|
|
6810
6812
|
}
|
|
6811
6813
|
}
|
|
6812
6814
|
if (!entry) {
|
|
6813
|
-
logger$
|
|
6815
|
+
logger$19.debug('no_pending_request_for_reply', {
|
|
6814
6816
|
request_id: requestId,
|
|
6815
6817
|
});
|
|
6816
6818
|
return;
|
|
6817
6819
|
}
|
|
6818
|
-
logger$
|
|
6820
|
+
logger$19.debug('handle_reply_envelope', {
|
|
6819
6821
|
envelope_id: envelope.id,
|
|
6820
6822
|
request_id: requestId,
|
|
6821
6823
|
corr_id: envelope.corrId,
|
|
@@ -6828,7 +6830,7 @@ class RPCClientManager {
|
|
|
6828
6830
|
const ackIndicatesSuccess = frame.ok === true ||
|
|
6829
6831
|
(frame.ok === undefined && !frame.code && !frame.reason);
|
|
6830
6832
|
if (ackIndicatesSuccess) {
|
|
6831
|
-
logger$
|
|
6833
|
+
logger$19.debug('pending_request_delivery_acknowledged', {
|
|
6832
6834
|
request_id: requestId,
|
|
6833
6835
|
envelope_id: envelope.id,
|
|
6834
6836
|
ref_id: frame.refId ?? null,
|
|
@@ -6856,7 +6858,7 @@ class RPCClientManager {
|
|
|
6856
6858
|
entry.timer = null;
|
|
6857
6859
|
}
|
|
6858
6860
|
if (!this.isDataFrame(envelope.frame)) {
|
|
6859
|
-
logger$
|
|
6861
|
+
logger$19.warning('unexpected_reply_frame_type', {
|
|
6860
6862
|
request_id: requestId,
|
|
6861
6863
|
frame_type: envelope.frame?.['type'],
|
|
6862
6864
|
});
|
|
@@ -6922,7 +6924,7 @@ class RPCClientManager {
|
|
|
6922
6924
|
return;
|
|
6923
6925
|
}
|
|
6924
6926
|
Promise.resolve(this.deliveryTracker.onStreamItem(envelopeId, envelope)).catch((error) => {
|
|
6925
|
-
logger$
|
|
6927
|
+
logger$19.debug('stream_tracker_push_failed', {
|
|
6926
6928
|
envelope_id: envelopeId,
|
|
6927
6929
|
error: error instanceof Error ? error.message : String(error),
|
|
6928
6930
|
});
|
|
@@ -7037,7 +7039,7 @@ function normalizeMailbox(mailbox) {
|
|
|
7037
7039
|
return mailbox;
|
|
7038
7040
|
}
|
|
7039
7041
|
|
|
7040
|
-
const logger$
|
|
7042
|
+
const logger$18 = getLogger('naylence.fame.node.envelope_listener_manager');
|
|
7041
7043
|
const SYSTEM_INBOX$2 = '__sys__';
|
|
7042
7044
|
class EnvelopeListener {
|
|
7043
7045
|
constructor(stopFn, task) {
|
|
@@ -7045,7 +7047,7 @@ class EnvelopeListener {
|
|
|
7045
7047
|
this.task = task;
|
|
7046
7048
|
}
|
|
7047
7049
|
stop() {
|
|
7048
|
-
logger$
|
|
7050
|
+
logger$18.debug('stopping_listener', {
|
|
7049
7051
|
task_name: this.task.name,
|
|
7050
7052
|
});
|
|
7051
7053
|
try {
|
|
@@ -7053,7 +7055,7 @@ class EnvelopeListener {
|
|
|
7053
7055
|
if (maybeCleanup &&
|
|
7054
7056
|
typeof maybeCleanup.then === 'function') {
|
|
7055
7057
|
void maybeCleanup.catch((error) => {
|
|
7056
|
-
logger$
|
|
7058
|
+
logger$18.debug('listener_stop_cleanup_failed', {
|
|
7057
7059
|
task_name: this.task.name,
|
|
7058
7060
|
error: error instanceof Error ? error.message : String(error),
|
|
7059
7061
|
});
|
|
@@ -7061,7 +7063,7 @@ class EnvelopeListener {
|
|
|
7061
7063
|
}
|
|
7062
7064
|
}
|
|
7063
7065
|
catch (error) {
|
|
7064
|
-
logger$
|
|
7066
|
+
logger$18.debug('listener_stop_cleanup_failed', {
|
|
7065
7067
|
task_name: this.task.name,
|
|
7066
7068
|
error: error instanceof Error ? error.message : String(error),
|
|
7067
7069
|
});
|
|
@@ -7091,7 +7093,7 @@ class EnvelopeListenerManager extends TaskSpawner {
|
|
|
7091
7093
|
envelope.replyTo = core.formatAddress(SYSTEM_INBOX$2, this.nodeLike.physicalPath);
|
|
7092
7094
|
}
|
|
7093
7095
|
catch (error) {
|
|
7094
|
-
logger$
|
|
7096
|
+
logger$18.warning('default_reply_to_assignment_failed', {
|
|
7095
7097
|
envelope_id: envelope.id,
|
|
7096
7098
|
service_name: envelope.capabilities?.[0] ?? null,
|
|
7097
7099
|
error: error instanceof Error ? error.message : String(error),
|
|
@@ -7116,7 +7118,7 @@ class EnvelopeListenerManager extends TaskSpawner {
|
|
|
7116
7118
|
if (serviceName === SYSTEM_INBOX$2) {
|
|
7117
7119
|
continue;
|
|
7118
7120
|
}
|
|
7119
|
-
logger$
|
|
7121
|
+
logger$18.debug('stopping_listener_for_service', {
|
|
7120
7122
|
service_name: serviceName,
|
|
7121
7123
|
});
|
|
7122
7124
|
entry.listener.stop();
|
|
@@ -7126,7 +7128,7 @@ class EnvelopeListenerManager extends TaskSpawner {
|
|
|
7126
7128
|
catch (error) {
|
|
7127
7129
|
if (!(error instanceof Error) ||
|
|
7128
7130
|
error.name !== 'TaskCancelledError') {
|
|
7129
|
-
logger$
|
|
7131
|
+
logger$18.debug('listener_task_stopped', {
|
|
7130
7132
|
service_name: serviceName,
|
|
7131
7133
|
error: error instanceof Error ? error.message : String(error),
|
|
7132
7134
|
});
|
|
@@ -7134,7 +7136,7 @@ class EnvelopeListenerManager extends TaskSpawner {
|
|
|
7134
7136
|
}
|
|
7135
7137
|
}
|
|
7136
7138
|
if (systemEntry) {
|
|
7137
|
-
logger$
|
|
7139
|
+
logger$18.debug('stopping_listener_for_service', {
|
|
7138
7140
|
service_name: SYSTEM_INBOX$2,
|
|
7139
7141
|
});
|
|
7140
7142
|
systemEntry.listener.stop();
|
|
@@ -7144,7 +7146,7 @@ class EnvelopeListenerManager extends TaskSpawner {
|
|
|
7144
7146
|
catch (error) {
|
|
7145
7147
|
if (!(error instanceof Error) ||
|
|
7146
7148
|
error.name !== 'TaskCancelledError') {
|
|
7147
|
-
logger$
|
|
7149
|
+
logger$18.debug('listener_task_stopped', {
|
|
7148
7150
|
service_name: SYSTEM_INBOX$2,
|
|
7149
7151
|
error: error instanceof Error ? error.message : String(error),
|
|
7150
7152
|
});
|
|
@@ -7161,13 +7163,13 @@ class EnvelopeListenerManager extends TaskSpawner {
|
|
|
7161
7163
|
}
|
|
7162
7164
|
async recoverUnhandledInboundEnvelopes() {
|
|
7163
7165
|
if (typeof this.deliveryTracker.listInbound !== 'function') {
|
|
7164
|
-
logger$
|
|
7166
|
+
logger$18.debug('delivery_tracker_missing_inbound_listing');
|
|
7165
7167
|
return;
|
|
7166
7168
|
}
|
|
7167
7169
|
const failedInbound = await this.deliveryTracker.listInbound((env) => env.status === EnvelopeStatus.RECEIVED ||
|
|
7168
7170
|
env.status === EnvelopeStatus.FAILED_TO_HANDLE);
|
|
7169
7171
|
if (!failedInbound.length) {
|
|
7170
|
-
logger$
|
|
7172
|
+
logger$18.debug('no_failed_inbound_envelopes_to_recover');
|
|
7171
7173
|
return;
|
|
7172
7174
|
}
|
|
7173
7175
|
const grouped = new Map();
|
|
@@ -7184,7 +7186,7 @@ class EnvelopeListenerManager extends TaskSpawner {
|
|
|
7184
7186
|
this.pendingRecoveryEnvelopes.set(serviceName, envelopes);
|
|
7185
7187
|
}
|
|
7186
7188
|
});
|
|
7187
|
-
logger$
|
|
7189
|
+
logger$18.debug('discovered_failed_inbound_envelopes', {
|
|
7188
7190
|
total: failedInbound.length,
|
|
7189
7191
|
services: Array.from(grouped.keys()),
|
|
7190
7192
|
});
|
|
@@ -7194,7 +7196,7 @@ class EnvelopeListenerManager extends TaskSpawner {
|
|
|
7194
7196
|
const pollTimeoutMs = options.pollTimeoutMs ??
|
|
7195
7197
|
options.poll_timeout_ms ??
|
|
7196
7198
|
core.DEFAULT_POLLING_TIMEOUT_MS;
|
|
7197
|
-
logger$
|
|
7199
|
+
logger$18.debug('listen_start', {
|
|
7198
7200
|
recipient: serviceName,
|
|
7199
7201
|
poll_timeout_ms: pollTimeoutMs ?? core.DEFAULT_POLLING_TIMEOUT_MS,
|
|
7200
7202
|
});
|
|
@@ -7225,7 +7227,7 @@ class EnvelopeListenerManager extends TaskSpawner {
|
|
|
7225
7227
|
tracked?.mailboxType === MailboxType.OUTBOX ||
|
|
7226
7228
|
envelope.frame?.['type'] === 'DeliveryAck';
|
|
7227
7229
|
if (!shouldInvoke) {
|
|
7228
|
-
logger$
|
|
7230
|
+
logger$18.debug('skipping_listener_handler', {
|
|
7229
7231
|
recipient: serviceName,
|
|
7230
7232
|
envelope_id: envelope.id,
|
|
7231
7233
|
tracked_status: tracked?.status,
|
|
@@ -7239,13 +7241,13 @@ class EnvelopeListenerManager extends TaskSpawner {
|
|
|
7239
7241
|
? undefined
|
|
7240
7242
|
: (tracked ?? undefined);
|
|
7241
7243
|
if (trackedForHandler && trackedForHandler.attempt > 0) {
|
|
7242
|
-
logger$
|
|
7244
|
+
logger$18.info('resuming_handler_retry_after_restart', {
|
|
7243
7245
|
envelope_id: envelope.id,
|
|
7244
7246
|
current_attempts: trackedForHandler.attempt,
|
|
7245
7247
|
service_name: serviceName,
|
|
7246
7248
|
});
|
|
7247
7249
|
}
|
|
7248
|
-
logger$
|
|
7250
|
+
logger$18.debug('forwarding_to_listener_handler', {
|
|
7249
7251
|
recipient: serviceName,
|
|
7250
7252
|
envelope_id: envelope.id,
|
|
7251
7253
|
frame_type: envelope.frame?.['type'],
|
|
@@ -7264,7 +7266,7 @@ class EnvelopeListenerManager extends TaskSpawner {
|
|
|
7264
7266
|
await channel.send(null);
|
|
7265
7267
|
}
|
|
7266
7268
|
catch (error) {
|
|
7267
|
-
logger$
|
|
7269
|
+
logger$18.debug('listener_stop_signal_failed', {
|
|
7268
7270
|
service_name: serviceName,
|
|
7269
7271
|
error: error instanceof Error ? error.message : String(error),
|
|
7270
7272
|
});
|
|
@@ -7273,7 +7275,7 @@ class EnvelopeListenerManager extends TaskSpawner {
|
|
|
7273
7275
|
await this.listenersLock.runExclusive(async () => {
|
|
7274
7276
|
const existing = this.listeners.get(serviceName);
|
|
7275
7277
|
if (existing) {
|
|
7276
|
-
logger$
|
|
7278
|
+
logger$18.debug('replacing_envelope_listener', { recipient: serviceName });
|
|
7277
7279
|
existing.listener.stop();
|
|
7278
7280
|
try {
|
|
7279
7281
|
await existing.listener.task.promise;
|
|
@@ -7291,13 +7293,13 @@ class EnvelopeListenerManager extends TaskSpawner {
|
|
|
7291
7293
|
return binding.address;
|
|
7292
7294
|
}
|
|
7293
7295
|
async listenRpc(serviceName, handler, options = {}) {
|
|
7294
|
-
logger$
|
|
7296
|
+
logger$18.debug('rpc_listen_start', { service_name: serviceName });
|
|
7295
7297
|
const rpcHandler = async (envelope, context) => {
|
|
7296
7298
|
const result = await this.rpcServerHandler.handleRpcRequest(envelope, context, handler, serviceName);
|
|
7297
7299
|
return result ?? null;
|
|
7298
7300
|
};
|
|
7299
7301
|
const address = await this.listen(serviceName, rpcHandler, options);
|
|
7300
|
-
logger$
|
|
7302
|
+
logger$18.debug('rpc_listen_bound', {
|
|
7301
7303
|
service_name: serviceName,
|
|
7302
7304
|
address: address.toString(),
|
|
7303
7305
|
});
|
|
@@ -7366,12 +7368,12 @@ class EnvelopeListenerManager extends TaskSpawner {
|
|
|
7366
7368
|
return cached;
|
|
7367
7369
|
});
|
|
7368
7370
|
if (!envelopes.length) {
|
|
7369
|
-
logger$
|
|
7371
|
+
logger$18.debug('no_cached_recovery_for_service', {
|
|
7370
7372
|
service_name: serviceName,
|
|
7371
7373
|
});
|
|
7372
7374
|
return;
|
|
7373
7375
|
}
|
|
7374
|
-
logger$
|
|
7376
|
+
logger$18.debug('recovering_unhandled_envelopes_on_listen', {
|
|
7375
7377
|
service_name: serviceName,
|
|
7376
7378
|
count: envelopes.length,
|
|
7377
7379
|
envelope_ids: envelopes.map((trackedEnvelope) => trackedEnvelope.envelopeId),
|
|
@@ -7382,7 +7384,7 @@ class EnvelopeListenerManager extends TaskSpawner {
|
|
|
7382
7384
|
async recoverServiceEnvelopes(serviceName, envelopes, handler) {
|
|
7383
7385
|
for (const tracked of envelopes) {
|
|
7384
7386
|
try {
|
|
7385
|
-
logger$
|
|
7387
|
+
logger$18.warning('recovering_unhandled_envelope', {
|
|
7386
7388
|
envelope_id: tracked.envelopeId,
|
|
7387
7389
|
service_name: serviceName,
|
|
7388
7390
|
current_attempts: tracked.attempt,
|
|
@@ -7391,13 +7393,13 @@ class EnvelopeListenerManager extends TaskSpawner {
|
|
|
7391
7393
|
const originalEnvelope = tracked.originalEnvelope;
|
|
7392
7394
|
const receiverPolicy = this.nodeLike.deliveryPolicy?.receiverRetryPolicy ?? undefined;
|
|
7393
7395
|
await this.executeHandlerWithRetries(handler, originalEnvelope, undefined, receiverPolicy, tracked, serviceName);
|
|
7394
|
-
logger$
|
|
7396
|
+
logger$18.debug('envelope_recovery_completed', {
|
|
7395
7397
|
envelope_id: tracked.envelopeId,
|
|
7396
7398
|
service_name: serviceName,
|
|
7397
7399
|
});
|
|
7398
7400
|
}
|
|
7399
7401
|
catch (error) {
|
|
7400
|
-
logger$
|
|
7402
|
+
logger$18.error('envelope_recovery_failed', {
|
|
7401
7403
|
envelope_id: tracked.envelopeId,
|
|
7402
7404
|
service_name: serviceName,
|
|
7403
7405
|
error: error instanceof Error ? error.message : String(error),
|
|
@@ -7443,7 +7445,7 @@ class EnvelopeListenerManager extends TaskSpawner {
|
|
|
7443
7445
|
await this.deliveryTracker.onEnvelopeHandled(trackedEnvelope);
|
|
7444
7446
|
}
|
|
7445
7447
|
if (currentAttempt > 0) {
|
|
7446
|
-
logger$
|
|
7448
|
+
logger$18.info('handler_retry_succeeded', {
|
|
7447
7449
|
envelope_id: envelope.id,
|
|
7448
7450
|
attempt: currentAttempt + 1,
|
|
7449
7451
|
total_attempts: currentAttempt + 1,
|
|
@@ -7459,7 +7461,7 @@ class EnvelopeListenerManager extends TaskSpawner {
|
|
|
7459
7461
|
await this.deliveryTracker.onEnvelopeHandleFailed(inboxName, trackedEnvelope, context, error instanceof Error ? error : new Error(String(error)), isFinalAttempt);
|
|
7460
7462
|
}
|
|
7461
7463
|
if (isFinalAttempt) {
|
|
7462
|
-
logger$
|
|
7464
|
+
logger$18.error('handler_execution_failed_exhausted_retries', {
|
|
7463
7465
|
envelope_id: envelope.id,
|
|
7464
7466
|
total_attempts: attemptNumber,
|
|
7465
7467
|
max_retries: retryPolicy?.maxRetries ?? 0,
|
|
@@ -7468,7 +7470,7 @@ class EnvelopeListenerManager extends TaskSpawner {
|
|
|
7468
7470
|
break;
|
|
7469
7471
|
}
|
|
7470
7472
|
const delayMs = retryPolicy?.nextDelayMs(attemptNumber) ?? 0;
|
|
7471
|
-
logger$
|
|
7473
|
+
logger$18.warning('handler_execution_failed_will_retry', {
|
|
7472
7474
|
envelope_id: envelope.id,
|
|
7473
7475
|
attempt: attemptNumber,
|
|
7474
7476
|
max_retries: retryPolicy?.maxRetries ?? 0,
|
|
@@ -7498,7 +7500,7 @@ class EnvelopeListenerManager extends TaskSpawner {
|
|
|
7498
7500
|
}
|
|
7499
7501
|
}
|
|
7500
7502
|
|
|
7501
|
-
const logger$
|
|
7503
|
+
const logger$17 = getLogger('naylence.fame.delivery.default_delivery_tracker');
|
|
7502
7504
|
const STREAM_END = Symbol('stream-end');
|
|
7503
7505
|
const SWEEPER_TICK = Symbol('tracker-sweeper-tick');
|
|
7504
7506
|
function createDeferred$2() {
|
|
@@ -7717,7 +7719,7 @@ class DefaultDeliveryTracker extends TaskSpawner {
|
|
|
7717
7719
|
const expectedResponseType = options.expectedResponseType;
|
|
7718
7720
|
const tracked = await this.lock.runExclusive(async () => {
|
|
7719
7721
|
if (this.ackFutures.has(envelope.id)) {
|
|
7720
|
-
logger$
|
|
7722
|
+
logger$17.debug('tracker_envelope_already_tracked', {
|
|
7721
7723
|
envp_id: envelope.id,
|
|
7722
7724
|
});
|
|
7723
7725
|
return null;
|
|
@@ -7727,7 +7729,7 @@ class DefaultDeliveryTracker extends TaskSpawner {
|
|
|
7727
7729
|
if (expectedResponseType & core.FameResponseType.REPLY ||
|
|
7728
7730
|
expectedResponseType & core.FameResponseType.STREAM) {
|
|
7729
7731
|
if (existingEnvId && existingEnvId !== envelope.id) {
|
|
7730
|
-
logger$
|
|
7732
|
+
logger$17.debug('envelope_already_tracked_for_replies', {
|
|
7731
7733
|
envp_id: envelope.id,
|
|
7732
7734
|
corr_id: corrId,
|
|
7733
7735
|
expected_response_type: expectedResponseType,
|
|
@@ -7776,7 +7778,7 @@ class DefaultDeliveryTracker extends TaskSpawner {
|
|
|
7776
7778
|
return null;
|
|
7777
7779
|
}
|
|
7778
7780
|
await this.scheduleTimer(tracked, options.retryPolicy ?? null, options.retryHandler ?? null);
|
|
7779
|
-
logger$
|
|
7781
|
+
logger$17.debug('tracker_registered_envelope', {
|
|
7780
7782
|
envp_id: envelope.id,
|
|
7781
7783
|
corr_id: tracked.originalEnvelope.corrId,
|
|
7782
7784
|
expected_response: tracked.expectedResponseType,
|
|
@@ -7800,21 +7802,21 @@ class DefaultDeliveryTracker extends TaskSpawner {
|
|
|
7800
7802
|
return this.awaitEnvelopeFuture(envelopeId, core.FameResponseType.REPLY | core.FameResponseType.STREAM, future, timeoutMs);
|
|
7801
7803
|
}
|
|
7802
7804
|
async onEnvelopeDelivered(inboxName, envelope, context) {
|
|
7803
|
-
logger$
|
|
7805
|
+
logger$17.debug('envelope_delivered', {
|
|
7804
7806
|
envp_id: envelope.id,
|
|
7805
7807
|
corr_id: envelope.corrId,
|
|
7806
7808
|
rtype: envelope.rtype ?? core.FameResponseType.NONE,
|
|
7807
7809
|
frame_type: envelope.frame?.type ?? 'unknown',
|
|
7808
7810
|
});
|
|
7809
7811
|
if (!envelope.corrId) {
|
|
7810
|
-
logger$
|
|
7812
|
+
logger$17.debug('envelope_delivered_no_corr_id', {
|
|
7811
7813
|
envelope_id: envelope.id,
|
|
7812
7814
|
});
|
|
7813
7815
|
return null;
|
|
7814
7816
|
}
|
|
7815
7817
|
if (this.isDeliveryAckFrame(envelope.frame)) {
|
|
7816
7818
|
if (!envelope.frame.refId) {
|
|
7817
|
-
logger$
|
|
7819
|
+
logger$17.debug('envelope_delivered_no_ref_id', {
|
|
7818
7820
|
envelope_id: envelope.id,
|
|
7819
7821
|
});
|
|
7820
7822
|
return null;
|
|
@@ -7851,7 +7853,7 @@ class DefaultDeliveryTracker extends TaskSpawner {
|
|
|
7851
7853
|
await inbox.set(envelope.id, tracked);
|
|
7852
7854
|
}
|
|
7853
7855
|
else {
|
|
7854
|
-
logger$
|
|
7856
|
+
logger$17.debug('tracker_duplicate_envelope_already_handled', {
|
|
7855
7857
|
envp_id: envelope.id,
|
|
7856
7858
|
status: tracked.status,
|
|
7857
7859
|
});
|
|
@@ -7893,7 +7895,7 @@ class DefaultDeliveryTracker extends TaskSpawner {
|
|
|
7893
7895
|
}
|
|
7894
7896
|
if (isFinalFailure) {
|
|
7895
7897
|
envelope.status = EnvelopeStatus.FAILED_TO_HANDLE;
|
|
7896
|
-
logger$
|
|
7898
|
+
logger$17.error('envelope_handle_failed_final', {
|
|
7897
7899
|
inbox_name: inboxName,
|
|
7898
7900
|
envp_id: envelope.originalEnvelope.id,
|
|
7899
7901
|
error: error?.message ?? 'unknown',
|
|
@@ -7904,7 +7906,7 @@ class DefaultDeliveryTracker extends TaskSpawner {
|
|
|
7904
7906
|
await inbox.delete(envelope.originalEnvelope.id);
|
|
7905
7907
|
return;
|
|
7906
7908
|
}
|
|
7907
|
-
logger$
|
|
7909
|
+
logger$17.warning('envelope_handle_failed_retry', {
|
|
7908
7910
|
inbox_name: inboxName,
|
|
7909
7911
|
envp_id: envelope.originalEnvelope.id,
|
|
7910
7912
|
error: error?.message ?? 'unknown',
|
|
@@ -7949,14 +7951,14 @@ class DefaultDeliveryTracker extends TaskSpawner {
|
|
|
7949
7951
|
if (handledViaFuture) {
|
|
7950
7952
|
await this.markDoneSince(this.ackFutures, refId, this.ackDoneSince);
|
|
7951
7953
|
await this.clearTimer(refId);
|
|
7952
|
-
logger$
|
|
7954
|
+
logger$17.debug('tracker_ack_resolved_without_tracked_envelope', {
|
|
7953
7955
|
envp_id: envelope.id,
|
|
7954
7956
|
ref_id: refId,
|
|
7955
7957
|
corr_id: envelope.corrId,
|
|
7956
7958
|
});
|
|
7957
7959
|
return;
|
|
7958
7960
|
}
|
|
7959
|
-
logger$
|
|
7961
|
+
logger$17.debug('tracker_ack_for_unknown_envelope', {
|
|
7960
7962
|
envp_id: envelope.id,
|
|
7961
7963
|
ref_id: refId,
|
|
7962
7964
|
corr_id: envelope.corrId,
|
|
@@ -7964,7 +7966,7 @@ class DefaultDeliveryTracker extends TaskSpawner {
|
|
|
7964
7966
|
return;
|
|
7965
7967
|
}
|
|
7966
7968
|
if (tracked.originalEnvelope.corrId !== envelope.corrId) {
|
|
7967
|
-
logger$
|
|
7969
|
+
logger$17.debug('tracker_ack_corr_id_mismatch', {
|
|
7968
7970
|
envp_id: envelope.id,
|
|
7969
7971
|
expected_corr_id: tracked.originalEnvelope.corrId,
|
|
7970
7972
|
actual_corr_id: envelope.corrId,
|
|
@@ -7989,7 +7991,7 @@ class DefaultDeliveryTracker extends TaskSpawner {
|
|
|
7989
7991
|
for (const handler of this.eventHandlers) {
|
|
7990
7992
|
await handler.onEnvelopeAcked?.(tracked);
|
|
7991
7993
|
}
|
|
7992
|
-
logger$
|
|
7994
|
+
logger$17.debug('tracker_envelope_acked', {
|
|
7993
7995
|
envp_id: tracked.originalEnvelope.id,
|
|
7994
7996
|
});
|
|
7995
7997
|
}
|
|
@@ -8006,13 +8008,13 @@ class DefaultDeliveryTracker extends TaskSpawner {
|
|
|
8006
8008
|
const outbox = this.ensureOutbox();
|
|
8007
8009
|
const tracked = await outbox.get(envelope.frame.refId);
|
|
8008
8010
|
if (!tracked) {
|
|
8009
|
-
logger$
|
|
8011
|
+
logger$17.debug('tracker_nack_for_unknown_envelope', {
|
|
8010
8012
|
envp_id: envelope.id,
|
|
8011
8013
|
});
|
|
8012
8014
|
return;
|
|
8013
8015
|
}
|
|
8014
8016
|
if (tracked.originalEnvelope.corrId !== envelope.corrId) {
|
|
8015
|
-
logger$
|
|
8017
|
+
logger$17.debug('tracker_nack_corr_id_mismatch', {
|
|
8016
8018
|
envp_id: envelope.id,
|
|
8017
8019
|
expected_corr_id: tracked.originalEnvelope.corrId,
|
|
8018
8020
|
actual_corr_id: envelope.corrId,
|
|
@@ -8054,7 +8056,7 @@ class DefaultDeliveryTracker extends TaskSpawner {
|
|
|
8054
8056
|
for (const handler of this.eventHandlers) {
|
|
8055
8057
|
await handler.onEnvelopeNacked?.(tracked, ackFrame.reason ?? null);
|
|
8056
8058
|
}
|
|
8057
|
-
logger$
|
|
8059
|
+
logger$17.debug('tracker_envelope_nacked', {
|
|
8058
8060
|
envp_id: tracked.originalEnvelope.id,
|
|
8059
8061
|
reason: ackFrame.reason,
|
|
8060
8062
|
});
|
|
@@ -8101,7 +8103,7 @@ class DefaultDeliveryTracker extends TaskSpawner {
|
|
|
8101
8103
|
for (const handler of this.eventHandlers) {
|
|
8102
8104
|
await handler.onEnvelopeReplied?.(trackedEnvelope, envelope);
|
|
8103
8105
|
}
|
|
8104
|
-
logger$
|
|
8106
|
+
logger$17.debug('tracked_envelope_replied', {
|
|
8105
8107
|
envp_id: trackedEnvelope.originalEnvelope.id,
|
|
8106
8108
|
corr_id: envelope.corrId,
|
|
8107
8109
|
});
|
|
@@ -8175,7 +8177,7 @@ class DefaultDeliveryTracker extends TaskSpawner {
|
|
|
8175
8177
|
async addToInboxDlq(trackedEnvelope, reason = null) {
|
|
8176
8178
|
const dlq = this.inboxDlq;
|
|
8177
8179
|
if (!dlq) {
|
|
8178
|
-
logger$
|
|
8180
|
+
logger$17.error('dlq_not_initialized', {
|
|
8179
8181
|
envp_id: trackedEnvelope.originalEnvelope.id,
|
|
8180
8182
|
});
|
|
8181
8183
|
return;
|
|
@@ -8190,7 +8192,7 @@ class DefaultDeliveryTracker extends TaskSpawner {
|
|
|
8190
8192
|
const deadLetteredAt = Date.now();
|
|
8191
8193
|
setMetaWithLegacy(trackedEnvelope.meta, 'deadLetteredAtMs', 'dead_lettered_at_ms', deadLetteredAt);
|
|
8192
8194
|
await dlq.set(trackedEnvelope.originalEnvelope.id, trackedEnvelope);
|
|
8193
|
-
logger$
|
|
8195
|
+
logger$17.warning('envelope_moved_to_dlq', {
|
|
8194
8196
|
envp_id: trackedEnvelope.originalEnvelope.id,
|
|
8195
8197
|
service_name: trackedEnvelope.serviceName,
|
|
8196
8198
|
});
|
|
@@ -8219,7 +8221,7 @@ class DefaultDeliveryTracker extends TaskSpawner {
|
|
|
8219
8221
|
const toDelete = Object.entries(items).filter(([, value]) => predicate ? predicate(value) : true);
|
|
8220
8222
|
await Promise.all(toDelete.map(([key]) => dlq.delete(key)));
|
|
8221
8223
|
if (toDelete.length) {
|
|
8222
|
-
logger$
|
|
8224
|
+
logger$17.debug('dlq_purged', { count: toDelete.length });
|
|
8223
8225
|
}
|
|
8224
8226
|
return toDelete.length;
|
|
8225
8227
|
}
|
|
@@ -8272,11 +8274,11 @@ class DefaultDeliveryTracker extends TaskSpawner {
|
|
|
8272
8274
|
}
|
|
8273
8275
|
this.futuresSweeper = null;
|
|
8274
8276
|
}
|
|
8275
|
-
logger$
|
|
8277
|
+
logger$17.debug('tracker_cleanup_completed');
|
|
8276
8278
|
}
|
|
8277
8279
|
async recoverPending() {
|
|
8278
8280
|
const pending = await this.listPending();
|
|
8279
|
-
logger$
|
|
8281
|
+
logger$17.debug('tracker_recovering_pending', { count: pending.length });
|
|
8280
8282
|
await this.lock.runExclusive(async () => {
|
|
8281
8283
|
for (const tracked of pending) {
|
|
8282
8284
|
if (tracked.expectedResponseType & core.FameResponseType.ACK) {
|
|
@@ -8302,7 +8304,7 @@ class DefaultDeliveryTracker extends TaskSpawner {
|
|
|
8302
8304
|
for (const tracked of pending) {
|
|
8303
8305
|
await this.scheduleTimer(tracked, null, null);
|
|
8304
8306
|
}
|
|
8305
|
-
logger$
|
|
8307
|
+
logger$17.debug('tracker_recovery_completed', { count: pending.length });
|
|
8306
8308
|
}
|
|
8307
8309
|
ensureOutbox() {
|
|
8308
8310
|
if (!this.outbox) {
|
|
@@ -8317,7 +8319,7 @@ class DefaultDeliveryTracker extends TaskSpawner {
|
|
|
8317
8319
|
return this.inbox;
|
|
8318
8320
|
}
|
|
8319
8321
|
async waitForPendingAcks() {
|
|
8320
|
-
logger$
|
|
8322
|
+
logger$17.debug('tracker_node_preparing_to_stop_waiting_for_pending_acks');
|
|
8321
8323
|
const outbox = this.outbox;
|
|
8322
8324
|
if (!outbox) {
|
|
8323
8325
|
return;
|
|
@@ -8329,7 +8331,7 @@ class DefaultDeliveryTracker extends TaskSpawner {
|
|
|
8329
8331
|
continue;
|
|
8330
8332
|
}
|
|
8331
8333
|
if (!future.done) {
|
|
8332
|
-
logger$
|
|
8334
|
+
logger$17.debug('tracker_pending_ack_future_detected', {
|
|
8333
8335
|
envelope_id: envelopeId,
|
|
8334
8336
|
});
|
|
8335
8337
|
pending.push({ envelopeId, future });
|
|
@@ -8337,10 +8339,10 @@ class DefaultDeliveryTracker extends TaskSpawner {
|
|
|
8337
8339
|
}
|
|
8338
8340
|
});
|
|
8339
8341
|
if (!pending.length) {
|
|
8340
|
-
logger$
|
|
8342
|
+
logger$17.debug('tracker_no_pending_acks_to_wait_for');
|
|
8341
8343
|
return;
|
|
8342
8344
|
}
|
|
8343
|
-
logger$
|
|
8345
|
+
logger$17.debug('tracker_waiting_for_pending_acks', { count: pending.length });
|
|
8344
8346
|
for (const entry of pending) {
|
|
8345
8347
|
if (!entry) {
|
|
8346
8348
|
continue;
|
|
@@ -8357,19 +8359,19 @@ class DefaultDeliveryTracker extends TaskSpawner {
|
|
|
8357
8359
|
}
|
|
8358
8360
|
try {
|
|
8359
8361
|
await this.awaitWithTimeout(entry.future.promise, remainingMs);
|
|
8360
|
-
logger$
|
|
8362
|
+
logger$17.debug('tracker_received_ack', {
|
|
8361
8363
|
envelope_id: entry.envelopeId,
|
|
8362
8364
|
});
|
|
8363
8365
|
await outbox.delete(entry.envelopeId);
|
|
8364
8366
|
}
|
|
8365
8367
|
catch (error) {
|
|
8366
8368
|
if (error instanceof Error && error.name === 'TimeoutError') {
|
|
8367
|
-
logger$
|
|
8369
|
+
logger$17.debug('tracker_ack_timeout_expired', {
|
|
8368
8370
|
envelope_id: entry.envelopeId,
|
|
8369
8371
|
});
|
|
8370
8372
|
}
|
|
8371
8373
|
else {
|
|
8372
|
-
logger$
|
|
8374
|
+
logger$17.debug('tracker_ack_wait_error', {
|
|
8373
8375
|
envelope_id: entry.envelopeId,
|
|
8374
8376
|
error: error instanceof Error ? error.message : String(error),
|
|
8375
8377
|
});
|
|
@@ -8377,13 +8379,13 @@ class DefaultDeliveryTracker extends TaskSpawner {
|
|
|
8377
8379
|
}
|
|
8378
8380
|
}
|
|
8379
8381
|
catch (error) {
|
|
8380
|
-
logger$
|
|
8382
|
+
logger$17.error('tracker_error_waiting_for_ack', {
|
|
8381
8383
|
envelope_id: entry.envelopeId,
|
|
8382
8384
|
error: error instanceof Error ? error.message : String(error),
|
|
8383
8385
|
});
|
|
8384
8386
|
}
|
|
8385
8387
|
}
|
|
8386
|
-
logger$
|
|
8388
|
+
logger$17.debug('tracker_finished_waiting_for_pending_acks');
|
|
8387
8389
|
}
|
|
8388
8390
|
async waitForPendingAckDispatches() {
|
|
8389
8391
|
while (this.pendingAckDispatches.size > 0) {
|
|
@@ -8441,7 +8443,7 @@ class DefaultDeliveryTracker extends TaskSpawner {
|
|
|
8441
8443
|
for (const handler of this.eventHandlers) {
|
|
8442
8444
|
await handler.onEnvelopeTimeout?.(currentTracked);
|
|
8443
8445
|
}
|
|
8444
|
-
logger$
|
|
8446
|
+
logger$17.debug('tracker_envelope_timed_out', {
|
|
8445
8447
|
envp_id: tracked.originalEnvelope.id,
|
|
8446
8448
|
});
|
|
8447
8449
|
return;
|
|
@@ -8454,7 +8456,7 @@ class DefaultDeliveryTracker extends TaskSpawner {
|
|
|
8454
8456
|
currentTracked.timeoutAtMs = nextTimeoutAt;
|
|
8455
8457
|
await outbox.set(tracked.originalEnvelope.id, currentTracked);
|
|
8456
8458
|
await this.scheduleTimer(currentTracked, retryPolicy, retryHandler);
|
|
8457
|
-
logger$
|
|
8459
|
+
logger$17.debug('tracker_retry_deferred_during_shutdown', {
|
|
8458
8460
|
envp_id: tracked.originalEnvelope.id,
|
|
8459
8461
|
defer_ms: shutdownDeferMs,
|
|
8460
8462
|
});
|
|
@@ -8477,7 +8479,7 @@ class DefaultDeliveryTracker extends TaskSpawner {
|
|
|
8477
8479
|
});
|
|
8478
8480
|
}
|
|
8479
8481
|
await this.scheduleTimer(currentTracked, retryPolicy, retryHandler);
|
|
8480
|
-
logger$
|
|
8482
|
+
logger$17.debug('envelope_delivery_retry_scheduled', {
|
|
8481
8483
|
envp_id: tracked.originalEnvelope.id,
|
|
8482
8484
|
attempt: currentTracked.attempt,
|
|
8483
8485
|
max_retries: retryPolicy.maxRetries,
|
|
@@ -8489,7 +8491,7 @@ class DefaultDeliveryTracker extends TaskSpawner {
|
|
|
8489
8491
|
currentTracked.timeoutAtMs = currentTracked.overallTimeoutAtMs;
|
|
8490
8492
|
await outbox.set(tracked.originalEnvelope.id, currentTracked);
|
|
8491
8493
|
await this.scheduleTimer(currentTracked, retryPolicy, retryHandler);
|
|
8492
|
-
logger$
|
|
8494
|
+
logger$17.debug('envelope_retries_exhausted_waiting_until_overall_timeout', {
|
|
8493
8495
|
envp_id: tracked.originalEnvelope.id,
|
|
8494
8496
|
attempt: currentTracked.attempt,
|
|
8495
8497
|
overall_timeout_at_ms: currentTracked.overallTimeoutAtMs,
|
|
@@ -8509,7 +8511,7 @@ class DefaultDeliveryTracker extends TaskSpawner {
|
|
|
8509
8511
|
for (const handler of this.eventHandlers) {
|
|
8510
8512
|
await handler.onEnvelopeTimeout?.(currentTracked);
|
|
8511
8513
|
}
|
|
8512
|
-
logger$
|
|
8514
|
+
logger$17.debug('tracker_envelope_timed_out', {
|
|
8513
8515
|
envp_id: tracked.originalEnvelope.id,
|
|
8514
8516
|
});
|
|
8515
8517
|
}
|
|
@@ -8517,7 +8519,7 @@ class DefaultDeliveryTracker extends TaskSpawner {
|
|
|
8517
8519
|
if (error instanceof TaskCancelledError) {
|
|
8518
8520
|
return;
|
|
8519
8521
|
}
|
|
8520
|
-
logger$
|
|
8522
|
+
logger$17.error('tracker_timer_error', {
|
|
8521
8523
|
envp_id: tracked.originalEnvelope.id,
|
|
8522
8524
|
error: error instanceof Error ? error.message : String(error),
|
|
8523
8525
|
});
|
|
@@ -8572,7 +8574,7 @@ class DefaultDeliveryTracker extends TaskSpawner {
|
|
|
8572
8574
|
if (timeoutSeconds !== null) {
|
|
8573
8575
|
return await this.awaitWithTimeout(future.promise, timeoutSeconds);
|
|
8574
8576
|
}
|
|
8575
|
-
logger$
|
|
8577
|
+
logger$17.debug('await_envelope_no_timeout_wait', {
|
|
8576
8578
|
envelope_id: envelopeId,
|
|
8577
8579
|
});
|
|
8578
8580
|
return await future.promise;
|
|
@@ -8581,7 +8583,7 @@ class DefaultDeliveryTracker extends TaskSpawner {
|
|
|
8581
8583
|
if (error instanceof Error && error.name !== 'TimeoutError') {
|
|
8582
8584
|
throw error;
|
|
8583
8585
|
}
|
|
8584
|
-
logger$
|
|
8586
|
+
logger$17.error('await_envelope_timeout_error', {
|
|
8585
8587
|
envelope_id: envelopeId,
|
|
8586
8588
|
timeout_ms: timeoutSeconds,
|
|
8587
8589
|
future_done: false,
|
|
@@ -8742,7 +8744,7 @@ class DefaultDeliveryTracker extends TaskSpawner {
|
|
|
8742
8744
|
this.replyDoneSince.delete(envId);
|
|
8743
8745
|
}
|
|
8744
8746
|
});
|
|
8745
|
-
logger$
|
|
8747
|
+
logger$17.debug('tracker_swept_completed_futures', {
|
|
8746
8748
|
ack_removed: toRemoveAck.length,
|
|
8747
8749
|
reply_removed: toRemoveReply.length,
|
|
8748
8750
|
grace_secs: this.futGcGraceSecs,
|
|
@@ -8756,7 +8758,7 @@ class DefaultDeliveryTracker extends TaskSpawner {
|
|
|
8756
8758
|
if (error instanceof Error && error.name === 'TimeoutError') {
|
|
8757
8759
|
continue;
|
|
8758
8760
|
}
|
|
8759
|
-
logger$
|
|
8761
|
+
logger$17.error('tracker_sweeper_error', {
|
|
8760
8762
|
error: error instanceof Error ? error.message : String(error),
|
|
8761
8763
|
});
|
|
8762
8764
|
}
|
|
@@ -8787,14 +8789,14 @@ class DefaultDeliveryTracker extends TaskSpawner {
|
|
|
8787
8789
|
}
|
|
8788
8790
|
const node = this.node;
|
|
8789
8791
|
if (!envelope.replyTo) {
|
|
8790
|
-
logger$
|
|
8792
|
+
logger$17.error('cannot_send_ack_no_reply_to', { envp_id: envelope.id });
|
|
8791
8793
|
return;
|
|
8792
8794
|
}
|
|
8793
8795
|
if (!envelope.corrId) {
|
|
8794
|
-
logger$
|
|
8796
|
+
logger$17.error('cannot_send_ack_no_corr_id', { envp_id: envelope.id });
|
|
8795
8797
|
return;
|
|
8796
8798
|
}
|
|
8797
|
-
logger$
|
|
8799
|
+
logger$17.debug('tracker_sending_ack', {
|
|
8798
8800
|
envp_id: envelope.id,
|
|
8799
8801
|
ref_id: envelope.id,
|
|
8800
8802
|
to: envelope.replyTo,
|
|
@@ -8814,7 +8816,7 @@ class DefaultDeliveryTracker extends TaskSpawner {
|
|
|
8814
8816
|
.send(ackEnvelope)
|
|
8815
8817
|
.then(() => undefined)
|
|
8816
8818
|
.catch((error) => {
|
|
8817
|
-
logger$
|
|
8819
|
+
logger$17.error('tracker_ack_dispatch_failed', {
|
|
8818
8820
|
envp_id: envelope.id,
|
|
8819
8821
|
error: error instanceof Error ? error.message : String(error),
|
|
8820
8822
|
});
|
|
@@ -8900,7 +8902,7 @@ class AsyncEvent {
|
|
|
8900
8902
|
}
|
|
8901
8903
|
}
|
|
8902
8904
|
|
|
8903
|
-
const logger$
|
|
8905
|
+
const logger$16 = getLogger('naylence.fame.node.root_session_manager');
|
|
8904
8906
|
function resolveOption$1(options, primary, ...aliases) {
|
|
8905
8907
|
const record = options;
|
|
8906
8908
|
const primaryKey = primary;
|
|
@@ -8981,7 +8983,7 @@ class RootSessionManager extends TaskSpawner {
|
|
|
8981
8983
|
this.onAdmissionFailed =
|
|
8982
8984
|
typeof onAdmissionFailed === 'function' ? onAdmissionFailed : undefined;
|
|
8983
8985
|
this.enableContinuousRefresh = enableContinuousRefresh ?? true;
|
|
8984
|
-
logger$
|
|
8986
|
+
logger$16.debug('created_root_session_manager');
|
|
8985
8987
|
}
|
|
8986
8988
|
get isReady() {
|
|
8987
8989
|
return this.readyEvent.isSet();
|
|
@@ -9006,7 +9008,7 @@ class RootSessionManager extends TaskSpawner {
|
|
|
9006
9008
|
if (this.admissionTask) {
|
|
9007
9009
|
return;
|
|
9008
9010
|
}
|
|
9009
|
-
logger$
|
|
9011
|
+
logger$16.debug('root_session_manager_starting');
|
|
9010
9012
|
this.stopEvent.clear();
|
|
9011
9013
|
this.readyEvent.clear();
|
|
9012
9014
|
const taskName = `root-admission-${this.admissionEpoch}`;
|
|
@@ -9026,10 +9028,10 @@ class RootSessionManager extends TaskSpawner {
|
|
|
9026
9028
|
await this.admissionTask.promise;
|
|
9027
9029
|
throw new FameConnectError('Root session manager failed to become ready');
|
|
9028
9030
|
}
|
|
9029
|
-
logger$
|
|
9031
|
+
logger$16.debug('root_session_manager_started');
|
|
9030
9032
|
}
|
|
9031
9033
|
async stop() {
|
|
9032
|
-
logger$
|
|
9034
|
+
logger$16.debug('root_session_manager_stopping');
|
|
9033
9035
|
this.stopEvent.set();
|
|
9034
9036
|
if (this.admissionTask) {
|
|
9035
9037
|
this.admissionTask.cancel();
|
|
@@ -9041,7 +9043,7 @@ class RootSessionManager extends TaskSpawner {
|
|
|
9041
9043
|
await this.consumeTask(this.expiryGuardTask);
|
|
9042
9044
|
this.expiryGuardTask = null;
|
|
9043
9045
|
}
|
|
9044
|
-
logger$
|
|
9046
|
+
logger$16.debug('root_session_manager_stopped');
|
|
9045
9047
|
}
|
|
9046
9048
|
async awaitReady(timeoutMs) {
|
|
9047
9049
|
if (this.isReady) {
|
|
@@ -9082,12 +9084,12 @@ class RootSessionManager extends TaskSpawner {
|
|
|
9082
9084
|
await this.onEpochChange(epoch);
|
|
9083
9085
|
}
|
|
9084
9086
|
else {
|
|
9085
|
-
logger$
|
|
9087
|
+
logger$16.debug('epoch_change_ignored_no_handler', { epoch });
|
|
9086
9088
|
}
|
|
9087
9089
|
}
|
|
9088
9090
|
static createForRootSentinel(node, admissionClient, requestedLogicals = [], enableContinuousRefresh = true, onEpochChange) {
|
|
9089
9091
|
const handleWelcome = async (frame) => {
|
|
9090
|
-
logger$
|
|
9092
|
+
logger$16.info('root_admission_successful', {
|
|
9091
9093
|
system_id: frame.systemId,
|
|
9092
9094
|
assigned_path: frame.assignedPath ?? null,
|
|
9093
9095
|
accepted_logicals: frame.acceptedLogicals ?? [],
|
|
@@ -9098,12 +9100,12 @@ class RootSessionManager extends TaskSpawner {
|
|
|
9098
9100
|
? grant.purpose
|
|
9099
9101
|
: undefined;
|
|
9100
9102
|
if (purpose) {
|
|
9101
|
-
logger$
|
|
9103
|
+
logger$16.debug('received_admission_grant', { purpose });
|
|
9102
9104
|
}
|
|
9103
9105
|
}
|
|
9104
9106
|
};
|
|
9105
9107
|
const handleFailure = async (error) => {
|
|
9106
|
-
logger$
|
|
9108
|
+
logger$16.error('root_admission_failed_permanently', {
|
|
9107
9109
|
error: error.message,
|
|
9108
9110
|
});
|
|
9109
9111
|
};
|
|
@@ -9132,10 +9134,10 @@ class RootSessionManager extends TaskSpawner {
|
|
|
9132
9134
|
this.readyEvent.set();
|
|
9133
9135
|
}
|
|
9134
9136
|
if (this.hadSuccessfulAdmission) {
|
|
9135
|
-
logger$
|
|
9137
|
+
logger$16.debug('root_admission_refreshed');
|
|
9136
9138
|
}
|
|
9137
9139
|
else {
|
|
9138
|
-
logger$
|
|
9140
|
+
logger$16.debug('root_admission_completed');
|
|
9139
9141
|
}
|
|
9140
9142
|
this.hadSuccessfulAdmission = true;
|
|
9141
9143
|
delay = RootSessionManager.BACKOFF_INITIAL;
|
|
@@ -9144,7 +9146,7 @@ class RootSessionManager extends TaskSpawner {
|
|
|
9144
9146
|
await this.startExpiryGuard(welcomeFrame);
|
|
9145
9147
|
const expiryTriggered = await this.waitForExpiryOrStop();
|
|
9146
9148
|
if (expiryTriggered && !this.stopEvent.isSet()) {
|
|
9147
|
-
logger$
|
|
9149
|
+
logger$16.debug('performing_scheduled_re_admission');
|
|
9148
9150
|
continue;
|
|
9149
9151
|
}
|
|
9150
9152
|
}
|
|
@@ -9156,7 +9158,7 @@ class RootSessionManager extends TaskSpawner {
|
|
|
9156
9158
|
}
|
|
9157
9159
|
const errorObject = error instanceof Error ? error : new Error(String(error));
|
|
9158
9160
|
const willRetry = attempts < RootSessionManager.RETRY_MAX_ATTEMPTS;
|
|
9159
|
-
logger$
|
|
9161
|
+
logger$16.warning('root_admission_failed', {
|
|
9160
9162
|
error: errorObject.message,
|
|
9161
9163
|
attempt: attempts,
|
|
9162
9164
|
will_retry: willRetry,
|
|
@@ -9174,7 +9176,7 @@ class RootSessionManager extends TaskSpawner {
|
|
|
9174
9176
|
}
|
|
9175
9177
|
}
|
|
9176
9178
|
if (attempts >= RootSessionManager.RETRY_MAX_ATTEMPTS) {
|
|
9177
|
-
logger$
|
|
9179
|
+
logger$16.error('root_admission_max_attempts_exceeded', {
|
|
9178
9180
|
max_attempts: RootSessionManager.RETRY_MAX_ATTEMPTS,
|
|
9179
9181
|
});
|
|
9180
9182
|
}
|
|
@@ -9251,7 +9253,7 @@ class RootSessionManager extends TaskSpawner {
|
|
|
9251
9253
|
}
|
|
9252
9254
|
async expiryGuard(welcomeFrame, signal) {
|
|
9253
9255
|
if (!welcomeFrame.expiresAt) {
|
|
9254
|
-
logger$
|
|
9256
|
+
logger$16.debug('no_admission_expiry_configured');
|
|
9255
9257
|
await Promise.race([this.stopEvent.wait(), this.waitForAbort(signal)]);
|
|
9256
9258
|
return;
|
|
9257
9259
|
}
|
|
@@ -9260,7 +9262,7 @@ class RootSessionManager extends TaskSpawner {
|
|
|
9260
9262
|
let delaySeconds = (expiresAt.getTime() - now.getTime()) / 1000 -
|
|
9261
9263
|
RootSessionManager.JWT_REFRESH_SAFETY;
|
|
9262
9264
|
delaySeconds = Math.max(delaySeconds, 0);
|
|
9263
|
-
logger$
|
|
9265
|
+
logger$16.debug('admission_expiry_guard_started', {
|
|
9264
9266
|
welcome_expires_at: expiresAt.toISOString(),
|
|
9265
9267
|
delay_seconds: delaySeconds,
|
|
9266
9268
|
refresh_safety_seconds: RootSessionManager.JWT_REFRESH_SAFETY,
|
|
@@ -9269,7 +9271,7 @@ class RootSessionManager extends TaskSpawner {
|
|
|
9269
9271
|
if (this.stopEvent.isSet() || signal?.aborted) {
|
|
9270
9272
|
return;
|
|
9271
9273
|
}
|
|
9272
|
-
logger$
|
|
9274
|
+
logger$16.debug('admission_expiry_triggered_refresh', {
|
|
9273
9275
|
expires_at: expiresAt.toISOString(),
|
|
9274
9276
|
current_time: new Date().toISOString(),
|
|
9275
9277
|
seconds_before_expiry: RootSessionManager.JWT_REFRESH_SAFETY,
|
|
@@ -9284,7 +9286,7 @@ class RootSessionManager extends TaskSpawner {
|
|
|
9284
9286
|
return;
|
|
9285
9287
|
}
|
|
9286
9288
|
const errorObject = error instanceof Error ? error : new Error(String(error));
|
|
9287
|
-
logger$
|
|
9289
|
+
logger$16.debug('background_task_error', {
|
|
9288
9290
|
task_name: task.name,
|
|
9289
9291
|
error: errorObject.message,
|
|
9290
9292
|
});
|
|
@@ -9325,7 +9327,7 @@ RootSessionManager.JWT_REFRESH_SAFETY = 60.0;
|
|
|
9325
9327
|
* Concrete implementations must define supported grant types and provide grant-to-connector
|
|
9326
9328
|
* conversion logic.
|
|
9327
9329
|
*/
|
|
9328
|
-
const logger$
|
|
9330
|
+
const logger$15 = getLogger('naylence.fame.connector.connector_factory');
|
|
9329
9331
|
const CONNECTOR_FACTORY_BASE_TYPE = 'ConnectorFactory';
|
|
9330
9332
|
/**
|
|
9331
9333
|
* Abstract base class for connector factories
|
|
@@ -9361,7 +9363,7 @@ class ConnectorFactory {
|
|
|
9361
9363
|
}
|
|
9362
9364
|
}
|
|
9363
9365
|
catch (error) {
|
|
9364
|
-
logger$
|
|
9366
|
+
logger$15.warning(`Failed to evaluate grant with factory ${factoryInfo.constructor.name}: ${error}`);
|
|
9365
9367
|
continue;
|
|
9366
9368
|
}
|
|
9367
9369
|
}
|
|
@@ -9404,7 +9406,7 @@ class ConnectorFactory {
|
|
|
9404
9406
|
}
|
|
9405
9407
|
}
|
|
9406
9408
|
catch (error) {
|
|
9407
|
-
logger$
|
|
9409
|
+
logger$15.warning(`Failed to create connector config from grant: ${error}`);
|
|
9408
9410
|
continue;
|
|
9409
9411
|
}
|
|
9410
9412
|
}
|
|
@@ -9471,20 +9473,20 @@ class ConnectorFactory {
|
|
|
9471
9473
|
return existing;
|
|
9472
9474
|
}
|
|
9473
9475
|
if (existing && !this.isGrantAware(existing)) {
|
|
9474
|
-
logger$
|
|
9476
|
+
logger$15.warning(`Factory ${factoryInfo.constructor.name} is registered under ${CONNECTOR_FACTORY_BASE_TYPE} but is missing grant conversion APIs; skipping.`);
|
|
9475
9477
|
return null;
|
|
9476
9478
|
}
|
|
9477
9479
|
try {
|
|
9478
9480
|
const instance = new factoryInfo.constructor();
|
|
9479
9481
|
if (!this.isGrantAware(instance)) {
|
|
9480
|
-
logger$
|
|
9482
|
+
logger$15.warning(`Factory ${factoryInfo.constructor.name} does not implement grant conversion APIs required by ${CONNECTOR_FACTORY_BASE_TYPE}; skipping.`);
|
|
9481
9483
|
return null;
|
|
9482
9484
|
}
|
|
9483
9485
|
factoryInfo.instance = instance;
|
|
9484
9486
|
return instance;
|
|
9485
9487
|
}
|
|
9486
9488
|
catch (error) {
|
|
9487
|
-
logger$
|
|
9489
|
+
logger$15.warning(`Failed to instantiate factory ${factoryInfo.constructor.name} while resolving grant conversion APIs: ${error}`);
|
|
9488
9490
|
return null;
|
|
9489
9491
|
}
|
|
9490
9492
|
}
|
|
@@ -9587,7 +9589,7 @@ class TaskCancellationError extends Error {
|
|
|
9587
9589
|
this.name = 'TaskCancellationError';
|
|
9588
9590
|
}
|
|
9589
9591
|
}
|
|
9590
|
-
const logger$
|
|
9592
|
+
const logger$14 = getLogger('naylence.fame.connector.base_async_connector');
|
|
9591
9593
|
// Environment variables
|
|
9592
9594
|
const ENV_VAR_FAME_FLOW_CONTROL = 'FAME_FLOW_CONTROL';
|
|
9593
9595
|
const FLOW_CONTROL_ENABLED = typeof process !== 'undefined' && process?.env
|
|
@@ -9670,7 +9672,7 @@ class BaseAsyncConnector extends TaskSpawner {
|
|
|
9670
9672
|
if (this._state !== newState) {
|
|
9671
9673
|
const oldState = this._state;
|
|
9672
9674
|
this._state = newState;
|
|
9673
|
-
logger$
|
|
9675
|
+
logger$14.debug('connector_state_transition', {
|
|
9674
9676
|
connector_id: this._connectorFlowId,
|
|
9675
9677
|
old_state: oldState,
|
|
9676
9678
|
new_state: newState,
|
|
@@ -9709,12 +9711,12 @@ class BaseAsyncConnector extends TaskSpawner {
|
|
|
9709
9711
|
* Stop the connector gracefully
|
|
9710
9712
|
*/
|
|
9711
9713
|
async stop() {
|
|
9712
|
-
logger$
|
|
9714
|
+
logger$14.debug('stopping_connector', {
|
|
9713
9715
|
current_state: this._state,
|
|
9714
9716
|
connector_id: this._connectorFlowId,
|
|
9715
9717
|
});
|
|
9716
9718
|
if (!core.ConnectorStateUtils.canStop(this._state)) {
|
|
9717
|
-
logger$
|
|
9719
|
+
logger$14.debug('connector_stop_already_stopped', {
|
|
9718
9720
|
current_state: this._state,
|
|
9719
9721
|
connector_id: this._connectorFlowId,
|
|
9720
9722
|
});
|
|
@@ -9725,7 +9727,7 @@ class BaseAsyncConnector extends TaskSpawner {
|
|
|
9725
9727
|
if (this._lastError) {
|
|
9726
9728
|
throw this._lastError;
|
|
9727
9729
|
}
|
|
9728
|
-
logger$
|
|
9730
|
+
logger$14.debug('connector_stopped', {
|
|
9729
9731
|
current_state: this._state,
|
|
9730
9732
|
connector_id: this._connectorFlowId,
|
|
9731
9733
|
});
|
|
@@ -9734,19 +9736,19 @@ class BaseAsyncConnector extends TaskSpawner {
|
|
|
9734
9736
|
* Pause the connector (suspends heartbeat and housekeeping, but keeps connection alive)
|
|
9735
9737
|
*/
|
|
9736
9738
|
async pause() {
|
|
9737
|
-
logger$
|
|
9739
|
+
logger$14.debug('pausing_connector', {
|
|
9738
9740
|
current_state: this._state,
|
|
9739
9741
|
connector_id: this._connectorFlowId,
|
|
9740
9742
|
});
|
|
9741
9743
|
if (this._state !== core.ConnectorState.STARTED) {
|
|
9742
|
-
logger$
|
|
9744
|
+
logger$14.debug('connector_pause_invalid_state', {
|
|
9743
9745
|
current_state: this._state,
|
|
9744
9746
|
connector_id: this._connectorFlowId,
|
|
9745
9747
|
});
|
|
9746
9748
|
return;
|
|
9747
9749
|
}
|
|
9748
9750
|
this._setState(core.ConnectorState.PAUSED);
|
|
9749
|
-
logger$
|
|
9751
|
+
logger$14.debug('connector_paused', {
|
|
9750
9752
|
current_state: this._state,
|
|
9751
9753
|
connector_id: this._connectorFlowId,
|
|
9752
9754
|
});
|
|
@@ -9755,19 +9757,19 @@ class BaseAsyncConnector extends TaskSpawner {
|
|
|
9755
9757
|
* Resume the connector from paused state
|
|
9756
9758
|
*/
|
|
9757
9759
|
async resume() {
|
|
9758
|
-
logger$
|
|
9760
|
+
logger$14.debug('resuming_connector', {
|
|
9759
9761
|
current_state: this._state,
|
|
9760
9762
|
connector_id: this._connectorFlowId,
|
|
9761
9763
|
});
|
|
9762
9764
|
if (this._state !== core.ConnectorState.PAUSED) {
|
|
9763
|
-
logger$
|
|
9765
|
+
logger$14.debug('connector_resume_invalid_state', {
|
|
9764
9766
|
current_state: this._state,
|
|
9765
9767
|
connector_id: this._connectorFlowId,
|
|
9766
9768
|
});
|
|
9767
9769
|
return;
|
|
9768
9770
|
}
|
|
9769
9771
|
this._setState(core.ConnectorState.STARTED);
|
|
9770
|
-
logger$
|
|
9772
|
+
logger$14.debug('connector_resumed', {
|
|
9771
9773
|
current_state: this._state,
|
|
9772
9774
|
connector_id: this._connectorFlowId,
|
|
9773
9775
|
});
|
|
@@ -9777,7 +9779,7 @@ class BaseAsyncConnector extends TaskSpawner {
|
|
|
9777
9779
|
*/
|
|
9778
9780
|
async close(code = 1000, reason = 'normal closure') {
|
|
9779
9781
|
if (!core.ConnectorStateUtils.canClose(this._state)) {
|
|
9780
|
-
logger$
|
|
9782
|
+
logger$14.warning('connector_close_invalid_state', {
|
|
9781
9783
|
current_state: this._state,
|
|
9782
9784
|
connector_id: this._connectorFlowId,
|
|
9783
9785
|
});
|
|
@@ -9858,7 +9860,7 @@ class BaseAsyncConnector extends TaskSpawner {
|
|
|
9858
9860
|
// Add to queue and notify send loop
|
|
9859
9861
|
this._sendQueue.push(raw);
|
|
9860
9862
|
// Log for debugging
|
|
9861
|
-
logger$
|
|
9863
|
+
logger$14.debug('send_envelope_queued', {
|
|
9862
9864
|
queue_length: this._sendQueue.length,
|
|
9863
9865
|
max_queue_size: this._maxQueueSize,
|
|
9864
9866
|
});
|
|
@@ -9907,14 +9909,14 @@ class BaseAsyncConnector extends TaskSpawner {
|
|
|
9907
9909
|
const item = this._sendQueue[0];
|
|
9908
9910
|
if (!item)
|
|
9909
9911
|
continue;
|
|
9910
|
-
logger$
|
|
9912
|
+
logger$14.debug('send_loop_processing_item', {
|
|
9911
9913
|
queue_length_before_send: this._sendQueue.length,
|
|
9912
9914
|
});
|
|
9913
9915
|
// Send through transport (this may block)
|
|
9914
9916
|
await this._transportSendBytes(item);
|
|
9915
9917
|
// Only remove from queue after successful send
|
|
9916
9918
|
this._sendQueue.shift();
|
|
9917
|
-
logger$
|
|
9919
|
+
logger$14.debug('send_loop_item_sent', {
|
|
9918
9920
|
queue_length_after_send: this._sendQueue.length,
|
|
9919
9921
|
});
|
|
9920
9922
|
}
|
|
@@ -9927,14 +9929,14 @@ class BaseAsyncConnector extends TaskSpawner {
|
|
|
9927
9929
|
}
|
|
9928
9930
|
else if (error instanceof TaskCancellationError) {
|
|
9929
9931
|
// Task cancellation is expected during shutdown - log as debug, not critical
|
|
9930
|
-
logger$
|
|
9932
|
+
logger$14.debug('send loop cancelled', {
|
|
9931
9933
|
connector: this.constructor.name,
|
|
9932
9934
|
reason: error.message,
|
|
9933
9935
|
});
|
|
9934
9936
|
// Don't re-throw - this is normal during shutdown
|
|
9935
9937
|
}
|
|
9936
9938
|
else {
|
|
9937
|
-
logger$
|
|
9939
|
+
logger$14.critical('unexpected exception in send loop', {
|
|
9938
9940
|
connector: this.constructor.name,
|
|
9939
9941
|
error: error instanceof Error ? error.message : String(error),
|
|
9940
9942
|
});
|
|
@@ -9975,7 +9977,7 @@ class BaseAsyncConnector extends TaskSpawner {
|
|
|
9975
9977
|
env = JSON.parse(jsonStr);
|
|
9976
9978
|
}
|
|
9977
9979
|
catch (error) {
|
|
9978
|
-
logger$
|
|
9980
|
+
logger$14.error('Invalid envelope', {
|
|
9979
9981
|
message: message.toString(),
|
|
9980
9982
|
error: error instanceof Error ? error.message : String(error),
|
|
9981
9983
|
});
|
|
@@ -9999,7 +10001,7 @@ class BaseAsyncConnector extends TaskSpawner {
|
|
|
9999
10001
|
};
|
|
10000
10002
|
await withEnvelopeContextAsync(envelopeContext, async () => {
|
|
10001
10003
|
const prettyEnvelope = prettyModel$1(env);
|
|
10002
|
-
logger$
|
|
10004
|
+
logger$14.trace('connector_received_envelope', {
|
|
10003
10005
|
envelope: env,
|
|
10004
10006
|
pretty: prettyEnvelope,
|
|
10005
10007
|
});
|
|
@@ -10028,7 +10030,7 @@ class BaseAsyncConnector extends TaskSpawner {
|
|
|
10028
10030
|
if (error instanceof TaskCancellationError) {
|
|
10029
10031
|
throw error;
|
|
10030
10032
|
}
|
|
10031
|
-
logger$
|
|
10033
|
+
logger$14.error('handler_failed', {
|
|
10032
10034
|
error: error instanceof Error ? error.message : String(error),
|
|
10033
10035
|
envelope_id: env.id ?? null,
|
|
10034
10036
|
trace_id: env.traceId ?? null,
|
|
@@ -10049,14 +10051,14 @@ class BaseAsyncConnector extends TaskSpawner {
|
|
|
10049
10051
|
}
|
|
10050
10052
|
else if (error instanceof TaskCancellationError) {
|
|
10051
10053
|
// Task cancellation is expected during shutdown - log as debug, not critical
|
|
10052
|
-
logger$
|
|
10054
|
+
logger$14.debug('receive loop cancelled', {
|
|
10053
10055
|
connector: this.constructor.name,
|
|
10054
10056
|
reason: error.message,
|
|
10055
10057
|
});
|
|
10056
10058
|
// Don't re-throw - this is normal during shutdown
|
|
10057
10059
|
}
|
|
10058
10060
|
else {
|
|
10059
|
-
logger$
|
|
10061
|
+
logger$14.critical('unexpected_error_in recv_loop', {
|
|
10060
10062
|
error: error instanceof Error ? error.message : String(error),
|
|
10061
10063
|
});
|
|
10062
10064
|
throw error;
|
|
@@ -10072,7 +10074,7 @@ class BaseAsyncConnector extends TaskSpawner {
|
|
|
10072
10074
|
async _maybeEmitCredit(flowId, traceId) {
|
|
10073
10075
|
const remainingCredits = this._flowCtrl.getCredits(flowId);
|
|
10074
10076
|
const needsRefill = this._flowCtrl.needsRefill(flowId);
|
|
10075
|
-
logger$
|
|
10077
|
+
logger$14.debug('maybe_emit_credit_check', {
|
|
10076
10078
|
connector_id: this._connectorFlowId,
|
|
10077
10079
|
flow_id: flowId,
|
|
10078
10080
|
trace_id: traceId ?? null,
|
|
@@ -10088,7 +10090,7 @@ class BaseAsyncConnector extends TaskSpawner {
|
|
|
10088
10090
|
}
|
|
10089
10091
|
const delta = this._initialWindow;
|
|
10090
10092
|
this._flowCtrl.addCredits(flowId, delta);
|
|
10091
|
-
logger$
|
|
10093
|
+
logger$14.debug('maybe_emit_credit_emit', {
|
|
10092
10094
|
connector_id: this._connectorFlowId,
|
|
10093
10095
|
flow_id: flowId,
|
|
10094
10096
|
trace_id: traceId ?? null,
|
|
@@ -10108,7 +10110,7 @@ class BaseAsyncConnector extends TaskSpawner {
|
|
|
10108
10110
|
});
|
|
10109
10111
|
try {
|
|
10110
10112
|
await this.send(ackEnv);
|
|
10111
|
-
logger$
|
|
10113
|
+
logger$14.debug('maybe_emit_credit_sent', {
|
|
10112
10114
|
connector_id: this._connectorFlowId,
|
|
10113
10115
|
flow_id: flowId,
|
|
10114
10116
|
trace_id: traceId ?? null,
|
|
@@ -10116,7 +10118,7 @@ class BaseAsyncConnector extends TaskSpawner {
|
|
|
10116
10118
|
});
|
|
10117
10119
|
}
|
|
10118
10120
|
catch (error) {
|
|
10119
|
-
logger$
|
|
10121
|
+
logger$14.error('maybe_emit_credit_send_failed', {
|
|
10120
10122
|
connector_id: this._connectorFlowId,
|
|
10121
10123
|
flow_id: flowId,
|
|
10122
10124
|
trace_id: traceId ?? null,
|
|
@@ -10141,13 +10143,13 @@ class BaseAsyncConnector extends TaskSpawner {
|
|
|
10141
10143
|
*/
|
|
10142
10144
|
async _shutdown(code, reason, gracePeriod, exc) {
|
|
10143
10145
|
if (this._closed) {
|
|
10144
|
-
logger$
|
|
10146
|
+
logger$14.debug('shutdown_already_closed', {
|
|
10145
10147
|
connector_id: this._connectorFlowId,
|
|
10146
10148
|
current_state: this._state,
|
|
10147
10149
|
});
|
|
10148
10150
|
return;
|
|
10149
10151
|
}
|
|
10150
|
-
logger$
|
|
10152
|
+
logger$14.debug('connector_shutdown_starting', {
|
|
10151
10153
|
connector_id: this._connectorFlowId,
|
|
10152
10154
|
connector_type: this.constructor.name,
|
|
10153
10155
|
code,
|
|
@@ -10177,19 +10179,19 @@ class BaseAsyncConnector extends TaskSpawner {
|
|
|
10177
10179
|
this._sendPromiseResolve = undefined;
|
|
10178
10180
|
}
|
|
10179
10181
|
// Close transport
|
|
10180
|
-
logger$
|
|
10182
|
+
logger$14.debug('connector_closing_transport', {
|
|
10181
10183
|
connector_id: this._connectorFlowId,
|
|
10182
10184
|
connector_type: this.constructor.name,
|
|
10183
10185
|
timestamp: new Date().toISOString(),
|
|
10184
10186
|
});
|
|
10185
10187
|
await this._transportClose(code, reason);
|
|
10186
|
-
logger$
|
|
10188
|
+
logger$14.debug('connector_transport_closed', {
|
|
10187
10189
|
connector_id: this._connectorFlowId,
|
|
10188
10190
|
connector_type: this.constructor.name,
|
|
10189
10191
|
timestamp: new Date().toISOString(),
|
|
10190
10192
|
});
|
|
10191
10193
|
// Shutdown spawned tasks
|
|
10192
|
-
logger$
|
|
10194
|
+
logger$14.debug('connector_shutting_down_tasks', {
|
|
10193
10195
|
connector_id: this._connectorFlowId,
|
|
10194
10196
|
connector_type: this.constructor.name,
|
|
10195
10197
|
grace_period_ms: effectiveGracePeriod * 1000,
|
|
@@ -10201,14 +10203,14 @@ class BaseAsyncConnector extends TaskSpawner {
|
|
|
10201
10203
|
gracePeriod: effectiveGracePeriod * 1000, // Convert to milliseconds
|
|
10202
10204
|
joinTimeout: this._shutdownJoinTimeout,
|
|
10203
10205
|
});
|
|
10204
|
-
logger$
|
|
10206
|
+
logger$14.debug('connector_tasks_shutdown_complete', {
|
|
10205
10207
|
connector_id: this._connectorFlowId,
|
|
10206
10208
|
connector_type: this.constructor.name,
|
|
10207
10209
|
timestamp: new Date().toISOString(),
|
|
10208
10210
|
});
|
|
10209
10211
|
}
|
|
10210
10212
|
catch (error) {
|
|
10211
|
-
logger$
|
|
10213
|
+
logger$14.warning('task_shutdown_error', {
|
|
10212
10214
|
connector_id: this._connectorFlowId,
|
|
10213
10215
|
error: error instanceof Error ? error.message : String(error),
|
|
10214
10216
|
});
|
|
@@ -10221,7 +10223,7 @@ class BaseAsyncConnector extends TaskSpawner {
|
|
|
10221
10223
|
if (this._closeResolver) {
|
|
10222
10224
|
this._closeResolver();
|
|
10223
10225
|
}
|
|
10224
|
-
logger$
|
|
10226
|
+
logger$14.debug('connector_shutdown_complete', {
|
|
10225
10227
|
connector_id: this._connectorFlowId,
|
|
10226
10228
|
connector_type: this.constructor.name,
|
|
10227
10229
|
final_state: this._state,
|
|
@@ -10297,7 +10299,7 @@ class BoundedAsyncQueue {
|
|
|
10297
10299
|
}
|
|
10298
10300
|
}
|
|
10299
10301
|
|
|
10300
|
-
const logger$
|
|
10302
|
+
const logger$13 = getLogger('naylence.fame.connector.broadcast_channel_connector');
|
|
10301
10303
|
const BROADCAST_CHANNEL_CONNECTOR_TYPE = 'broadcast-channel-connector';
|
|
10302
10304
|
const DEFAULT_CHANNEL$7 = 'naylence-fabric';
|
|
10303
10305
|
const DEFAULT_INBOX_CAPACITY$7 = 2048;
|
|
@@ -10386,7 +10388,7 @@ let BroadcastChannelConnector$2 = class BroadcastChannelConnector extends BaseAs
|
|
|
10386
10388
|
this.localNodeId = normalizedLocalNodeId;
|
|
10387
10389
|
this.targetNodeId = BroadcastChannelConnector.normalizeTargetNodeId(config.initialTargetNodeId);
|
|
10388
10390
|
this.channel = new BroadcastChannel(this.channelName);
|
|
10389
|
-
logger$
|
|
10391
|
+
logger$13.debug('broadcast_channel_connector_created', {
|
|
10390
10392
|
channel: this.channelName,
|
|
10391
10393
|
connector_id: this.connectorId,
|
|
10392
10394
|
local_node_id: this.localNodeId,
|
|
@@ -10398,7 +10400,7 @@ let BroadcastChannelConnector$2 = class BroadcastChannelConnector extends BaseAs
|
|
|
10398
10400
|
this.onMsg = (event) => {
|
|
10399
10401
|
// Guard: Don't process if listener was unregistered
|
|
10400
10402
|
if (!this.listenerRegistered) {
|
|
10401
|
-
logger$
|
|
10403
|
+
logger$13.warning('broadcast_channel_message_after_unregister', {
|
|
10402
10404
|
channel: this.channelName,
|
|
10403
10405
|
connector_id: this.connectorId,
|
|
10404
10406
|
timestamp: new Date().toISOString(),
|
|
@@ -10406,7 +10408,7 @@ let BroadcastChannelConnector$2 = class BroadcastChannelConnector extends BaseAs
|
|
|
10406
10408
|
return;
|
|
10407
10409
|
}
|
|
10408
10410
|
const message = event.data;
|
|
10409
|
-
logger$
|
|
10411
|
+
logger$13.debug('broadcast_channel_raw_event', {
|
|
10410
10412
|
channel: this.channelName,
|
|
10411
10413
|
connector_id: this.connectorId,
|
|
10412
10414
|
message_type: message && typeof message === 'object'
|
|
@@ -10422,7 +10424,7 @@ let BroadcastChannelConnector$2 = class BroadcastChannelConnector extends BaseAs
|
|
|
10422
10424
|
const busMessage = message;
|
|
10423
10425
|
const senderNodeId = BroadcastChannelConnector.normalizeNodeId(busMessage.senderNodeId);
|
|
10424
10426
|
if (!senderNodeId) {
|
|
10425
|
-
logger$
|
|
10427
|
+
logger$13.debug('broadcast_channel_message_rejected', {
|
|
10426
10428
|
channel: this.channelName,
|
|
10427
10429
|
connector_id: this.connectorId,
|
|
10428
10430
|
reason: 'missing_sender_node_id',
|
|
@@ -10430,7 +10432,7 @@ let BroadcastChannelConnector$2 = class BroadcastChannelConnector extends BaseAs
|
|
|
10430
10432
|
return;
|
|
10431
10433
|
}
|
|
10432
10434
|
if (senderNodeId === this.localNodeId) {
|
|
10433
|
-
logger$
|
|
10435
|
+
logger$13.debug('broadcast_channel_message_rejected', {
|
|
10434
10436
|
channel: this.channelName,
|
|
10435
10437
|
connector_id: this.connectorId,
|
|
10436
10438
|
reason: 'self_echo',
|
|
@@ -10444,14 +10446,14 @@ let BroadcastChannelConnector$2 = class BroadcastChannelConnector extends BaseAs
|
|
|
10444
10446
|
}
|
|
10445
10447
|
const payload = BroadcastChannelConnector.coercePayload(busMessage.payload);
|
|
10446
10448
|
if (!payload) {
|
|
10447
|
-
logger$
|
|
10449
|
+
logger$13.debug('broadcast_channel_payload_rejected', {
|
|
10448
10450
|
channel: this.channelName,
|
|
10449
10451
|
connector_id: this.connectorId,
|
|
10450
10452
|
reason: 'unrecognized_payload_type',
|
|
10451
10453
|
});
|
|
10452
10454
|
return;
|
|
10453
10455
|
}
|
|
10454
|
-
logger$
|
|
10456
|
+
logger$13.debug('broadcast_channel_message_received', {
|
|
10455
10457
|
channel: this.channelName,
|
|
10456
10458
|
sender_id: message?.senderId,
|
|
10457
10459
|
sender_node_id: senderNodeId,
|
|
@@ -10480,14 +10482,14 @@ let BroadcastChannelConnector$2 = class BroadcastChannelConnector extends BaseAs
|
|
|
10480
10482
|
}
|
|
10481
10483
|
catch (error) {
|
|
10482
10484
|
if (error instanceof QueueFullError) {
|
|
10483
|
-
logger$
|
|
10485
|
+
logger$13.warning('broadcast_channel_receive_queue_full', {
|
|
10484
10486
|
channel: this.channelName,
|
|
10485
10487
|
inbox_capacity: this.inboxCapacity,
|
|
10486
10488
|
inbox_remaining_capacity: this.inbox.remainingCapacity,
|
|
10487
10489
|
});
|
|
10488
10490
|
}
|
|
10489
10491
|
else {
|
|
10490
|
-
logger$
|
|
10492
|
+
logger$13.error('broadcast_channel_receive_error', {
|
|
10491
10493
|
channel: this.channelName,
|
|
10492
10494
|
error: error instanceof Error ? error.message : String(error),
|
|
10493
10495
|
});
|
|
@@ -10501,7 +10503,7 @@ let BroadcastChannelConnector$2 = class BroadcastChannelConnector extends BaseAs
|
|
|
10501
10503
|
// Setup visibility change monitoring
|
|
10502
10504
|
this.visibilityChangeHandler = () => {
|
|
10503
10505
|
const isHidden = document.hidden;
|
|
10504
|
-
logger$
|
|
10506
|
+
logger$13.debug('broadcast_channel_visibility_changed', {
|
|
10505
10507
|
channel: this.channelName,
|
|
10506
10508
|
connector_id: this.connectorId,
|
|
10507
10509
|
visibility: isHidden ? 'hidden' : 'visible',
|
|
@@ -10510,7 +10512,7 @@ let BroadcastChannelConnector$2 = class BroadcastChannelConnector extends BaseAs
|
|
|
10510
10512
|
// Pause/resume connector based on visibility
|
|
10511
10513
|
if (isHidden && this.state === core.ConnectorState.STARTED) {
|
|
10512
10514
|
this.pause().catch((err) => {
|
|
10513
|
-
logger$
|
|
10515
|
+
logger$13.warning('broadcast_channel_pause_failed', {
|
|
10514
10516
|
channel: this.channelName,
|
|
10515
10517
|
connector_id: this.connectorId,
|
|
10516
10518
|
error: err instanceof Error ? err.message : String(err),
|
|
@@ -10519,7 +10521,7 @@ let BroadcastChannelConnector$2 = class BroadcastChannelConnector extends BaseAs
|
|
|
10519
10521
|
}
|
|
10520
10522
|
else if (!isHidden && this.state === core.ConnectorState.PAUSED) {
|
|
10521
10523
|
this.resume().catch((err) => {
|
|
10522
|
-
logger$
|
|
10524
|
+
logger$13.warning('broadcast_channel_resume_failed', {
|
|
10523
10525
|
channel: this.channelName,
|
|
10524
10526
|
connector_id: this.connectorId,
|
|
10525
10527
|
error: err instanceof Error ? err.message : String(err),
|
|
@@ -10533,7 +10535,7 @@ let BroadcastChannelConnector$2 = class BroadcastChannelConnector extends BaseAs
|
|
|
10533
10535
|
// Track page lifecycle events to detect browser unload/discard
|
|
10534
10536
|
if (typeof window !== 'undefined') {
|
|
10535
10537
|
const lifecycleLogger = (event) => {
|
|
10536
|
-
logger$
|
|
10538
|
+
logger$13.debug('broadcast_channel_page_lifecycle', {
|
|
10537
10539
|
channel: this.channelName,
|
|
10538
10540
|
connector_id: this.connectorId,
|
|
10539
10541
|
event_type: event.type,
|
|
@@ -10549,7 +10551,7 @@ let BroadcastChannelConnector$2 = class BroadcastChannelConnector extends BaseAs
|
|
|
10549
10551
|
document.addEventListener('resume', lifecycleLogger);
|
|
10550
10552
|
}
|
|
10551
10553
|
// Log initial state with detailed visibility info
|
|
10552
|
-
logger$
|
|
10554
|
+
logger$13.debug('broadcast_channel_initial_visibility', {
|
|
10553
10555
|
channel: this.channelName,
|
|
10554
10556
|
connector_id: this.connectorId,
|
|
10555
10557
|
visibility: document.hidden ? 'hidden' : 'visible',
|
|
@@ -10581,14 +10583,14 @@ let BroadcastChannelConnector$2 = class BroadcastChannelConnector extends BaseAs
|
|
|
10581
10583
|
}
|
|
10582
10584
|
catch (error) {
|
|
10583
10585
|
if (error instanceof QueueFullError) {
|
|
10584
|
-
logger$
|
|
10586
|
+
logger$13.warning('broadcast_channel_push_queue_full', {
|
|
10585
10587
|
channel: this.channelName,
|
|
10586
10588
|
inbox_capacity: this.inboxCapacity,
|
|
10587
10589
|
inbox_remaining_capacity: this.inbox.remainingCapacity,
|
|
10588
10590
|
});
|
|
10589
10591
|
throw error;
|
|
10590
10592
|
}
|
|
10591
|
-
logger$
|
|
10593
|
+
logger$13.error('broadcast_channel_push_failed', {
|
|
10592
10594
|
channel: this.channelName,
|
|
10593
10595
|
error: error instanceof Error ? error.message : String(error),
|
|
10594
10596
|
});
|
|
@@ -10598,7 +10600,7 @@ let BroadcastChannelConnector$2 = class BroadcastChannelConnector extends BaseAs
|
|
|
10598
10600
|
async _transportSendBytes(data) {
|
|
10599
10601
|
ensureBroadcastEnvironment();
|
|
10600
10602
|
const targetNodeId = this.targetNodeId ?? '*';
|
|
10601
|
-
logger$
|
|
10603
|
+
logger$13.debug('broadcast_channel_message_sending', {
|
|
10602
10604
|
channel: this.channelName,
|
|
10603
10605
|
sender_id: this.connectorId,
|
|
10604
10606
|
sender_node_id: this.localNodeId,
|
|
@@ -10619,7 +10621,7 @@ let BroadcastChannelConnector$2 = class BroadcastChannelConnector extends BaseAs
|
|
|
10619
10621
|
return item;
|
|
10620
10622
|
}
|
|
10621
10623
|
async _transportClose(code, reason) {
|
|
10622
|
-
logger$
|
|
10624
|
+
logger$13.debug('broadcast_channel_transport_closing', {
|
|
10623
10625
|
channel: this.channelName,
|
|
10624
10626
|
connector_id: this.connectorId,
|
|
10625
10627
|
code,
|
|
@@ -10628,14 +10630,14 @@ let BroadcastChannelConnector$2 = class BroadcastChannelConnector extends BaseAs
|
|
|
10628
10630
|
timestamp: new Date().toISOString(),
|
|
10629
10631
|
});
|
|
10630
10632
|
if (this.listenerRegistered) {
|
|
10631
|
-
logger$
|
|
10633
|
+
logger$13.debug('broadcast_channel_removing_listener', {
|
|
10632
10634
|
channel: this.channelName,
|
|
10633
10635
|
connector_id: this.connectorId,
|
|
10634
10636
|
timestamp: new Date().toISOString(),
|
|
10635
10637
|
});
|
|
10636
10638
|
this.channel.removeEventListener('message', this.onMsg);
|
|
10637
10639
|
this.listenerRegistered = false;
|
|
10638
|
-
logger$
|
|
10640
|
+
logger$13.debug('broadcast_channel_listener_removed', {
|
|
10639
10641
|
channel: this.channelName,
|
|
10640
10642
|
connector_id: this.connectorId,
|
|
10641
10643
|
timestamp: new Date().toISOString(),
|
|
@@ -10648,13 +10650,13 @@ let BroadcastChannelConnector$2 = class BroadcastChannelConnector extends BaseAs
|
|
|
10648
10650
|
this.visibilityChangeListenerRegistered = false;
|
|
10649
10651
|
this.visibilityChangeHandler = undefined;
|
|
10650
10652
|
}
|
|
10651
|
-
logger$
|
|
10653
|
+
logger$13.debug('broadcast_channel_closing', {
|
|
10652
10654
|
channel: this.channelName,
|
|
10653
10655
|
connector_id: this.connectorId,
|
|
10654
10656
|
timestamp: new Date().toISOString(),
|
|
10655
10657
|
});
|
|
10656
10658
|
this.channel.close();
|
|
10657
|
-
logger$
|
|
10659
|
+
logger$13.debug('broadcast_channel_closed', {
|
|
10658
10660
|
channel: this.channelName,
|
|
10659
10661
|
connector_id: this.connectorId,
|
|
10660
10662
|
timestamp: new Date().toISOString(),
|
|
@@ -10678,7 +10680,7 @@ let BroadcastChannelConnector$2 = class BroadcastChannelConnector extends BaseAs
|
|
|
10678
10680
|
if (targetNodeId &&
|
|
10679
10681
|
targetNodeId !== '*' &&
|
|
10680
10682
|
targetNodeId !== this.localNodeId) {
|
|
10681
|
-
logger$
|
|
10683
|
+
logger$13.debug('broadcast_channel_message_rejected', {
|
|
10682
10684
|
channel: this.channelName,
|
|
10683
10685
|
connector_id: this.connectorId,
|
|
10684
10686
|
reason: 'wildcard_target_mismatch',
|
|
@@ -10694,7 +10696,7 @@ let BroadcastChannelConnector$2 = class BroadcastChannelConnector extends BaseAs
|
|
|
10694
10696
|
if (expectedSender &&
|
|
10695
10697
|
expectedSender !== '*' &&
|
|
10696
10698
|
senderNodeId !== expectedSender) {
|
|
10697
|
-
logger$
|
|
10699
|
+
logger$13.debug('broadcast_channel_message_rejected', {
|
|
10698
10700
|
channel: this.channelName,
|
|
10699
10701
|
connector_id: this.connectorId,
|
|
10700
10702
|
reason: 'unexpected_sender',
|
|
@@ -10707,7 +10709,7 @@ let BroadcastChannelConnector$2 = class BroadcastChannelConnector extends BaseAs
|
|
|
10707
10709
|
if (targetNodeId &&
|
|
10708
10710
|
targetNodeId !== '*' &&
|
|
10709
10711
|
targetNodeId !== this.localNodeId) {
|
|
10710
|
-
logger$
|
|
10712
|
+
logger$13.debug('broadcast_channel_message_rejected', {
|
|
10711
10713
|
channel: this.channelName,
|
|
10712
10714
|
connector_id: this.connectorId,
|
|
10713
10715
|
reason: 'unexpected_target',
|
|
@@ -10732,7 +10734,7 @@ let BroadcastChannelConnector$2 = class BroadcastChannelConnector extends BaseAs
|
|
|
10732
10734
|
return 'unknown';
|
|
10733
10735
|
}
|
|
10734
10736
|
logInboxSnapshot(event, extra = {}) {
|
|
10735
|
-
logger$
|
|
10737
|
+
logger$13.debug(event, {
|
|
10736
10738
|
channel: this.channelName,
|
|
10737
10739
|
connector_id: this.connectorId,
|
|
10738
10740
|
connector_state: this.state,
|
|
@@ -10748,7 +10750,7 @@ let BroadcastChannelConnector$2 = class BroadcastChannelConnector extends BaseAs
|
|
|
10748
10750
|
await super.start(inboundHandler);
|
|
10749
10751
|
// After transitioning to STARTED, check if tab is already hidden
|
|
10750
10752
|
if (typeof document !== 'undefined' && document.hidden) {
|
|
10751
|
-
logger$
|
|
10753
|
+
logger$13.debug('broadcast_channel_start_in_hidden_tab', {
|
|
10752
10754
|
channel: this.channelName,
|
|
10753
10755
|
connector_id: this.connectorId,
|
|
10754
10756
|
document_hidden: document.hidden,
|
|
@@ -10758,7 +10760,7 @@ let BroadcastChannelConnector$2 = class BroadcastChannelConnector extends BaseAs
|
|
|
10758
10760
|
});
|
|
10759
10761
|
// Immediately pause if tab is hidden at start time
|
|
10760
10762
|
await this.pause().catch((err) => {
|
|
10761
|
-
logger$
|
|
10763
|
+
logger$13.warning('broadcast_channel_initial_pause_failed', {
|
|
10762
10764
|
channel: this.channelName,
|
|
10763
10765
|
connector_id: this.connectorId,
|
|
10764
10766
|
error: err instanceof Error ? err.message : String(err),
|
|
@@ -10776,7 +10778,7 @@ let BroadcastChannelConnector$2 = class BroadcastChannelConnector extends BaseAs
|
|
|
10776
10778
|
return;
|
|
10777
10779
|
}
|
|
10778
10780
|
this.targetNodeId = normalized;
|
|
10779
|
-
logger$
|
|
10781
|
+
logger$13.debug('broadcast_channel_target_updated', {
|
|
10780
10782
|
channel: this.channelName,
|
|
10781
10783
|
connector_id: this.connectorId,
|
|
10782
10784
|
local_node_id: this.localNodeId,
|
|
@@ -10786,7 +10788,7 @@ let BroadcastChannelConnector$2 = class BroadcastChannelConnector extends BaseAs
|
|
|
10786
10788
|
}
|
|
10787
10789
|
setWildcardTarget() {
|
|
10788
10790
|
this.targetNodeId = '*';
|
|
10789
|
-
logger$
|
|
10791
|
+
logger$13.debug('broadcast_channel_target_updated', {
|
|
10790
10792
|
channel: this.channelName,
|
|
10791
10793
|
connector_id: this.connectorId,
|
|
10792
10794
|
local_node_id: this.localNodeId,
|
|
@@ -10959,7 +10961,7 @@ function broadcastChannelGrantToConnectorConfig(grant) {
|
|
|
10959
10961
|
return config;
|
|
10960
10962
|
}
|
|
10961
10963
|
|
|
10962
|
-
const logger$
|
|
10964
|
+
const logger$12 = getLogger('naylence.fame.node.upstream_session_manager');
|
|
10963
10965
|
function isPlainRecord$4(value) {
|
|
10964
10966
|
if (typeof value !== 'object' || value === null) {
|
|
10965
10967
|
return false;
|
|
@@ -11032,6 +11034,7 @@ function normalizeOptions$k(options) {
|
|
|
11032
11034
|
const onEpochChangeValue = pickOption$2(record, 'onEpochChange', 'on_epoch_change');
|
|
11033
11035
|
const onEpochChange = typeof onEpochChangeValue === 'function' ? onEpochChangeValue : undefined;
|
|
11034
11036
|
const admissionClient = pickOption$2(record, 'admissionClient', 'admission_client');
|
|
11037
|
+
const retryPolicy = pickOption$2(record, 'retryPolicy', 'retry_policy');
|
|
11035
11038
|
return {
|
|
11036
11039
|
node,
|
|
11037
11040
|
attachClient,
|
|
@@ -11043,6 +11046,7 @@ function normalizeOptions$k(options) {
|
|
|
11043
11046
|
onAttach: validatedOnAttach,
|
|
11044
11047
|
onEpochChange,
|
|
11045
11048
|
admissionClient: admissionClient ?? undefined,
|
|
11049
|
+
retryPolicy: retryPolicy ?? undefined,
|
|
11046
11050
|
};
|
|
11047
11051
|
}
|
|
11048
11052
|
class UpstreamSessionManager extends TaskSpawner {
|
|
@@ -11062,6 +11066,7 @@ class UpstreamSessionManager extends TaskSpawner {
|
|
|
11062
11066
|
this.hadSuccessfulAttach = false;
|
|
11063
11067
|
this.lastConnectorState = null;
|
|
11064
11068
|
this.connectEpoch = 0;
|
|
11069
|
+
this.initialAttempts = 0;
|
|
11065
11070
|
this._visibilityHandler = null;
|
|
11066
11071
|
const options = normalizeOptions$k(optionsInput);
|
|
11067
11072
|
this.node = options.node;
|
|
@@ -11075,31 +11080,34 @@ class UpstreamSessionManager extends TaskSpawner {
|
|
|
11075
11080
|
this.admissionClient =
|
|
11076
11081
|
options.admissionClient ?? options.node.admissionClient;
|
|
11077
11082
|
this.wrappedHandler = this.makeHeartbeatEnabledHandler(options.inboundHandler);
|
|
11078
|
-
|
|
11083
|
+
// Store the connection retry policy (can be null, in which case default behavior applies)
|
|
11084
|
+
this.connectionRetryPolicy = options.retryPolicy ?? null;
|
|
11085
|
+
logger$12.debug('created_upstream_session_manager', {
|
|
11079
11086
|
target_system_id: this.targetSystemId,
|
|
11087
|
+
has_retry_policy: this.connectionRetryPolicy !== null,
|
|
11080
11088
|
});
|
|
11081
11089
|
}
|
|
11082
11090
|
get systemId() {
|
|
11083
11091
|
return this.targetSystemId;
|
|
11084
11092
|
}
|
|
11085
11093
|
setupVisibilityListener() {
|
|
11086
|
-
logger$
|
|
11094
|
+
logger$12.debug('setup_visibility_listener_called', {
|
|
11087
11095
|
has_document: typeof document !== 'undefined',
|
|
11088
11096
|
});
|
|
11089
11097
|
if (typeof document !== 'undefined' && document.addEventListener) {
|
|
11090
11098
|
this._visibilityHandler = () => {
|
|
11091
|
-
logger$
|
|
11099
|
+
logger$12.debug('visibility_change_event_fired', {
|
|
11092
11100
|
state: document.visibilityState,
|
|
11093
11101
|
});
|
|
11094
11102
|
if (document.visibilityState === 'visible') {
|
|
11095
|
-
logger$
|
|
11103
|
+
logger$12.debug('visibility_change_detected_waking_up');
|
|
11096
11104
|
this.wakeEvent.set();
|
|
11097
11105
|
}
|
|
11098
11106
|
};
|
|
11099
11107
|
document.addEventListener('visibilitychange', this._visibilityHandler);
|
|
11100
11108
|
}
|
|
11101
11109
|
else {
|
|
11102
|
-
logger$
|
|
11110
|
+
logger$12.debug('setup_visibility_listener_skipped_no_document');
|
|
11103
11111
|
}
|
|
11104
11112
|
}
|
|
11105
11113
|
teardownVisibilityListener() {
|
|
@@ -11132,13 +11140,13 @@ class UpstreamSessionManager extends TaskSpawner {
|
|
|
11132
11140
|
}
|
|
11133
11141
|
throw new FameConnectError('Upstream session manager failed to attach');
|
|
11134
11142
|
}
|
|
11135
|
-
logger$
|
|
11143
|
+
logger$12.debug('upstream_session_manager_started');
|
|
11136
11144
|
}
|
|
11137
11145
|
getActiveConnector() {
|
|
11138
11146
|
return this.connector;
|
|
11139
11147
|
}
|
|
11140
11148
|
async stop() {
|
|
11141
|
-
logger$
|
|
11149
|
+
logger$12.debug('upstream_session_manager_stopping');
|
|
11142
11150
|
this.teardownVisibilityListener();
|
|
11143
11151
|
this.stopEvent.set();
|
|
11144
11152
|
this.currentStopSubtasks?.set();
|
|
@@ -11149,7 +11157,7 @@ class UpstreamSessionManager extends TaskSpawner {
|
|
|
11149
11157
|
}
|
|
11150
11158
|
catch (error) {
|
|
11151
11159
|
if (!(error instanceof TaskCancelledError)) {
|
|
11152
|
-
logger$
|
|
11160
|
+
logger$12.debug('fsm_task_stopped_with_error', {
|
|
11153
11161
|
error: error.message,
|
|
11154
11162
|
});
|
|
11155
11163
|
}
|
|
@@ -11158,13 +11166,13 @@ class UpstreamSessionManager extends TaskSpawner {
|
|
|
11158
11166
|
}
|
|
11159
11167
|
if (this.connector) {
|
|
11160
11168
|
await this.connector.stop().catch((error) => {
|
|
11161
|
-
logger$
|
|
11169
|
+
logger$12.debug('connector_stop_error', {
|
|
11162
11170
|
error: error.message,
|
|
11163
11171
|
});
|
|
11164
11172
|
});
|
|
11165
11173
|
this.connector = null;
|
|
11166
11174
|
}
|
|
11167
|
-
logger$
|
|
11175
|
+
logger$12.debug('upstream_session_manager_stopped');
|
|
11168
11176
|
}
|
|
11169
11177
|
async send(envelope) {
|
|
11170
11178
|
if (this.messageQueue.length >= UpstreamSessionManager.TX_QUEUE_MAX) {
|
|
@@ -11192,11 +11200,14 @@ class UpstreamSessionManager extends TaskSpawner {
|
|
|
11192
11200
|
}
|
|
11193
11201
|
async fsmLoop() {
|
|
11194
11202
|
let delay = UpstreamSessionManager.BACKOFF_INITIAL;
|
|
11203
|
+
this.initialAttempts = 0;
|
|
11195
11204
|
while (!this.stopEvent.isSet()) {
|
|
11196
11205
|
const startTime = Date.now();
|
|
11206
|
+
this.initialAttempts += 1;
|
|
11197
11207
|
try {
|
|
11198
11208
|
await this.connectCycle();
|
|
11199
11209
|
delay = UpstreamSessionManager.BACKOFF_INITIAL;
|
|
11210
|
+
this.initialAttempts = 0; // Reset on success
|
|
11200
11211
|
}
|
|
11201
11212
|
catch (error) {
|
|
11202
11213
|
// Reset backoff if the connection was alive for more than 10 seconds
|
|
@@ -11206,32 +11217,38 @@ class UpstreamSessionManager extends TaskSpawner {
|
|
|
11206
11217
|
if (error instanceof TaskCancelledError) {
|
|
11207
11218
|
throw error;
|
|
11208
11219
|
}
|
|
11220
|
+
// Determine if we should fail-fast or retry
|
|
11221
|
+
const shouldFailFast = this.shouldFailFastOnError(error);
|
|
11209
11222
|
if (error instanceof FameTransportClose ||
|
|
11210
11223
|
error instanceof FameConnectError) {
|
|
11211
|
-
logger$
|
|
11224
|
+
logger$12.warning('upstream_link_closed', {
|
|
11212
11225
|
error: error.message,
|
|
11213
|
-
will_retry:
|
|
11226
|
+
will_retry: !shouldFailFast,
|
|
11227
|
+
attempt: this.initialAttempts,
|
|
11228
|
+
has_retry_policy: this.connectionRetryPolicy !== null,
|
|
11214
11229
|
});
|
|
11215
|
-
if (
|
|
11230
|
+
if (shouldFailFast && error instanceof FameConnectError) {
|
|
11216
11231
|
throw error;
|
|
11217
11232
|
}
|
|
11218
11233
|
}
|
|
11219
11234
|
else {
|
|
11220
11235
|
const err = error;
|
|
11221
11236
|
if (err.name === 'OAuth2PkceRedirectInitiatedError') {
|
|
11222
|
-
logger$
|
|
11237
|
+
logger$12.info('upstream_link_redirecting', {
|
|
11223
11238
|
error: err.message,
|
|
11224
11239
|
will_retry: true,
|
|
11225
11240
|
});
|
|
11226
11241
|
}
|
|
11227
11242
|
else {
|
|
11228
|
-
logger$
|
|
11243
|
+
logger$12.warning('upstream_link_closed', {
|
|
11229
11244
|
error: err.message,
|
|
11230
|
-
will_retry:
|
|
11245
|
+
will_retry: !shouldFailFast,
|
|
11246
|
+
attempt: this.initialAttempts,
|
|
11247
|
+
has_retry_policy: this.connectionRetryPolicy !== null,
|
|
11231
11248
|
exc_info: true,
|
|
11232
11249
|
});
|
|
11233
11250
|
}
|
|
11234
|
-
if (
|
|
11251
|
+
if (shouldFailFast) {
|
|
11235
11252
|
throw error;
|
|
11236
11253
|
}
|
|
11237
11254
|
}
|
|
@@ -11239,52 +11256,77 @@ class UpstreamSessionManager extends TaskSpawner {
|
|
|
11239
11256
|
}
|
|
11240
11257
|
}
|
|
11241
11258
|
}
|
|
11259
|
+
/**
|
|
11260
|
+
* Determine whether to fail immediately or continue retrying.
|
|
11261
|
+
* Returns true if we should throw the error instead of retrying.
|
|
11262
|
+
*/
|
|
11263
|
+
shouldFailFastOnError(error) {
|
|
11264
|
+
// If no policy is configured, use legacy behavior (fail-fast after first attempt)
|
|
11265
|
+
if (!this.connectionRetryPolicy) {
|
|
11266
|
+
// After first successful attach, always retry (existing behavior)
|
|
11267
|
+
if (this.hadSuccessfulAttach) {
|
|
11268
|
+
return false;
|
|
11269
|
+
}
|
|
11270
|
+
// Without a policy, fail on first error
|
|
11271
|
+
return true;
|
|
11272
|
+
}
|
|
11273
|
+
// Delegate decision to the policy
|
|
11274
|
+
const shouldRetry = this.connectionRetryPolicy.shouldRetry({
|
|
11275
|
+
hadSuccessfulAttach: this.hadSuccessfulAttach,
|
|
11276
|
+
attemptNumber: this.initialAttempts,
|
|
11277
|
+
error,
|
|
11278
|
+
});
|
|
11279
|
+
return !shouldRetry;
|
|
11280
|
+
}
|
|
11242
11281
|
async applyBackoff(delay) {
|
|
11243
11282
|
const jitter = Math.random() * delay;
|
|
11244
|
-
await this.sleepWithStop(delay + jitter);
|
|
11283
|
+
const wasWoken = await this.sleepWithStop(delay + jitter);
|
|
11284
|
+
// If sleep was interrupted by visibility change (user returned to tab),
|
|
11285
|
+
// reset backoff to initial delay for immediate retry with fresh backoff
|
|
11286
|
+
if (wasWoken) {
|
|
11287
|
+
logger$12.debug('backoff_reset_on_visibility_change', {
|
|
11288
|
+
previous_delay: delay,
|
|
11289
|
+
new_delay: UpstreamSessionManager.BACKOFF_INITIAL,
|
|
11290
|
+
});
|
|
11291
|
+
return UpstreamSessionManager.BACKOFF_INITIAL;
|
|
11292
|
+
}
|
|
11245
11293
|
return Math.min(delay * 2, UpstreamSessionManager.BACKOFF_CAP);
|
|
11246
11294
|
}
|
|
11295
|
+
/**
|
|
11296
|
+
* Sleep for the specified duration, but can be interrupted by stop or wake events.
|
|
11297
|
+
* @returns true if interrupted by wake event (e.g., visibility change), false otherwise
|
|
11298
|
+
*/
|
|
11247
11299
|
async sleepWithStop(delaySeconds) {
|
|
11248
11300
|
if (delaySeconds <= 0) {
|
|
11249
|
-
return;
|
|
11250
|
-
}
|
|
11251
|
-
// If the document is visible, cap the backoff delay to improve UX
|
|
11252
|
-
// This ensures that if the user is watching, we retry quickly (e.g. 1s)
|
|
11253
|
-
// instead of waiting for the full exponential backoff (up to 30s).
|
|
11254
|
-
let effectiveDelay = delaySeconds;
|
|
11255
|
-
if (typeof document !== 'undefined' &&
|
|
11256
|
-
document.visibilityState === 'visible') {
|
|
11257
|
-
effectiveDelay = Math.min(delaySeconds, 1.0);
|
|
11258
|
-
if (effectiveDelay < delaySeconds) {
|
|
11259
|
-
logger$11.debug('sleep_reduced_document_visible', {
|
|
11260
|
-
original: delaySeconds,
|
|
11261
|
-
new: effectiveDelay,
|
|
11262
|
-
});
|
|
11263
|
-
}
|
|
11301
|
+
return false;
|
|
11264
11302
|
}
|
|
11303
|
+
// Check if wake event is already set (e.g., visibility just changed)
|
|
11265
11304
|
if (this.wakeEvent.isSet()) {
|
|
11266
11305
|
this.wakeEvent.clear();
|
|
11267
|
-
|
|
11306
|
+
logger$12.debug('sleep_skipped_wake_event_pending');
|
|
11307
|
+
return true;
|
|
11268
11308
|
}
|
|
11269
11309
|
let timeout;
|
|
11270
11310
|
const sleepPromise = new Promise((resolve) => {
|
|
11271
11311
|
timeout = setTimeout(() => {
|
|
11272
11312
|
timeout = undefined;
|
|
11273
11313
|
resolve();
|
|
11274
|
-
},
|
|
11314
|
+
}, delaySeconds * 1000);
|
|
11275
11315
|
});
|
|
11276
11316
|
await Promise.race([
|
|
11277
11317
|
sleepPromise,
|
|
11278
11318
|
this.stopEvent.wait(),
|
|
11279
11319
|
this.wakeEvent.wait(),
|
|
11280
11320
|
]);
|
|
11281
|
-
|
|
11282
|
-
|
|
11321
|
+
const wasWoken = this.wakeEvent.isSet();
|
|
11322
|
+
if (wasWoken) {
|
|
11323
|
+
logger$12.debug('sleep_interrupted_by_wake_event');
|
|
11283
11324
|
this.wakeEvent.clear();
|
|
11284
11325
|
}
|
|
11285
11326
|
if (timeout !== undefined) {
|
|
11286
11327
|
clearTimeout(timeout);
|
|
11287
11328
|
}
|
|
11329
|
+
return wasWoken;
|
|
11288
11330
|
}
|
|
11289
11331
|
getNodeAttachGrant(connectionGrants) {
|
|
11290
11332
|
if (!connectionGrants) {
|
|
@@ -11341,7 +11383,7 @@ class UpstreamSessionManager extends TaskSpawner {
|
|
|
11341
11383
|
await connector.start(this.wrappedHandler);
|
|
11342
11384
|
this.connector = connector;
|
|
11343
11385
|
const callbackGrants = this.node.gatherSupportedCallbackGrants();
|
|
11344
|
-
logger$
|
|
11386
|
+
logger$12.debug('callback_grants_before_augmentation', {
|
|
11345
11387
|
count: callbackGrants.length,
|
|
11346
11388
|
types: callbackGrants.map((g) => g.type),
|
|
11347
11389
|
});
|
|
@@ -11351,7 +11393,7 @@ class UpstreamSessionManager extends TaskSpawner {
|
|
|
11351
11393
|
const broadcastCallbackGrant = shouldAddBroadcastGrant
|
|
11352
11394
|
? this.createBroadcastCallbackGrant(grant)
|
|
11353
11395
|
: null;
|
|
11354
|
-
logger$
|
|
11396
|
+
logger$12.debug('broadcast_callback_grant_check', {
|
|
11355
11397
|
should_add: shouldAddBroadcastGrant,
|
|
11356
11398
|
grant_created: !!broadcastCallbackGrant,
|
|
11357
11399
|
});
|
|
@@ -11370,12 +11412,12 @@ class UpstreamSessionManager extends TaskSpawner {
|
|
|
11370
11412
|
const isDuplicate = callbackGrants.some((existing) => JSON.stringify(existing) === JSON.stringify(grant));
|
|
11371
11413
|
if (!isDuplicate) {
|
|
11372
11414
|
callbackGrants.push(grant);
|
|
11373
|
-
logger$
|
|
11415
|
+
logger$12.debug('added_connection_grant_as_callback', {
|
|
11374
11416
|
type: grant.type,
|
|
11375
11417
|
});
|
|
11376
11418
|
}
|
|
11377
11419
|
else {
|
|
11378
|
-
logger$
|
|
11420
|
+
logger$12.debug('skipped_duplicate_connection_grant', {
|
|
11379
11421
|
type: grant.type,
|
|
11380
11422
|
});
|
|
11381
11423
|
}
|
|
@@ -11387,12 +11429,12 @@ class UpstreamSessionManager extends TaskSpawner {
|
|
|
11387
11429
|
if (broadcastCallbackGrant &&
|
|
11388
11430
|
this.shouldAdvertiseBroadcastGrant(grant, callbackGrants)) {
|
|
11389
11431
|
callbackGrants.push(broadcastCallbackGrant);
|
|
11390
|
-
logger$
|
|
11432
|
+
logger$12.debug('added_broadcast_callback_grant');
|
|
11391
11433
|
}
|
|
11392
11434
|
else if (broadcastCallbackGrant) {
|
|
11393
|
-
logger$
|
|
11435
|
+
logger$12.debug('skipped_duplicate_broadcast_callback_grant');
|
|
11394
11436
|
}
|
|
11395
|
-
logger$
|
|
11437
|
+
logger$12.debug('callback_grants_after_augmentation', {
|
|
11396
11438
|
count: callbackGrants.length,
|
|
11397
11439
|
types: callbackGrants.map((g) => g.type),
|
|
11398
11440
|
});
|
|
@@ -11405,7 +11447,7 @@ class UpstreamSessionManager extends TaskSpawner {
|
|
|
11405
11447
|
targetAware.setTargetNodeId(this.targetSystemId);
|
|
11406
11448
|
}
|
|
11407
11449
|
catch (error) {
|
|
11408
|
-
logger$
|
|
11450
|
+
logger$12.warning('broadcast_channel_target_apply_failed', {
|
|
11409
11451
|
error: error instanceof Error ? error.message : String(error),
|
|
11410
11452
|
target_node_id: this.targetSystemId,
|
|
11411
11453
|
});
|
|
@@ -11427,14 +11469,14 @@ class UpstreamSessionManager extends TaskSpawner {
|
|
|
11427
11469
|
});
|
|
11428
11470
|
}
|
|
11429
11471
|
else {
|
|
11430
|
-
logger$
|
|
11472
|
+
logger$12.warning('parent_epoch_changed', { epoch });
|
|
11431
11473
|
}
|
|
11432
11474
|
}
|
|
11433
11475
|
if (!this.readyEvent.isSet()) {
|
|
11434
11476
|
this.readyEvent.set();
|
|
11435
11477
|
}
|
|
11436
11478
|
if (this.messageQueue.length > 0) {
|
|
11437
|
-
logger$
|
|
11479
|
+
logger$12.debug('flushing_buffered_frames', {
|
|
11438
11480
|
queue_size: this.messageQueue.length,
|
|
11439
11481
|
});
|
|
11440
11482
|
this.queueEvent.set();
|
|
@@ -11451,12 +11493,12 @@ class UpstreamSessionManager extends TaskSpawner {
|
|
|
11451
11493
|
name: `expiry-guard-${this.connectEpoch}`,
|
|
11452
11494
|
});
|
|
11453
11495
|
if (this.hadSuccessfulAttach) {
|
|
11454
|
-
logger$
|
|
11496
|
+
logger$12.debug('reconnected_to_upstream', {
|
|
11455
11497
|
attach_expires_at: attachInfo.attachExpiresAt?.toISOString?.() ?? null,
|
|
11456
11498
|
});
|
|
11457
11499
|
}
|
|
11458
11500
|
else {
|
|
11459
|
-
logger$
|
|
11501
|
+
logger$12.debug('connected_to_upstream', {
|
|
11460
11502
|
attach_expires_at: attachInfo.attachExpiresAt?.toISOString?.() ?? null,
|
|
11461
11503
|
});
|
|
11462
11504
|
}
|
|
@@ -11474,18 +11516,18 @@ class UpstreamSessionManager extends TaskSpawner {
|
|
|
11474
11516
|
this.currentStopSubtasks = null;
|
|
11475
11517
|
await Promise.allSettled(tasks.map((task) => task.promise));
|
|
11476
11518
|
if (this.connector) {
|
|
11477
|
-
logger$
|
|
11519
|
+
logger$12.debug('upstream_stopping_old_connector', {
|
|
11478
11520
|
connect_epoch: this.connectEpoch,
|
|
11479
11521
|
target_system_id: this.targetSystemId,
|
|
11480
11522
|
timestamp: new Date().toISOString(),
|
|
11481
11523
|
});
|
|
11482
11524
|
await this.connector.stop().catch((err) => {
|
|
11483
|
-
logger$
|
|
11525
|
+
logger$12.warning('upstream_connector_stop_error', {
|
|
11484
11526
|
connect_epoch: this.connectEpoch,
|
|
11485
11527
|
error: err instanceof Error ? err.message : String(err),
|
|
11486
11528
|
});
|
|
11487
11529
|
});
|
|
11488
|
-
logger$
|
|
11530
|
+
logger$12.debug('upstream_old_connector_stopped', {
|
|
11489
11531
|
connect_epoch: this.connectEpoch,
|
|
11490
11532
|
target_system_id: this.targetSystemId,
|
|
11491
11533
|
timestamp: new Date().toISOString(),
|
|
@@ -11538,7 +11580,7 @@ class UpstreamSessionManager extends TaskSpawner {
|
|
|
11538
11580
|
});
|
|
11539
11581
|
}
|
|
11540
11582
|
catch (error) {
|
|
11541
|
-
logger$
|
|
11583
|
+
logger$12.debug('broadcast_callback_grant_generation_failed', {
|
|
11542
11584
|
error: error instanceof Error ? error.message : String(error),
|
|
11543
11585
|
});
|
|
11544
11586
|
return null;
|
|
@@ -11593,7 +11635,7 @@ class UpstreamSessionManager extends TaskSpawner {
|
|
|
11593
11635
|
}
|
|
11594
11636
|
}
|
|
11595
11637
|
async heartbeatLoop(connector, stopEvt, signal) {
|
|
11596
|
-
logger$
|
|
11638
|
+
logger$12.debug('starting_heartbeat_loop');
|
|
11597
11639
|
const intervalMs = UpstreamSessionManager.HEARTBEAT_INTERVAL * 1000;
|
|
11598
11640
|
const graceMs = intervalMs * UpstreamSessionManager.HEARTBEAT_GRACE;
|
|
11599
11641
|
this.lastHeartbeatAckTime = Date.now();
|
|
@@ -11629,7 +11671,7 @@ class UpstreamSessionManager extends TaskSpawner {
|
|
|
11629
11671
|
// Skip heartbeat if connector is paused (e.g., tab is hidden)
|
|
11630
11672
|
// Keep ack time current so we don't timeout immediately after resuming
|
|
11631
11673
|
if (currentState === core.ConnectorState.PAUSED) {
|
|
11632
|
-
logger$
|
|
11674
|
+
logger$12.debug('skipping_heartbeat_connector_paused', {
|
|
11633
11675
|
connector_state: currentState,
|
|
11634
11676
|
});
|
|
11635
11677
|
this.lastHeartbeatAckTime = Date.now();
|
|
@@ -11638,14 +11680,14 @@ class UpstreamSessionManager extends TaskSpawner {
|
|
|
11638
11680
|
// Reset ack time if just resumed from pause (prevents immediate timeout)
|
|
11639
11681
|
if (previousState === core.ConnectorState.PAUSED &&
|
|
11640
11682
|
currentState === core.ConnectorState.STARTED) {
|
|
11641
|
-
logger$
|
|
11683
|
+
logger$12.debug('connector_just_resumed_resetting_ack_time', {
|
|
11642
11684
|
previous_state: previousState,
|
|
11643
11685
|
current_state: currentState,
|
|
11644
11686
|
});
|
|
11645
11687
|
this.lastHeartbeatAckTime = Date.now();
|
|
11646
11688
|
}
|
|
11647
11689
|
const envelope = await this.makeHeartbeatEnvelope();
|
|
11648
|
-
logger$
|
|
11690
|
+
logger$12.debug('sending_heartbeat', {
|
|
11649
11691
|
hb_corr_id: envelope.corrId,
|
|
11650
11692
|
hb_env_id: envelope.id,
|
|
11651
11693
|
});
|
|
@@ -11671,7 +11713,7 @@ class UpstreamSessionManager extends TaskSpawner {
|
|
|
11671
11713
|
throw new FameConnectError('missed heartbeat acknowledgement');
|
|
11672
11714
|
}
|
|
11673
11715
|
}
|
|
11674
|
-
logger$
|
|
11716
|
+
logger$12.debug('completed_heartbeat_loop');
|
|
11675
11717
|
}
|
|
11676
11718
|
async messagePumpLoop(connector, stopEvt, signal) {
|
|
11677
11719
|
while (!stopEvt.isSet() && !signal?.aborted) {
|
|
@@ -11688,19 +11730,19 @@ class UpstreamSessionManager extends TaskSpawner {
|
|
|
11688
11730
|
if (!envelope) {
|
|
11689
11731
|
continue;
|
|
11690
11732
|
}
|
|
11691
|
-
logger$
|
|
11733
|
+
logger$12.debug('upstream_pump_sending_envelope', {
|
|
11692
11734
|
envelopeId: envelope.id,
|
|
11693
11735
|
type: envelope.frame?.type,
|
|
11694
11736
|
});
|
|
11695
11737
|
try {
|
|
11696
11738
|
await connector.send(envelope);
|
|
11697
|
-
logger$
|
|
11739
|
+
logger$12.debug('upstream_pump_sent_envelope', {
|
|
11698
11740
|
envelopeId: envelope.id,
|
|
11699
11741
|
});
|
|
11700
11742
|
}
|
|
11701
11743
|
catch (error) {
|
|
11702
11744
|
if (error instanceof FameMessageTooLarge) {
|
|
11703
|
-
logger$
|
|
11745
|
+
logger$12.error('failed_to_send_message', { error: error.message });
|
|
11704
11746
|
await this.handleMessageTooLarge(envelope, error.message);
|
|
11705
11747
|
}
|
|
11706
11748
|
else if (error instanceof FameTransportClose) {
|
|
@@ -11762,7 +11804,7 @@ class UpstreamSessionManager extends TaskSpawner {
|
|
|
11762
11804
|
await fabric.send(ackEnvelope);
|
|
11763
11805
|
}
|
|
11764
11806
|
catch (error) {
|
|
11765
|
-
logger$
|
|
11807
|
+
logger$12.warning('failed_to_send_nack', {
|
|
11766
11808
|
error: error.message,
|
|
11767
11809
|
});
|
|
11768
11810
|
}
|
|
@@ -11776,7 +11818,7 @@ class UpstreamSessionManager extends TaskSpawner {
|
|
|
11776
11818
|
timestamps.push(info.attachExpiresAt);
|
|
11777
11819
|
}
|
|
11778
11820
|
if (!timestamps.length) {
|
|
11779
|
-
logger$
|
|
11821
|
+
logger$12.debug('no_ttl_expiry_configured');
|
|
11780
11822
|
await this.waitEvent(stopEvt, signal);
|
|
11781
11823
|
return;
|
|
11782
11824
|
}
|
|
@@ -11785,7 +11827,7 @@ class UpstreamSessionManager extends TaskSpawner {
|
|
|
11785
11827
|
let delaySeconds = (earliest.getTime() - now.getTime()) / 1000 -
|
|
11786
11828
|
UpstreamSessionManager.JWT_REFRESH_SAFETY;
|
|
11787
11829
|
delaySeconds = Math.max(delaySeconds, UpstreamSessionManager.JWT_REFRESH_SAFETY);
|
|
11788
|
-
logger$
|
|
11830
|
+
logger$12.debug('ttl_expiry_guard_started', {
|
|
11789
11831
|
welcome_expires_at: welcome.frame.expiresAt ?? null,
|
|
11790
11832
|
attach_expires_at: info.attachExpiresAt?.toISOString?.() ?? null,
|
|
11791
11833
|
earliest_expiry: earliest.toISOString(),
|
|
@@ -11813,7 +11855,7 @@ class UpstreamSessionManager extends TaskSpawner {
|
|
|
11813
11855
|
}
|
|
11814
11856
|
}
|
|
11815
11857
|
if (!stopEvt.isSet()) {
|
|
11816
|
-
logger$
|
|
11858
|
+
logger$12.debug('ttl_expiry_triggered_reconnect', {
|
|
11817
11859
|
expires_at: earliest.toISOString(),
|
|
11818
11860
|
current_time: new Date().toISOString(),
|
|
11819
11861
|
seconds_before_expiry: UpstreamSessionManager.JWT_REFRESH_SAFETY,
|
|
@@ -11858,7 +11900,7 @@ class UpstreamSessionManager extends TaskSpawner {
|
|
|
11858
11900
|
}
|
|
11859
11901
|
await this.node.dispatchEnvelopeEvent('onEnvelopeReceived', this.node, env, context);
|
|
11860
11902
|
if (env.frame.type === 'NodeHeartbeatAck') {
|
|
11861
|
-
logger$
|
|
11903
|
+
logger$12.debug('received_heartbeat_ack', {
|
|
11862
11904
|
hb_ack_env_id: env.id,
|
|
11863
11905
|
hb_ack_corr_id: env.corrId,
|
|
11864
11906
|
hb_routing_epoch: env.frame.routingEpoch,
|
|
@@ -11872,7 +11914,7 @@ class UpstreamSessionManager extends TaskSpawner {
|
|
|
11872
11914
|
await this.onEpochChange(epoch);
|
|
11873
11915
|
}
|
|
11874
11916
|
else {
|
|
11875
|
-
logger$
|
|
11917
|
+
logger$12.warning('parent_epoch_changed', { epoch });
|
|
11876
11918
|
}
|
|
11877
11919
|
}
|
|
11878
11920
|
return;
|
|
@@ -11891,7 +11933,7 @@ UpstreamSessionManager.TX_QUEUE_MAX = 512;
|
|
|
11891
11933
|
UpstreamSessionManager.BACKOFF_INITIAL = 1; // seconds
|
|
11892
11934
|
UpstreamSessionManager.BACKOFF_CAP = 30; // seconds
|
|
11893
11935
|
|
|
11894
|
-
const logger$
|
|
11936
|
+
const logger$11 = getLogger('naylence.fame.node.admission.noop_admission_client');
|
|
11895
11937
|
class NoopAdmissionClient {
|
|
11896
11938
|
constructor(options = {}) {
|
|
11897
11939
|
this.hasUpstream = false;
|
|
@@ -11905,7 +11947,7 @@ class NoopAdmissionClient {
|
|
|
11905
11947
|
const acceptedLogicals = this.autoAcceptLogicals
|
|
11906
11948
|
? [...(requestedLogicals ?? [])]
|
|
11907
11949
|
: [];
|
|
11908
|
-
logger$
|
|
11950
|
+
logger$11.debug('noop_admission_hello', {
|
|
11909
11951
|
systemId: effectiveSystemId,
|
|
11910
11952
|
instanceId,
|
|
11911
11953
|
requestedLogicals,
|
|
@@ -11923,7 +11965,7 @@ class NoopAdmissionClient {
|
|
|
11923
11965
|
});
|
|
11924
11966
|
}
|
|
11925
11967
|
async close() {
|
|
11926
|
-
logger$
|
|
11968
|
+
logger$11.debug('noop_admission_close');
|
|
11927
11969
|
}
|
|
11928
11970
|
}
|
|
11929
11971
|
|
|
@@ -12129,7 +12171,7 @@ class DefaultServiceManager {
|
|
|
12129
12171
|
}
|
|
12130
12172
|
|
|
12131
12173
|
const SYSTEM_INBOX$1 = '__sys__';
|
|
12132
|
-
const logger
|
|
12174
|
+
const logger$10 = getLogger('naylence.fame.node.node');
|
|
12133
12175
|
function isSnakeCase(name) {
|
|
12134
12176
|
return name.includes('_');
|
|
12135
12177
|
}
|
|
@@ -12256,6 +12298,8 @@ class FameNode extends TaskSpawner {
|
|
|
12256
12298
|
this._acceptedLogicals = new Set(acceptedLogicalsOption);
|
|
12257
12299
|
const deliveryPolicyOption = resolveOption(options, 'deliveryPolicy', 'delivery_policy');
|
|
12258
12300
|
this._deliveryPolicy = deliveryPolicyOption ?? null;
|
|
12301
|
+
const connectionRetryPolicyOption = resolveOption(options, 'connectionRetryPolicy', 'connection_retry_policy');
|
|
12302
|
+
this._connectionRetryPolicy = connectionRetryPolicyOption ?? null;
|
|
12259
12303
|
const admissionClientOption = resolveOption(options, 'admissionClient', 'admission_client');
|
|
12260
12304
|
this._admissionClient = admissionClientOption ?? null;
|
|
12261
12305
|
const attachClientOption = resolveOption(options, 'attachClient', 'attach_client');
|
|
@@ -12385,6 +12429,7 @@ class FameNode extends TaskSpawner {
|
|
|
12385
12429
|
onAttach: (info, connector) => this.handleAttach(info, connector),
|
|
12386
12430
|
onEpochChange: (epoch) => this.handleEpochChange(epoch),
|
|
12387
12431
|
admissionClient: this._admissionClient,
|
|
12432
|
+
retryPolicy: this._connectionRetryPolicy,
|
|
12388
12433
|
});
|
|
12389
12434
|
this._sessionManager = manager;
|
|
12390
12435
|
await manager.start();
|
|
@@ -12396,7 +12441,7 @@ class FameNode extends TaskSpawner {
|
|
|
12396
12441
|
confirmIdentity(systemId, source) {
|
|
12397
12442
|
if (this._confirmedId) {
|
|
12398
12443
|
if (this._confirmedId !== systemId) {
|
|
12399
|
-
logger
|
|
12444
|
+
logger$10.error('node_identity_mismatch', {
|
|
12400
12445
|
current_id: this._confirmedId,
|
|
12401
12446
|
new_id: systemId,
|
|
12402
12447
|
source,
|
|
@@ -12408,14 +12453,14 @@ class FameNode extends TaskSpawner {
|
|
|
12408
12453
|
const isReassignment = this._provisionalId !== systemId;
|
|
12409
12454
|
this._confirmedId = systemId;
|
|
12410
12455
|
if (isReassignment) {
|
|
12411
|
-
logger
|
|
12456
|
+
logger$10.debug('node_identity_reassigned', {
|
|
12412
12457
|
system_id: systemId,
|
|
12413
12458
|
previous_id: this._provisionalId,
|
|
12414
12459
|
source,
|
|
12415
12460
|
});
|
|
12416
12461
|
}
|
|
12417
12462
|
else {
|
|
12418
|
-
logger
|
|
12463
|
+
logger$10.debug('node_identity_confirmed', {
|
|
12419
12464
|
system_id: systemId,
|
|
12420
12465
|
source,
|
|
12421
12466
|
});
|
|
@@ -12483,7 +12528,7 @@ class FameNode extends TaskSpawner {
|
|
|
12483
12528
|
return;
|
|
12484
12529
|
}
|
|
12485
12530
|
if (frameType === 'NodeHeartbeat') {
|
|
12486
|
-
logger
|
|
12531
|
+
logger$10.debug('received_heartbeat_frame', {
|
|
12487
12532
|
envelopeId: envelope.id,
|
|
12488
12533
|
corrId: envelope.corrId ?? null,
|
|
12489
12534
|
});
|
|
@@ -12495,7 +12540,7 @@ class FameNode extends TaskSpawner {
|
|
|
12495
12540
|
await this.handleDeliveryAck(envelope, context);
|
|
12496
12541
|
return;
|
|
12497
12542
|
}
|
|
12498
|
-
logger
|
|
12543
|
+
logger$10.debug('unhandled_system_frame', {
|
|
12499
12544
|
envelopeId: envelope.id,
|
|
12500
12545
|
frameType,
|
|
12501
12546
|
});
|
|
@@ -12507,13 +12552,13 @@ class FameNode extends TaskSpawner {
|
|
|
12507
12552
|
}
|
|
12508
12553
|
await this._deliveryTracker.onEnvelopeDelivered(SYSTEM_INBOX$1, envelope, context);
|
|
12509
12554
|
if (frame.ok !== false) {
|
|
12510
|
-
logger
|
|
12555
|
+
logger$10.debug('delivery_ack_received', {
|
|
12511
12556
|
envelopeId: envelope.id,
|
|
12512
12557
|
corrId: envelope.corrId ?? null,
|
|
12513
12558
|
});
|
|
12514
12559
|
return;
|
|
12515
12560
|
}
|
|
12516
|
-
logger
|
|
12561
|
+
logger$10.warning('delivery_nack_received', {
|
|
12517
12562
|
envelopeId: envelope.id,
|
|
12518
12563
|
corrId: envelope.corrId ?? null,
|
|
12519
12564
|
code: frame.code ?? null,
|
|
@@ -12523,7 +12568,7 @@ class FameNode extends TaskSpawner {
|
|
|
12523
12568
|
await this.onDeliveryNack(frame, envelope, context);
|
|
12524
12569
|
}
|
|
12525
12570
|
async onDeliveryNack(frame, envelope, _context) {
|
|
12526
|
-
logger
|
|
12571
|
+
logger$10.debug('delivery_nack_processed', {
|
|
12527
12572
|
envelopeId: envelope.id,
|
|
12528
12573
|
code: frame.code ?? null,
|
|
12529
12574
|
reason: frame.reason ?? null,
|
|
@@ -12638,7 +12683,7 @@ class FameNode extends TaskSpawner {
|
|
|
12638
12683
|
await this._bindingManager.restore();
|
|
12639
12684
|
await this._envelopeListenerManager.start();
|
|
12640
12685
|
this._isStarted = true;
|
|
12641
|
-
logger
|
|
12686
|
+
logger$10.debug('node_started', {
|
|
12642
12687
|
node_id: this.id,
|
|
12643
12688
|
sid: this.sid,
|
|
12644
12689
|
path: this.physicalPath,
|
|
@@ -12670,7 +12715,7 @@ class FameNode extends TaskSpawner {
|
|
|
12670
12715
|
await this._serviceManager.stop();
|
|
12671
12716
|
await this.dispatchEvent('onNodeStopped', this);
|
|
12672
12717
|
this._isStarted = false;
|
|
12673
|
-
logger
|
|
12718
|
+
logger$10.debug('node_stopped', {
|
|
12674
12719
|
node_id: this.id,
|
|
12675
12720
|
});
|
|
12676
12721
|
}
|
|
@@ -12860,20 +12905,20 @@ class FameNode extends TaskSpawner {
|
|
|
12860
12905
|
await this.forwardUpstream(processedEnvelope, context);
|
|
12861
12906
|
}
|
|
12862
12907
|
else {
|
|
12863
|
-
logger
|
|
12908
|
+
logger$10.error('attempted_upstream_loop', {
|
|
12864
12909
|
envelopeId: processedEnvelope.id,
|
|
12865
12910
|
});
|
|
12866
12911
|
}
|
|
12867
12912
|
return;
|
|
12868
12913
|
}
|
|
12869
12914
|
if (!processedEnvelope.to) {
|
|
12870
|
-
logger
|
|
12915
|
+
logger$10.error('dropping_envelope_without_destination', {
|
|
12871
12916
|
envelopeId: processedEnvelope.id,
|
|
12872
12917
|
capabilities: processedEnvelope.capabilities ?? [],
|
|
12873
12918
|
});
|
|
12874
12919
|
return;
|
|
12875
12920
|
}
|
|
12876
|
-
logger
|
|
12921
|
+
logger$10.warning('no_local_handler_for_address', {
|
|
12877
12922
|
address: processedEnvelope.to.toString?.() ?? String(processedEnvelope.to),
|
|
12878
12923
|
originType: context?.originType ?? null,
|
|
12879
12924
|
});
|
|
@@ -12997,7 +13042,7 @@ class FameNode extends TaskSpawner {
|
|
|
12997
13042
|
}
|
|
12998
13043
|
}
|
|
12999
13044
|
catch (error) {
|
|
13000
|
-
logger
|
|
13045
|
+
logger$10.warning('callback_grant_collection_failed', {
|
|
13001
13046
|
error: error instanceof Error ? error.message : String(error),
|
|
13002
13047
|
});
|
|
13003
13048
|
}
|
|
@@ -13060,7 +13105,7 @@ class FameNode extends TaskSpawner {
|
|
|
13060
13105
|
await store.set('self', record);
|
|
13061
13106
|
}
|
|
13062
13107
|
catch (error) {
|
|
13063
|
-
logger
|
|
13108
|
+
logger$10.warning('node_meta_persist_failed', {
|
|
13064
13109
|
error: error instanceof Error ? error.message : String(error),
|
|
13065
13110
|
});
|
|
13066
13111
|
}
|
|
@@ -13091,6 +13136,7 @@ const FameNodeConfigSchemaInternal = zod.z
|
|
|
13091
13136
|
telemetry: zod.z.unknown().optional().nullable(),
|
|
13092
13137
|
requestedCapabilities: zod.z.array(zod.z.string()).optional(),
|
|
13093
13138
|
identityPolicy: zod.z.unknown().optional().nullable(),
|
|
13139
|
+
connectionRetryPolicy: zod.z.unknown().optional().nullable(),
|
|
13094
13140
|
})
|
|
13095
13141
|
.passthrough();
|
|
13096
13142
|
function normalizeFameNodeConfig(input) {
|
|
@@ -13132,6 +13178,9 @@ function normalizeFameNodeConfig(input) {
|
|
|
13132
13178
|
identityPolicy: parsed.identityPolicy === undefined
|
|
13133
13179
|
? null
|
|
13134
13180
|
: parsed.identityPolicy,
|
|
13181
|
+
connectionRetryPolicy: parsed.connectionRetryPolicy === undefined
|
|
13182
|
+
? null
|
|
13183
|
+
: parsed.connectionRetryPolicy,
|
|
13135
13184
|
};
|
|
13136
13185
|
if (parsed.requestedCapabilities) {
|
|
13137
13186
|
normalized.requestedCapabilities = coerceStringArray$1(parsed.requestedCapabilities);
|
|
@@ -13176,6 +13225,24 @@ class AdmissionClientFactory extends factory.AbstractResourceFactory {
|
|
|
13176
13225
|
}
|
|
13177
13226
|
}
|
|
13178
13227
|
|
|
13228
|
+
const CONNECTION_RETRY_POLICY_FACTORY_BASE_TYPE = 'ConnectionRetryPolicyFactory';
|
|
13229
|
+
class ConnectionRetryPolicyFactory extends factory.AbstractResourceFactory {
|
|
13230
|
+
static async createConnectionRetryPolicy(config, options = {}) {
|
|
13231
|
+
if (config) {
|
|
13232
|
+
const policy = await factory.createResource(CONNECTION_RETRY_POLICY_FACTORY_BASE_TYPE, config, options);
|
|
13233
|
+
if (!policy) {
|
|
13234
|
+
throw new Error('Failed to create connection retry policy from configuration');
|
|
13235
|
+
}
|
|
13236
|
+
return policy;
|
|
13237
|
+
}
|
|
13238
|
+
const policy = await factory.createDefaultResource(CONNECTION_RETRY_POLICY_FACTORY_BASE_TYPE, null, options);
|
|
13239
|
+
if (!policy) {
|
|
13240
|
+
throw new Error('Failed to create default connection retry policy');
|
|
13241
|
+
}
|
|
13242
|
+
return policy;
|
|
13243
|
+
}
|
|
13244
|
+
}
|
|
13245
|
+
|
|
13179
13246
|
const TOKEN_PROVIDER_FACTORY_BASE_TYPE = 'TokenProviderFactory';
|
|
13180
13247
|
class TokenProviderFactory extends factory.AbstractResourceFactory {
|
|
13181
13248
|
static async createTokenProvider(config, options = {}) {
|
|
@@ -13213,7 +13280,7 @@ function isIdentityExposingTokenProvider(candidate) {
|
|
|
13213
13280
|
'function');
|
|
13214
13281
|
}
|
|
13215
13282
|
|
|
13216
|
-
const logger
|
|
13283
|
+
const logger$$ = getLogger('naylence.fame.node.default_node_identity_policy');
|
|
13217
13284
|
class DefaultNodeIdentityPolicy {
|
|
13218
13285
|
async resolveInitialNodeId(context) {
|
|
13219
13286
|
if (context.configuredId) {
|
|
@@ -13243,7 +13310,7 @@ class DefaultNodeIdentityPolicy {
|
|
|
13243
13310
|
if (isIdentityExposingTokenProvider(provider)) {
|
|
13244
13311
|
const identity = await provider.getIdentity();
|
|
13245
13312
|
if (identity && identity.subject) {
|
|
13246
|
-
logger
|
|
13313
|
+
logger$$.debug('identity_extracted_from_grant', {
|
|
13247
13314
|
identity_id: identity.subject,
|
|
13248
13315
|
grant_type: grant.type,
|
|
13249
13316
|
});
|
|
@@ -13252,7 +13319,7 @@ class DefaultNodeIdentityPolicy {
|
|
|
13252
13319
|
}
|
|
13253
13320
|
}
|
|
13254
13321
|
catch (error) {
|
|
13255
|
-
logger
|
|
13322
|
+
logger$$.warning('identity_extraction_failed', {
|
|
13256
13323
|
error: error instanceof Error ? error.message : String(error),
|
|
13257
13324
|
grant_type: grant.type,
|
|
13258
13325
|
});
|
|
@@ -13336,7 +13403,7 @@ class AttachmentKeyValidator {
|
|
|
13336
13403
|
}
|
|
13337
13404
|
}
|
|
13338
13405
|
|
|
13339
|
-
const logger$
|
|
13406
|
+
const logger$_ = getLogger('naylence.fame.node.admission.default_node_attach_client');
|
|
13340
13407
|
const HANDSHAKE_POLL_INTERVAL_MS = 20;
|
|
13341
13408
|
class DefaultNodeAttachClient {
|
|
13342
13409
|
constructor(options = {}) {
|
|
@@ -13360,7 +13427,7 @@ class DefaultNodeAttachClient {
|
|
|
13360
13427
|
}
|
|
13361
13428
|
else {
|
|
13362
13429
|
// Silently ignore frames from other agents during concurrent handshakes
|
|
13363
|
-
logger$
|
|
13430
|
+
logger$_.debug('handshake_ignoring_frame_from_different_system', {
|
|
13364
13431
|
frame_type: envelope.frame.type,
|
|
13365
13432
|
frame_system_id: frameSystemId,
|
|
13366
13433
|
expected_system_id: this.expectedSystemId,
|
|
@@ -13403,7 +13470,7 @@ class DefaultNodeAttachClient {
|
|
|
13403
13470
|
}
|
|
13404
13471
|
}
|
|
13405
13472
|
catch (error) {
|
|
13406
|
-
logger$
|
|
13473
|
+
logger$_.debug('stickiness_offer_skipped', {
|
|
13407
13474
|
error: error instanceof Error ? error.message : String(error),
|
|
13408
13475
|
});
|
|
13409
13476
|
}
|
|
@@ -13424,7 +13491,7 @@ class DefaultNodeAttachClient {
|
|
|
13424
13491
|
if (!processedEnvelope) {
|
|
13425
13492
|
throw new Error('Envelope was blocked by onForwardUpstream event');
|
|
13426
13493
|
}
|
|
13427
|
-
logger$
|
|
13494
|
+
logger$_.debug('sending_node_attach_envelope', {
|
|
13428
13495
|
envp_id: processedEnvelope.id ?? envelope.id ?? null,
|
|
13429
13496
|
frame_type: processedEnvelope.frame?.type ?? 'unknown',
|
|
13430
13497
|
trace_id: processedEnvelope.traceId ?? envelope.traceId ?? null,
|
|
@@ -13460,7 +13527,7 @@ class DefaultNodeAttachClient {
|
|
|
13460
13527
|
try {
|
|
13461
13528
|
const keyInfos = await this.attachmentKeyValidator.validateKeys(parentKeys);
|
|
13462
13529
|
if (Array.isArray(keyInfos) && keyInfos.length > 0) {
|
|
13463
|
-
logger$
|
|
13530
|
+
logger$_.debug('parent_certificate_validation_passed', {
|
|
13464
13531
|
parent_id: parentId,
|
|
13465
13532
|
correlation_id: corrId,
|
|
13466
13533
|
validated_keys: keyInfos.length,
|
|
@@ -13469,7 +13536,7 @@ class DefaultNodeAttachClient {
|
|
|
13469
13536
|
}
|
|
13470
13537
|
catch (error) {
|
|
13471
13538
|
if (error instanceof KeyValidationError) {
|
|
13472
|
-
logger$
|
|
13539
|
+
logger$_.error('parent_certificate_validation_failed', {
|
|
13473
13540
|
parent_id: parentId,
|
|
13474
13541
|
correlation_id: corrId,
|
|
13475
13542
|
error_code: error.code,
|
|
@@ -13483,12 +13550,12 @@ class DefaultNodeAttachClient {
|
|
|
13483
13550
|
}
|
|
13484
13551
|
}
|
|
13485
13552
|
else {
|
|
13486
|
-
logger$
|
|
13553
|
+
logger$_.debug('parent_certificate_validation_skipped', {
|
|
13487
13554
|
parent_id: parentId,
|
|
13488
13555
|
reason: 'no_validator',
|
|
13489
13556
|
});
|
|
13490
13557
|
}
|
|
13491
|
-
logger$
|
|
13558
|
+
logger$_.debug('processing_node_attach_ack', {
|
|
13492
13559
|
parent_id: ackFrame.targetSystemId,
|
|
13493
13560
|
});
|
|
13494
13561
|
this.inHandshake = false;
|
|
@@ -13519,7 +13586,7 @@ class DefaultNodeAttachClient {
|
|
|
13519
13586
|
}
|
|
13520
13587
|
}
|
|
13521
13588
|
catch (error) {
|
|
13522
|
-
logger$
|
|
13589
|
+
logger$_.debug('stickiness_accept_skipped', {
|
|
13523
13590
|
error: error instanceof Error ? error.message : String(error),
|
|
13524
13591
|
});
|
|
13525
13592
|
}
|
|
@@ -13573,7 +13640,7 @@ class DefaultNodeAttachClient {
|
|
|
13573
13640
|
// NodeAttach frames during handshake are expected in multi-agent scenarios
|
|
13574
13641
|
// where multiple agents attach concurrently to the same channel
|
|
13575
13642
|
if (envelope.frame.type === 'NodeAttach') {
|
|
13576
|
-
logger$
|
|
13643
|
+
logger$_.debug('handshake_ignoring_concurrent_attach', {
|
|
13577
13644
|
frame_type: envelope.frame.type,
|
|
13578
13645
|
frame_system_id: envelope.frame?.systemId ??
|
|
13579
13646
|
'unknown',
|
|
@@ -13581,7 +13648,7 @@ class DefaultNodeAttachClient {
|
|
|
13581
13648
|
}
|
|
13582
13649
|
else {
|
|
13583
13650
|
// Other unexpected frames are still logged as errors
|
|
13584
|
-
logger$
|
|
13651
|
+
logger$_.error('unexpected_frame_during_handshake', {
|
|
13585
13652
|
frame_type: envelope.frame.type,
|
|
13586
13653
|
});
|
|
13587
13654
|
}
|
|
@@ -13716,7 +13783,7 @@ class TraceEmitterFactory extends factory.AbstractResourceFactory {
|
|
|
13716
13783
|
// void import('./trace-emitter-profile-factory.js');
|
|
13717
13784
|
|
|
13718
13785
|
const BINDING_STORE_NAMESPACE = '__binding_store';
|
|
13719
|
-
const logger$
|
|
13786
|
+
const logger$Z = getLogger('naylence.fame.node.factory_commons');
|
|
13720
13787
|
function isPlainRecord$2(value) {
|
|
13721
13788
|
return Boolean(value) && typeof value === 'object' && !Array.isArray(value);
|
|
13722
13789
|
}
|
|
@@ -13823,6 +13890,7 @@ async function makeCommonOptions(config, rawConfig) {
|
|
|
13823
13890
|
const telemetryConfig = pickOption$1(config.telemetry ?? null, aliasRecord, 'trace_emitter', 'telemetry_config');
|
|
13824
13891
|
const securityConfig = pickOption$1(config.security ?? null, aliasRecord, 'security_manager', 'security_profile');
|
|
13825
13892
|
const identityPolicyConfig = pickOption$1(config.identityPolicy ?? null, aliasRecord, 'identity_policy', 'node_identity_policy');
|
|
13893
|
+
const connectionRetryPolicyConfig = pickOption$1(config.connectionRetryPolicy ?? null, aliasRecord, 'connection_retry_policy', 'retry_policy');
|
|
13826
13894
|
const publicUrl = pickString$2(config.publicUrl ?? null, aliasRecord, 'public_url') ?? null;
|
|
13827
13895
|
const directParentUrl = pickString$2(config.directParentUrl ?? null, aliasRecord, 'direct_parent_url') ?? null;
|
|
13828
13896
|
const hasParentFlag = config.hasParent || Boolean(aliasRecord.has_parent ?? false);
|
|
@@ -13832,6 +13900,7 @@ async function makeCommonOptions(config, rawConfig) {
|
|
|
13832
13900
|
const nodeMetaStore = await storageProvider.getKeyValueStore(NodeMetaRecord, NODE_META_NAMESPACE);
|
|
13833
13901
|
const nodeMeta = await nodeMetaStore.get('self');
|
|
13834
13902
|
const identityPolicy = await resolveNodeIdentityPolicy(identityPolicyConfig ?? null, expressionOptions);
|
|
13903
|
+
const connectionRetryPolicy = await resolveConnectionRetryPolicy(connectionRetryPolicyConfig ?? null, expressionOptions);
|
|
13835
13904
|
const admissionClient = await resolveAdmissionClient(admissionConfig ?? null, expressionOptions, identityPolicy ?? undefined);
|
|
13836
13905
|
const hasParent = determineHasParent(hasParentFlag, directParentUrl, admissionClient);
|
|
13837
13906
|
const replicaStickinessManager = await resolveReplicaStickinessManager(hasParent, requestedLogicals, expressionOptions);
|
|
@@ -13900,6 +13969,7 @@ async function makeCommonOptions(config, rawConfig) {
|
|
|
13900
13969
|
transportListeners,
|
|
13901
13970
|
traceEmitter,
|
|
13902
13971
|
identityPolicy: identityPolicy ?? undefined,
|
|
13972
|
+
connectionRetryPolicy: connectionRetryPolicy ?? undefined,
|
|
13903
13973
|
};
|
|
13904
13974
|
}
|
|
13905
13975
|
async function resolveNodeIdentityPolicy(config, options) {
|
|
@@ -13907,7 +13977,18 @@ async function resolveNodeIdentityPolicy(config, options) {
|
|
|
13907
13977
|
return await NodeIdentityPolicyFactory.createNodeIdentityPolicy(config ?? undefined, cloneCreateOptions(options));
|
|
13908
13978
|
}
|
|
13909
13979
|
catch (error) {
|
|
13910
|
-
logger$
|
|
13980
|
+
logger$Z.warning('node_identity_policy_creation_failed', {
|
|
13981
|
+
error: error instanceof Error ? error.message : String(error),
|
|
13982
|
+
});
|
|
13983
|
+
return null;
|
|
13984
|
+
}
|
|
13985
|
+
}
|
|
13986
|
+
async function resolveConnectionRetryPolicy(config, options) {
|
|
13987
|
+
try {
|
|
13988
|
+
return await ConnectionRetryPolicyFactory.createConnectionRetryPolicy(config ?? undefined, cloneCreateOptions(options));
|
|
13989
|
+
}
|
|
13990
|
+
catch (error) {
|
|
13991
|
+
logger$Z.warning('connection_retry_policy_creation_failed', {
|
|
13911
13992
|
error: error instanceof Error ? error.message : String(error),
|
|
13912
13993
|
});
|
|
13913
13994
|
return null;
|
|
@@ -13919,7 +14000,7 @@ async function resolveStorageProvider(config, options) {
|
|
|
13919
14000
|
return await StorageProviderFactory.createStorageProvider(config, cloneCreateOptions(options));
|
|
13920
14001
|
}
|
|
13921
14002
|
catch (error) {
|
|
13922
|
-
logger$
|
|
14003
|
+
logger$Z.warning('storage_provider_creation_failed', {
|
|
13923
14004
|
error: error instanceof Error ? error.message : String(error),
|
|
13924
14005
|
});
|
|
13925
14006
|
}
|
|
@@ -13941,7 +14022,7 @@ async function resolveAdmissionClient(config, options, identityPolicy) {
|
|
|
13941
14022
|
return await AdmissionClientFactory.createAdmissionClient((config ?? null), createOptions);
|
|
13942
14023
|
}
|
|
13943
14024
|
catch (error) {
|
|
13944
|
-
logger$
|
|
14025
|
+
logger$Z.warning('admission_client_creation_failed', {
|
|
13945
14026
|
error: error instanceof Error ? error.message : String(error),
|
|
13946
14027
|
});
|
|
13947
14028
|
return null;
|
|
@@ -13968,7 +14049,7 @@ async function resolveReplicaStickinessManager(hasParent, requestedLogicals, opt
|
|
|
13968
14049
|
return await ReplicaStickinessManagerFactory.createReplicaStickinessManager(undefined, cloneCreateOptions(options));
|
|
13969
14050
|
}
|
|
13970
14051
|
catch (error) {
|
|
13971
|
-
logger$
|
|
14052
|
+
logger$Z.debug('replica_stickiness_manager_unavailable', { error });
|
|
13972
14053
|
return null;
|
|
13973
14054
|
}
|
|
13974
14055
|
}
|
|
@@ -13977,7 +14058,7 @@ async function resolveAttachmentKeyValidator(config, options) {
|
|
|
13977
14058
|
return await AttachmentKeyValidatorFactory.createAttachmentKeyValidator(config ?? undefined, cloneCreateOptions(options));
|
|
13978
14059
|
}
|
|
13979
14060
|
catch (error) {
|
|
13980
|
-
logger$
|
|
14061
|
+
logger$Z.warning('attachment_key_validator_creation_failed', {
|
|
13981
14062
|
error: error instanceof Error ? error.message : String(error),
|
|
13982
14063
|
});
|
|
13983
14064
|
return null;
|
|
@@ -13995,7 +14076,7 @@ async function resolveDeliveryPolicy(config, options) {
|
|
|
13995
14076
|
return await DeliveryPolicyFactory.createDeliveryPolicy(config ?? undefined, cloneCreateOptions(options));
|
|
13996
14077
|
}
|
|
13997
14078
|
catch (error) {
|
|
13998
|
-
logger$
|
|
14079
|
+
logger$Z.warning('delivery_policy_creation_failed', {
|
|
13999
14080
|
error: error instanceof Error ? error.message : String(error),
|
|
14000
14081
|
});
|
|
14001
14082
|
return null;
|
|
@@ -14009,7 +14090,7 @@ async function resolveTransportListeners(configs, eventListeners, options) {
|
|
|
14009
14090
|
return await TransportListenerFactory.createTransportListeners(configs, eventListeners, cloneCreateOptions(options));
|
|
14010
14091
|
}
|
|
14011
14092
|
catch (error) {
|
|
14012
|
-
logger$
|
|
14093
|
+
logger$Z.warning('transport_listener_creation_failed', {
|
|
14013
14094
|
error: error instanceof Error ? error.message : String(error),
|
|
14014
14095
|
});
|
|
14015
14096
|
return [];
|
|
@@ -14020,7 +14101,7 @@ async function resolveTraceEmitter(config, options) {
|
|
|
14020
14101
|
return await TraceEmitterFactory.createTraceEmitter(config ?? undefined, cloneCreateOptions(options));
|
|
14021
14102
|
}
|
|
14022
14103
|
catch (error) {
|
|
14023
|
-
logger$
|
|
14104
|
+
logger$Z.warning('trace_emitter_creation_failed', {
|
|
14024
14105
|
error: error instanceof Error ? error.message : String(error),
|
|
14025
14106
|
});
|
|
14026
14107
|
return null;
|
|
@@ -14076,7 +14157,7 @@ async function createSecurityManagerFromConfig(config, overrides, options) {
|
|
|
14076
14157
|
return manager ?? null;
|
|
14077
14158
|
}
|
|
14078
14159
|
catch (error) {
|
|
14079
|
-
logger$
|
|
14160
|
+
logger$Z.warning('security_manager_creation_failed', {
|
|
14080
14161
|
error: error instanceof Error ? error.message : String(error),
|
|
14081
14162
|
});
|
|
14082
14163
|
return null;
|
|
@@ -14105,7 +14186,7 @@ async function resolveCryptoProvider(config, options) {
|
|
|
14105
14186
|
// This happens with overlay security profiles that need envelope signing
|
|
14106
14187
|
if (requiresCryptoProvider(config)) {
|
|
14107
14188
|
try {
|
|
14108
|
-
logger$
|
|
14189
|
+
logger$Z.debug('auto_creating_crypto_provider', {
|
|
14109
14190
|
reason: 'overlay_security_requires_signing',
|
|
14110
14191
|
});
|
|
14111
14192
|
// Dynamically import to avoid circular dependencies
|
|
@@ -14125,7 +14206,7 @@ async function resolveCryptoProvider(config, options) {
|
|
|
14125
14206
|
});
|
|
14126
14207
|
}
|
|
14127
14208
|
catch (error) {
|
|
14128
|
-
logger$
|
|
14209
|
+
logger$Z.error('failed_to_auto_create_crypto_provider', {
|
|
14129
14210
|
error: error instanceof Error ? error.message : String(error),
|
|
14130
14211
|
});
|
|
14131
14212
|
throw error;
|
|
@@ -14671,7 +14752,7 @@ class NodeLikeFactory extends factory.AbstractResourceFactory {
|
|
|
14671
14752
|
// registerFactory(NODE_LIKE_FACTORY_BASE_TYPE, type, factory);
|
|
14672
14753
|
// }
|
|
14673
14754
|
|
|
14674
|
-
const FACTORY_META$
|
|
14755
|
+
const FACTORY_META$18 = {
|
|
14675
14756
|
base: NODE_LIKE_FACTORY_BASE_TYPE,
|
|
14676
14757
|
key: 'Node',
|
|
14677
14758
|
};
|
|
@@ -14705,6 +14786,7 @@ class NodeFactory extends NodeLikeFactory {
|
|
|
14705
14786
|
nodeMetaStore: components.nodeMetaStore,
|
|
14706
14787
|
transportListeners: components.transportListeners,
|
|
14707
14788
|
defaultServiceConfigs: serviceConfigs,
|
|
14789
|
+
connectionRetryPolicy: components.connectionRetryPolicy,
|
|
14708
14790
|
});
|
|
14709
14791
|
return node;
|
|
14710
14792
|
}
|
|
@@ -14712,7 +14794,7 @@ class NodeFactory extends NodeLikeFactory {
|
|
|
14712
14794
|
|
|
14713
14795
|
var nodeFactory = /*#__PURE__*/Object.freeze({
|
|
14714
14796
|
__proto__: null,
|
|
14715
|
-
FACTORY_META: FACTORY_META$
|
|
14797
|
+
FACTORY_META: FACTORY_META$18,
|
|
14716
14798
|
NodeFactory: NodeFactory,
|
|
14717
14799
|
default: NodeFactory
|
|
14718
14800
|
});
|
|
@@ -15285,7 +15367,7 @@ function normalizeSecurityRequirements(value) {
|
|
|
15285
15367
|
};
|
|
15286
15368
|
}
|
|
15287
15369
|
|
|
15288
|
-
const logger$
|
|
15370
|
+
const logger$Y = getLogger('naylence.fame.node.envelope_security_handler');
|
|
15289
15371
|
const ENCRYPTION_OPTION_ALIAS_PAIRS = [
|
|
15290
15372
|
['recipKid', 'recip_kid'],
|
|
15291
15373
|
['recipientKeyId', 'recipient_key_id'],
|
|
@@ -15334,7 +15416,7 @@ class EnvelopeSecurityHandler {
|
|
|
15334
15416
|
const shouldSign = this.securityPolicy
|
|
15335
15417
|
? await this.securityPolicy.shouldSignEnvelope(envelope, context, this.node)
|
|
15336
15418
|
: false;
|
|
15337
|
-
logger$
|
|
15419
|
+
logger$Y.debug('checking_signing', {
|
|
15338
15420
|
has_signer: Boolean(this.envelopeSigner),
|
|
15339
15421
|
should_sign: shouldSign,
|
|
15340
15422
|
envp_id: envelope.id,
|
|
@@ -15356,7 +15438,7 @@ class EnvelopeSecurityHandler {
|
|
|
15356
15438
|
const shouldEncrypt = this.securityPolicy
|
|
15357
15439
|
? await this.securityPolicy.shouldEncryptEnvelope(envelope, context, this.node)
|
|
15358
15440
|
: false;
|
|
15359
|
-
logger$
|
|
15441
|
+
logger$Y.debug('checking_encryption', {
|
|
15360
15442
|
has_encryption_manager: Boolean(this.encryptionManager),
|
|
15361
15443
|
should_encrypt: shouldEncrypt,
|
|
15362
15444
|
envp_id: envelope.id,
|
|
@@ -15364,7 +15446,7 @@ class EnvelopeSecurityHandler {
|
|
|
15364
15446
|
});
|
|
15365
15447
|
if (this.encryptionManager && this.securityPolicy) {
|
|
15366
15448
|
if (envelope.sec?.enc) {
|
|
15367
|
-
logger$
|
|
15449
|
+
logger$Y.debug('skipping_encryption_already_encrypted', {
|
|
15368
15450
|
envp_id: envelope.id,
|
|
15369
15451
|
destination: envelope.to ? String(envelope.to) : undefined,
|
|
15370
15452
|
});
|
|
@@ -15377,7 +15459,7 @@ class EnvelopeSecurityHandler {
|
|
|
15377
15459
|
exports.CryptoLevel.PLAINTEXT;
|
|
15378
15460
|
desiredCryptoLevel =
|
|
15379
15461
|
await this.securityPolicy.decideResponseCryptoLevel(requestCryptoLevel, envelope, context);
|
|
15380
|
-
logger$
|
|
15462
|
+
logger$Y.debug('response_crypto_level_decided', {
|
|
15381
15463
|
envp_id: envelope.id,
|
|
15382
15464
|
crypto_level: desiredCryptoLevel,
|
|
15383
15465
|
destination: envelope.to ? String(envelope.to) : undefined,
|
|
@@ -15388,7 +15470,7 @@ class EnvelopeSecurityHandler {
|
|
|
15388
15470
|
else {
|
|
15389
15471
|
desiredCryptoLevel =
|
|
15390
15472
|
await this.securityPolicy.decideOutboundCryptoLevel(envelope, context, this.node);
|
|
15391
|
-
logger$
|
|
15473
|
+
logger$Y.debug('outbound_crypto_level_decided', {
|
|
15392
15474
|
envp_id: envelope.id,
|
|
15393
15475
|
frame_type: envelope.frame.type,
|
|
15394
15476
|
crypto_level: desiredCryptoLevel,
|
|
@@ -15396,11 +15478,11 @@ class EnvelopeSecurityHandler {
|
|
|
15396
15478
|
});
|
|
15397
15479
|
}
|
|
15398
15480
|
if (desiredCryptoLevel === exports.CryptoLevel.SEALED) {
|
|
15399
|
-
logger$
|
|
15481
|
+
logger$Y.debug('applying_sealed_encryption', { envp_id: envelope.id });
|
|
15400
15482
|
return await this.handleSealedEncryption(envelope, context);
|
|
15401
15483
|
}
|
|
15402
15484
|
if (desiredCryptoLevel === exports.CryptoLevel.CHANNEL) {
|
|
15403
|
-
logger$
|
|
15485
|
+
logger$Y.debug('applying_channel_encryption', { envp_id: envelope.id });
|
|
15404
15486
|
return await this.handleChannelEncryption(envelope, context);
|
|
15405
15487
|
}
|
|
15406
15488
|
}
|
|
@@ -15451,7 +15533,7 @@ class EnvelopeSecurityHandler {
|
|
|
15451
15533
|
frameType === 'KeyAnnounce' ||
|
|
15452
15534
|
frameType === 'SecureOpen' ||
|
|
15453
15535
|
frameType === 'SecureAccept') {
|
|
15454
|
-
logger$
|
|
15536
|
+
logger$Y.error('critical_frame_unsigned_rejected', {
|
|
15455
15537
|
envp_id: envelope.id,
|
|
15456
15538
|
frame_type: frameType,
|
|
15457
15539
|
reason: 'critical_frames_must_be_signed',
|
|
@@ -15459,7 +15541,7 @@ class EnvelopeSecurityHandler {
|
|
|
15459
15541
|
return [envelope, false];
|
|
15460
15542
|
}
|
|
15461
15543
|
const action = this.securityPolicy.getUnsignedViolationAction(envelope, context);
|
|
15462
|
-
logger$
|
|
15544
|
+
logger$Y.warning('unsigned_envelope_violation', {
|
|
15463
15545
|
envp_id: envelope.id,
|
|
15464
15546
|
frame_type: frameType,
|
|
15465
15547
|
action,
|
|
@@ -15471,26 +15553,26 @@ class EnvelopeSecurityHandler {
|
|
|
15471
15553
|
return [envelope, true];
|
|
15472
15554
|
}
|
|
15473
15555
|
async handleChannelHandshakeComplete(channelId, destination) {
|
|
15474
|
-
logger$
|
|
15556
|
+
logger$Y.debug('channel_handshake_completed', {
|
|
15475
15557
|
channel_id: channelId,
|
|
15476
15558
|
destination,
|
|
15477
15559
|
});
|
|
15478
15560
|
if (this.encryptionManager?.notifyChannelEstablished) {
|
|
15479
15561
|
await this.encryptionManager.notifyChannelEstablished(channelId);
|
|
15480
|
-
logger$
|
|
15562
|
+
logger$Y.debug('notified_encryption_manager_channel_ready', {
|
|
15481
15563
|
channel_id: channelId,
|
|
15482
15564
|
});
|
|
15483
15565
|
}
|
|
15484
15566
|
}
|
|
15485
15567
|
async handleChannelHandshakeFailed(channelId, destination, reason = 'handshake_failed') {
|
|
15486
|
-
logger$
|
|
15568
|
+
logger$Y.debug('channel_handshake_failed', {
|
|
15487
15569
|
channel_id: channelId,
|
|
15488
15570
|
destination,
|
|
15489
15571
|
reason,
|
|
15490
15572
|
});
|
|
15491
15573
|
if (this.encryptionManager?.notifyChannelFailed) {
|
|
15492
15574
|
await this.encryptionManager.notifyChannelFailed(channelId, reason);
|
|
15493
|
-
logger$
|
|
15575
|
+
logger$Y.debug('notified_encryption_manager_channel_failed', {
|
|
15494
15576
|
channel_id: channelId,
|
|
15495
15577
|
reason,
|
|
15496
15578
|
});
|
|
@@ -15537,7 +15619,7 @@ class EnvelopeSecurityHandler {
|
|
|
15537
15619
|
checkPayload: false,
|
|
15538
15620
|
});
|
|
15539
15621
|
if (verified) {
|
|
15540
|
-
logger$
|
|
15622
|
+
logger$Y.debug('envelope_verified', {
|
|
15541
15623
|
envp_id: envelope.id,
|
|
15542
15624
|
sid: envelope.sid,
|
|
15543
15625
|
kid,
|
|
@@ -15548,7 +15630,7 @@ class EnvelopeSecurityHandler {
|
|
|
15548
15630
|
}
|
|
15549
15631
|
this.keyManagementHandler.queuePendingSignedEnvelope(kid, envelope, context);
|
|
15550
15632
|
await this.keyManagementHandler.maybeRequestSigningKey(kid, context.originType, fromSystemId);
|
|
15551
|
-
logger$
|
|
15633
|
+
logger$Y.debug('queued_envelope_missing_signing_key', {
|
|
15552
15634
|
kid,
|
|
15553
15635
|
envp_id: envelope.id,
|
|
15554
15636
|
});
|
|
@@ -15556,7 +15638,7 @@ class EnvelopeSecurityHandler {
|
|
|
15556
15638
|
}
|
|
15557
15639
|
async handleSealedEncryption(envelope, context) {
|
|
15558
15640
|
if (!envelope.to) {
|
|
15559
|
-
logger$
|
|
15641
|
+
logger$Y.warning('sealed_encryption_requested_but_no_destination', {
|
|
15560
15642
|
envp_id: envelope.id,
|
|
15561
15643
|
});
|
|
15562
15644
|
return true;
|
|
@@ -15568,20 +15650,20 @@ class EnvelopeSecurityHandler {
|
|
|
15568
15650
|
: undefined;
|
|
15569
15651
|
if (options) {
|
|
15570
15652
|
if (options.encryptionType === 'channel') {
|
|
15571
|
-
logger$
|
|
15653
|
+
logger$Y.warning('policy_returned_channel_for_sealed_request', {
|
|
15572
15654
|
envp_id: envelope.id,
|
|
15573
15655
|
});
|
|
15574
15656
|
return await this.handleToBeEncryptedEnvelopeWithOptions(envelope, context, normalizeEncryptionOptions({
|
|
15575
15657
|
requestAddress: envelope.to,
|
|
15576
15658
|
}));
|
|
15577
15659
|
}
|
|
15578
|
-
logger$
|
|
15660
|
+
logger$Y.debug('using_sealed_encryption_options', {
|
|
15579
15661
|
envp_id: envelope.id,
|
|
15580
15662
|
options,
|
|
15581
15663
|
});
|
|
15582
15664
|
return await this.handleToBeEncryptedEnvelopeWithOptions(envelope, context, options);
|
|
15583
15665
|
}
|
|
15584
|
-
logger$
|
|
15666
|
+
logger$Y.debug('no_encryption_options_requesting_key', {
|
|
15585
15667
|
envp_id: envelope.id,
|
|
15586
15668
|
});
|
|
15587
15669
|
return await this.handleToBeEncryptedEnvelopeWithOptions(envelope, context, normalizeEncryptionOptions({
|
|
@@ -15589,7 +15671,7 @@ class EnvelopeSecurityHandler {
|
|
|
15589
15671
|
}));
|
|
15590
15672
|
}
|
|
15591
15673
|
catch (error) {
|
|
15592
|
-
logger$
|
|
15674
|
+
logger$Y.debug('sealed_key_lookup_failed_requesting', {
|
|
15593
15675
|
envp_id: envelope.id,
|
|
15594
15676
|
error: error instanceof Error ? error.message : String(error),
|
|
15595
15677
|
});
|
|
@@ -15600,7 +15682,7 @@ class EnvelopeSecurityHandler {
|
|
|
15600
15682
|
}
|
|
15601
15683
|
async handleChannelEncryption(envelope, context) {
|
|
15602
15684
|
if (!envelope.to) {
|
|
15603
|
-
logger$
|
|
15685
|
+
logger$Y.warning('channel_encryption_requested_but_no_destination', {
|
|
15604
15686
|
envp_id: envelope.id,
|
|
15605
15687
|
});
|
|
15606
15688
|
return true;
|
|
@@ -15615,13 +15697,13 @@ class EnvelopeSecurityHandler {
|
|
|
15615
15697
|
return true;
|
|
15616
15698
|
}
|
|
15617
15699
|
if (context.originType !== core.DeliveryOriginType.LOCAL) {
|
|
15618
|
-
logger$
|
|
15700
|
+
logger$Y.warning('envelope_encryption_rejected_non_local', {
|
|
15619
15701
|
origin: context.originType,
|
|
15620
15702
|
});
|
|
15621
15703
|
return true;
|
|
15622
15704
|
}
|
|
15623
15705
|
if (!isDataFrame$4(envelope.frame)) {
|
|
15624
|
-
logger$
|
|
15706
|
+
logger$Y.trace('skipping_encryption_non_dataframe', {
|
|
15625
15707
|
envp_id: envelope.id,
|
|
15626
15708
|
frame_type: envelope.frame.type,
|
|
15627
15709
|
});
|
|
@@ -15632,7 +15714,7 @@ class EnvelopeSecurityHandler {
|
|
|
15632
15714
|
? normalizeEncryptionOptions(rawOptions)
|
|
15633
15715
|
: undefined;
|
|
15634
15716
|
if (!options) {
|
|
15635
|
-
logger$
|
|
15717
|
+
logger$Y.warning('no_encryption_options_provided', {
|
|
15636
15718
|
envp_id: envelope.id,
|
|
15637
15719
|
});
|
|
15638
15720
|
return true;
|
|
@@ -15644,13 +15726,13 @@ class EnvelopeSecurityHandler {
|
|
|
15644
15726
|
return true;
|
|
15645
15727
|
}
|
|
15646
15728
|
if (context.originType !== core.DeliveryOriginType.LOCAL) {
|
|
15647
|
-
logger$
|
|
15729
|
+
logger$Y.warning('envelope_encryption_rejected_non_local', {
|
|
15648
15730
|
origin: context.originType,
|
|
15649
15731
|
});
|
|
15650
15732
|
return true;
|
|
15651
15733
|
}
|
|
15652
15734
|
if (!isDataFrame$4(envelope.frame)) {
|
|
15653
|
-
logger$
|
|
15735
|
+
logger$Y.trace('skipping_encryption_non_dataframe', {
|
|
15654
15736
|
envp_id: envelope.id,
|
|
15655
15737
|
frame_type: envelope.frame.type,
|
|
15656
15738
|
});
|
|
@@ -15667,7 +15749,7 @@ class EnvelopeSecurityHandler {
|
|
|
15667
15749
|
// Skip encryption if envelope is already encrypted
|
|
15668
15750
|
// This prevents re-queuing when replayed envelopes go through security again
|
|
15669
15751
|
if (envelope.sec?.enc) {
|
|
15670
|
-
logger$
|
|
15752
|
+
logger$Y.debug('skipping_encryption_already_encrypted', {
|
|
15671
15753
|
envp_id: envelope.id,
|
|
15672
15754
|
destination: envelope.to ? String(envelope.to) : undefined,
|
|
15673
15755
|
});
|
|
@@ -15676,14 +15758,14 @@ class EnvelopeSecurityHandler {
|
|
|
15676
15758
|
try {
|
|
15677
15759
|
const result = await this.encryptionManager.encryptEnvelope(envelope, normalizedOptions);
|
|
15678
15760
|
if (result.status === exports.EncryptionStatus.QUEUED) {
|
|
15679
|
-
logger$
|
|
15761
|
+
logger$Y.debug('envelope_queued_for_encryption', {
|
|
15680
15762
|
envp_id: envelope.id,
|
|
15681
15763
|
});
|
|
15682
15764
|
await this.handleEncryptionQueueing(envelope, context, normalizedOptions);
|
|
15683
15765
|
return false;
|
|
15684
15766
|
}
|
|
15685
15767
|
if (result.status === exports.EncryptionStatus.OK) {
|
|
15686
|
-
logger$
|
|
15768
|
+
logger$Y.debug('envelope_encrypted', { envp_id: envelope.id });
|
|
15687
15769
|
if (result.envelope) {
|
|
15688
15770
|
envelope.frame = result.envelope.frame;
|
|
15689
15771
|
envelope.sec = result.envelope.sec;
|
|
@@ -15691,17 +15773,17 @@ class EnvelopeSecurityHandler {
|
|
|
15691
15773
|
return true;
|
|
15692
15774
|
}
|
|
15693
15775
|
if (result.status === exports.EncryptionStatus.SKIPPED) {
|
|
15694
|
-
logger$
|
|
15776
|
+
logger$Y.debug('envelope_encryption_skipped', { envp_id: envelope.id });
|
|
15695
15777
|
return true;
|
|
15696
15778
|
}
|
|
15697
|
-
logger$
|
|
15779
|
+
logger$Y.warning('unknown_encryption_status', {
|
|
15698
15780
|
envp_id: envelope.id,
|
|
15699
15781
|
status: result.status,
|
|
15700
15782
|
});
|
|
15701
15783
|
return true;
|
|
15702
15784
|
}
|
|
15703
15785
|
catch (error) {
|
|
15704
|
-
logger$
|
|
15786
|
+
logger$Y.error('encryption_failed', {
|
|
15705
15787
|
envp_id: envelope.id,
|
|
15706
15788
|
error: error instanceof Error ? error.message : String(error),
|
|
15707
15789
|
});
|
|
@@ -15740,7 +15822,7 @@ class EnvelopeSecurityHandler {
|
|
|
15740
15822
|
return;
|
|
15741
15823
|
}
|
|
15742
15824
|
if (normalizedOptions.encryptionType === 'channel') {
|
|
15743
|
-
logger$
|
|
15825
|
+
logger$Y.debug('channel_encryption_queueing_handled_internally', {
|
|
15744
15826
|
envp_id: envelope.id,
|
|
15745
15827
|
destination: normalizedOptions.destination
|
|
15746
15828
|
? String(normalizedOptions.destination)
|
|
@@ -15748,13 +15830,13 @@ class EnvelopeSecurityHandler {
|
|
|
15748
15830
|
});
|
|
15749
15831
|
return;
|
|
15750
15832
|
}
|
|
15751
|
-
logger$
|
|
15833
|
+
logger$Y.warning('unknown_encryption_queueing_options', {
|
|
15752
15834
|
envp_id: envelope.id,
|
|
15753
15835
|
options: normalizedOptions,
|
|
15754
15836
|
});
|
|
15755
15837
|
}
|
|
15756
15838
|
async handleFailedChannelEnvelopeCleanup(destination, reason) {
|
|
15757
|
-
logger$
|
|
15839
|
+
logger$Y.debug('channel_handshake_failure_cleanup_attempted', {
|
|
15758
15840
|
destination,
|
|
15759
15841
|
reason,
|
|
15760
15842
|
note: 'envelope_cleanup_handled_by_encryption_manager',
|
|
@@ -15765,7 +15847,7 @@ class EnvelopeSecurityHandler {
|
|
|
15765
15847
|
}
|
|
15766
15848
|
}
|
|
15767
15849
|
|
|
15768
|
-
const logger$
|
|
15850
|
+
const logger$X = getLogger('naylence.fame.node.secure_channel_frame_handler');
|
|
15769
15851
|
function isPlainRecord$1(value) {
|
|
15770
15852
|
if (typeof value !== 'object' || value === null) {
|
|
15771
15853
|
return false;
|
|
@@ -15855,7 +15937,7 @@ class SecureChannelFrameHandler {
|
|
|
15855
15937
|
assertSecureChannelManager(this.secureChannelManager);
|
|
15856
15938
|
const frame = envelope.frame;
|
|
15857
15939
|
assertFrameType(frame, 'SecureOpen');
|
|
15858
|
-
logger$
|
|
15940
|
+
logger$X.debug('received_secure_open', {
|
|
15859
15941
|
cid: frame.cid,
|
|
15860
15942
|
algorithm: frame.alg,
|
|
15861
15943
|
});
|
|
@@ -15878,13 +15960,13 @@ class SecureChannelFrameHandler {
|
|
|
15878
15960
|
stickySid: envelope.sid ?? undefined,
|
|
15879
15961
|
expectedResponseType: core.FameResponseType.NONE,
|
|
15880
15962
|
};
|
|
15881
|
-
logger$
|
|
15963
|
+
logger$X.debug('stickiness_requested_for_channel_encryption', {
|
|
15882
15964
|
cid: frame.cid,
|
|
15883
15965
|
reason: 'secure_channel_established',
|
|
15884
15966
|
});
|
|
15885
15967
|
}
|
|
15886
15968
|
await this.sendCallback(responseEnvelope, responseContext);
|
|
15887
|
-
logger$
|
|
15969
|
+
logger$X.debug('sent_secure_accept', { cid: frame.cid, ok: acceptFrame.ok });
|
|
15888
15970
|
if (acceptFrame.ok && this.envelopeSecurityHandler) {
|
|
15889
15971
|
const destination = extractDestinationFromChannelId(frame.cid);
|
|
15890
15972
|
if (destination) {
|
|
@@ -15896,13 +15978,13 @@ class SecureChannelFrameHandler {
|
|
|
15896
15978
|
assertSecureChannelManager(this.secureChannelManager);
|
|
15897
15979
|
const frame = envelope.frame;
|
|
15898
15980
|
assertFrameType(frame, 'SecureAccept');
|
|
15899
|
-
logger$
|
|
15981
|
+
logger$X.debug('received_secure_accept', { cid: frame.cid, ok: frame.ok });
|
|
15900
15982
|
const success = await this.secureChannelManager.handleAcceptFrame(frame);
|
|
15901
15983
|
if (!success) {
|
|
15902
|
-
logger$
|
|
15984
|
+
logger$X.warning('failed_to_complete_channel', { cid: frame.cid });
|
|
15903
15985
|
}
|
|
15904
15986
|
else {
|
|
15905
|
-
logger$
|
|
15987
|
+
logger$X.debug('channel_established', { cid: frame.cid });
|
|
15906
15988
|
if (this.envelopeSecurityHandler) {
|
|
15907
15989
|
const destination = extractDestinationFromChannelId(frame.cid);
|
|
15908
15990
|
if (destination) {
|
|
@@ -15914,7 +15996,7 @@ class SecureChannelFrameHandler {
|
|
|
15914
15996
|
const destination = extractDestinationFromChannelId(frame.cid);
|
|
15915
15997
|
if (destination) {
|
|
15916
15998
|
await this.envelopeSecurityHandler.handleChannelHandshakeFailed(frame.cid, destination, 'negative_secure_accept');
|
|
15917
|
-
logger$
|
|
15999
|
+
logger$X.debug('notified_handshake_failure', {
|
|
15918
16000
|
cid: frame.cid,
|
|
15919
16001
|
destination,
|
|
15920
16002
|
});
|
|
@@ -15925,7 +16007,7 @@ class SecureChannelFrameHandler {
|
|
|
15925
16007
|
assertSecureChannelManager(this.secureChannelManager);
|
|
15926
16008
|
const frame = envelope.frame;
|
|
15927
16009
|
assertFrameType(frame, 'SecureClose');
|
|
15928
|
-
logger$
|
|
16010
|
+
logger$X.debug('received_secure_close', {
|
|
15929
16011
|
cid: frame.cid,
|
|
15930
16012
|
reason: frame.reason,
|
|
15931
16013
|
});
|
|
@@ -15983,7 +16065,7 @@ function createNodeDeliveryContext(options = {}) {
|
|
|
15983
16065
|
class FameEnvironmentContext {
|
|
15984
16066
|
}
|
|
15985
16067
|
|
|
15986
|
-
const FACTORY_META$
|
|
16068
|
+
const FACTORY_META$17 = {
|
|
15987
16069
|
base: NODE_IDENTITY_POLICY_FACTORY_BASE_TYPE,
|
|
15988
16070
|
key: 'DefaultNodeIdentityPolicy',
|
|
15989
16071
|
};
|
|
@@ -16001,11 +16083,11 @@ class DefaultNodeIdentityPolicyFactory extends NodeIdentityPolicyFactory {
|
|
|
16001
16083
|
var defaultNodeIdentityPolicyFactory = /*#__PURE__*/Object.freeze({
|
|
16002
16084
|
__proto__: null,
|
|
16003
16085
|
DefaultNodeIdentityPolicyFactory: DefaultNodeIdentityPolicyFactory,
|
|
16004
|
-
FACTORY_META: FACTORY_META$
|
|
16086
|
+
FACTORY_META: FACTORY_META$17,
|
|
16005
16087
|
default: DefaultNodeIdentityPolicyFactory
|
|
16006
16088
|
});
|
|
16007
16089
|
|
|
16008
|
-
const logger$
|
|
16090
|
+
const logger$W = getLogger('naylence.fame.node.token_subject_node_identity_policy');
|
|
16009
16091
|
class TokenSubjectNodeIdentityPolicy {
|
|
16010
16092
|
async resolveInitialNodeId(context) {
|
|
16011
16093
|
if (context.configuredId) {
|
|
@@ -16017,7 +16099,7 @@ class TokenSubjectNodeIdentityPolicy {
|
|
|
16017
16099
|
return core.generateIdAsync();
|
|
16018
16100
|
}
|
|
16019
16101
|
async resolveAdmissionNodeId(context) {
|
|
16020
|
-
logger$
|
|
16102
|
+
logger$W.debug('resolve_admission_node_id_start', {
|
|
16021
16103
|
grantsCount: context.grants?.length ?? 0,
|
|
16022
16104
|
currentNodeId: context.currentNodeId,
|
|
16023
16105
|
});
|
|
@@ -16026,31 +16108,31 @@ class TokenSubjectNodeIdentityPolicy {
|
|
|
16026
16108
|
try {
|
|
16027
16109
|
const auth = grant.auth;
|
|
16028
16110
|
if (!auth) {
|
|
16029
|
-
logger$
|
|
16111
|
+
logger$W.debug('skipping_grant_no_auth', { grantType: grant.type });
|
|
16030
16112
|
continue;
|
|
16031
16113
|
}
|
|
16032
16114
|
const tokenProviderConfig = (auth.tokenProvider ??
|
|
16033
16115
|
auth.token_provider);
|
|
16034
16116
|
if (!tokenProviderConfig ||
|
|
16035
16117
|
typeof tokenProviderConfig.type !== 'string') {
|
|
16036
|
-
logger$
|
|
16118
|
+
logger$W.debug('skipping_grant_invalid_token_provider_config', {
|
|
16037
16119
|
grantType: grant.type,
|
|
16038
16120
|
config: tokenProviderConfig,
|
|
16039
16121
|
});
|
|
16040
16122
|
continue;
|
|
16041
16123
|
}
|
|
16042
|
-
logger$
|
|
16124
|
+
logger$W.debug('creating_token_provider', {
|
|
16043
16125
|
type: tokenProviderConfig.type,
|
|
16044
16126
|
});
|
|
16045
16127
|
const provider = await TokenProviderFactory.createTokenProvider(tokenProviderConfig);
|
|
16046
16128
|
const isExposing = isIdentityExposingTokenProvider(provider);
|
|
16047
|
-
logger$
|
|
16129
|
+
logger$W.debug('token_provider_created', {
|
|
16048
16130
|
type: tokenProviderConfig.type,
|
|
16049
16131
|
isIdentityExposing: isExposing,
|
|
16050
16132
|
});
|
|
16051
16133
|
if (isExposing) {
|
|
16052
16134
|
const identity = await provider.getIdentity();
|
|
16053
|
-
logger$
|
|
16135
|
+
logger$W.debug('retrieved_identity', { identity });
|
|
16054
16136
|
if (identity && identity.subject) {
|
|
16055
16137
|
const hashedSubject = await core.generateIdAsync({
|
|
16056
16138
|
mode: 'fingerprint',
|
|
@@ -16058,7 +16140,7 @@ class TokenSubjectNodeIdentityPolicy {
|
|
|
16058
16140
|
length: 8,
|
|
16059
16141
|
});
|
|
16060
16142
|
const newNodeId = `${hashedSubject}-${context.currentNodeId}`;
|
|
16061
|
-
logger$
|
|
16143
|
+
logger$W.info('resolved_identity_from_token', {
|
|
16062
16144
|
subject: identity.subject,
|
|
16063
16145
|
hashedSubject,
|
|
16064
16146
|
newNodeId,
|
|
@@ -16066,17 +16148,17 @@ class TokenSubjectNodeIdentityPolicy {
|
|
|
16066
16148
|
return newNodeId;
|
|
16067
16149
|
}
|
|
16068
16150
|
else {
|
|
16069
|
-
logger$
|
|
16151
|
+
logger$W.debug('identity_missing_subject', { identity });
|
|
16070
16152
|
}
|
|
16071
16153
|
}
|
|
16072
16154
|
}
|
|
16073
16155
|
catch (err) {
|
|
16074
|
-
logger$
|
|
16156
|
+
logger$W.warning('failed_to_extract_identity_from_grant', { error: err });
|
|
16075
16157
|
}
|
|
16076
16158
|
}
|
|
16077
16159
|
}
|
|
16078
16160
|
else {
|
|
16079
|
-
logger$
|
|
16161
|
+
logger$W.debug('no_grants_available');
|
|
16080
16162
|
}
|
|
16081
16163
|
return context.currentNodeId;
|
|
16082
16164
|
}
|
|
@@ -16087,7 +16169,7 @@ var tokenSubjectNodeIdentityPolicy = /*#__PURE__*/Object.freeze({
|
|
|
16087
16169
|
TokenSubjectNodeIdentityPolicy: TokenSubjectNodeIdentityPolicy
|
|
16088
16170
|
});
|
|
16089
16171
|
|
|
16090
|
-
const FACTORY_META$
|
|
16172
|
+
const FACTORY_META$16 = {
|
|
16091
16173
|
base: NODE_IDENTITY_POLICY_FACTORY_BASE_TYPE,
|
|
16092
16174
|
key: 'TokenSubjectNodeIdentityPolicy',
|
|
16093
16175
|
};
|
|
@@ -16106,12 +16188,12 @@ class TokenSubjectNodeIdentityPolicyFactory extends NodeIdentityPolicyFactory {
|
|
|
16106
16188
|
|
|
16107
16189
|
var tokenSubjectNodeIdentityPolicyFactory = /*#__PURE__*/Object.freeze({
|
|
16108
16190
|
__proto__: null,
|
|
16109
|
-
FACTORY_META: FACTORY_META$
|
|
16191
|
+
FACTORY_META: FACTORY_META$16,
|
|
16110
16192
|
TokenSubjectNodeIdentityPolicyFactory: TokenSubjectNodeIdentityPolicyFactory,
|
|
16111
16193
|
default: TokenSubjectNodeIdentityPolicyFactory
|
|
16112
16194
|
});
|
|
16113
16195
|
|
|
16114
|
-
const logger$
|
|
16196
|
+
const logger$V = getLogger('naylence.fame.node.node_identity_policy_profile_factory');
|
|
16115
16197
|
const PROFILE_NAME_DEFAULT = 'default';
|
|
16116
16198
|
const PROFILE_NAME_TOKEN_SUBJECT = 'token-subject';
|
|
16117
16199
|
const PROFILE_NAME_TOKEN_SUBJECT_ALIAS = 'token_subject';
|
|
@@ -16126,7 +16208,7 @@ const PROFILE_MAP$5 = {
|
|
|
16126
16208
|
[PROFILE_NAME_TOKEN_SUBJECT]: TOKEN_SUBJECT_PROFILE,
|
|
16127
16209
|
[PROFILE_NAME_TOKEN_SUBJECT_ALIAS]: TOKEN_SUBJECT_PROFILE,
|
|
16128
16210
|
};
|
|
16129
|
-
const FACTORY_META$
|
|
16211
|
+
const FACTORY_META$15 = {
|
|
16130
16212
|
base: NODE_IDENTITY_POLICY_FACTORY_BASE_TYPE,
|
|
16131
16213
|
key: 'NodeIdentityPolicyProfile',
|
|
16132
16214
|
};
|
|
@@ -16138,7 +16220,7 @@ class NodeIdentityPolicyProfileFactory extends NodeIdentityPolicyFactory {
|
|
|
16138
16220
|
async create(config) {
|
|
16139
16221
|
const normalized = normalizeConfig$t(config);
|
|
16140
16222
|
const profileConfig = resolveProfileConfig$4(normalized.profile);
|
|
16141
|
-
logger$
|
|
16223
|
+
logger$V.debug('enabling_node_identity_policy_profile', {
|
|
16142
16224
|
profile: normalized.profile,
|
|
16143
16225
|
});
|
|
16144
16226
|
return NodeIdentityPolicyFactory.createNodeIdentityPolicy(profileConfig);
|
|
@@ -16174,11 +16256,95 @@ function deepClone$4(value) {
|
|
|
16174
16256
|
|
|
16175
16257
|
var nodeIdentityPolicyProfileFactory = /*#__PURE__*/Object.freeze({
|
|
16176
16258
|
__proto__: null,
|
|
16177
|
-
FACTORY_META: FACTORY_META$
|
|
16259
|
+
FACTORY_META: FACTORY_META$15,
|
|
16178
16260
|
NodeIdentityPolicyProfileFactory: NodeIdentityPolicyProfileFactory,
|
|
16179
16261
|
default: NodeIdentityPolicyProfileFactory
|
|
16180
16262
|
});
|
|
16181
16263
|
|
|
16264
|
+
/**
|
|
16265
|
+
* Environment variable for overriding max initial attempts.
|
|
16266
|
+
*/
|
|
16267
|
+
const ENV_VAR_SESSION_MAX_INITIAL_ATTEMPTS = 'FAME_SESSION_MAX_INITIAL_ATTEMPTS';
|
|
16268
|
+
/**
|
|
16269
|
+
* Default implementation of connection retry policy.
|
|
16270
|
+
*
|
|
16271
|
+
* Before first successful attach:
|
|
16272
|
+
* - Respects maxInitialAttempts configuration
|
|
16273
|
+
* - Uses exponential backoff with jitter
|
|
16274
|
+
*
|
|
16275
|
+
* After first successful attach:
|
|
16276
|
+
* - Always retries (unlimited) to maintain connection
|
|
16277
|
+
* - Resets backoff if connection was stable for >10 seconds
|
|
16278
|
+
*/
|
|
16279
|
+
class DefaultConnectionRetryPolicy {
|
|
16280
|
+
constructor(options = {}) {
|
|
16281
|
+
// Check for environment variable override
|
|
16282
|
+
const envValue = typeof process !== 'undefined'
|
|
16283
|
+
? process.env?.[ENV_VAR_SESSION_MAX_INITIAL_ATTEMPTS]
|
|
16284
|
+
: undefined;
|
|
16285
|
+
if (envValue !== undefined && envValue !== '') {
|
|
16286
|
+
const parsed = parseInt(envValue, 10);
|
|
16287
|
+
this.maxInitialAttempts = isNaN(parsed) ? (options.maxInitialAttempts ?? 1) : parsed;
|
|
16288
|
+
}
|
|
16289
|
+
else {
|
|
16290
|
+
this.maxInitialAttempts = options.maxInitialAttempts ?? 1;
|
|
16291
|
+
}
|
|
16292
|
+
}
|
|
16293
|
+
shouldRetry(context) {
|
|
16294
|
+
// After first successful attach, always retry to maintain connection
|
|
16295
|
+
if (context.hadSuccessfulAttach) {
|
|
16296
|
+
return true;
|
|
16297
|
+
}
|
|
16298
|
+
// maxInitialAttempts = 0 means unlimited retries
|
|
16299
|
+
if (this.maxInitialAttempts === 0) {
|
|
16300
|
+
return true;
|
|
16301
|
+
}
|
|
16302
|
+
// Fail if we've exceeded the configured max attempts
|
|
16303
|
+
return context.attemptNumber < this.maxInitialAttempts;
|
|
16304
|
+
}
|
|
16305
|
+
calculateRetryDelay(_context, baseDelay) {
|
|
16306
|
+
// Add jitter to prevent thundering herd
|
|
16307
|
+
const jitter = Math.random() * baseDelay;
|
|
16308
|
+
return baseDelay + jitter;
|
|
16309
|
+
}
|
|
16310
|
+
}
|
|
16311
|
+
|
|
16312
|
+
const logger$U = getLogger('naylence.fame.node.default-connection-retry-policy-factory');
|
|
16313
|
+
const FACTORY_META$14 = {
|
|
16314
|
+
base: CONNECTION_RETRY_POLICY_FACTORY_BASE_TYPE,
|
|
16315
|
+
key: 'DefaultConnectionRetryPolicy',
|
|
16316
|
+
};
|
|
16317
|
+
class DefaultConnectionRetryPolicyFactory extends ConnectionRetryPolicyFactory {
|
|
16318
|
+
constructor() {
|
|
16319
|
+
super(...arguments);
|
|
16320
|
+
this.type = 'DefaultConnectionRetryPolicy';
|
|
16321
|
+
this.isDefault = true;
|
|
16322
|
+
}
|
|
16323
|
+
async create(config) {
|
|
16324
|
+
const options = {};
|
|
16325
|
+
if (config) {
|
|
16326
|
+
const rawMax = config.maxInitialAttempts ??
|
|
16327
|
+
config.max_initial_attempts;
|
|
16328
|
+
if (rawMax !== undefined && rawMax !== null) {
|
|
16329
|
+
options.maxInitialAttempts =
|
|
16330
|
+
typeof rawMax === 'string' ? parseInt(rawMax, 10) : Number(rawMax);
|
|
16331
|
+
}
|
|
16332
|
+
}
|
|
16333
|
+
const policy = new DefaultConnectionRetryPolicy(options);
|
|
16334
|
+
logger$U.debug('connection_retry_policy_created', {
|
|
16335
|
+
maxInitialAttempts: policy.maxInitialAttempts,
|
|
16336
|
+
});
|
|
16337
|
+
return policy;
|
|
16338
|
+
}
|
|
16339
|
+
}
|
|
16340
|
+
|
|
16341
|
+
var defaultConnectionRetryPolicyFactory = /*#__PURE__*/Object.freeze({
|
|
16342
|
+
__proto__: null,
|
|
16343
|
+
DefaultConnectionRetryPolicyFactory: DefaultConnectionRetryPolicyFactory,
|
|
16344
|
+
FACTORY_META: FACTORY_META$14,
|
|
16345
|
+
default: DefaultConnectionRetryPolicyFactory
|
|
16346
|
+
});
|
|
16347
|
+
|
|
16182
16348
|
const LOAD_BALANCER_STICKINESS_MANAGER_FACTORY_BASE_TYPE = 'LoadBalancerStickinessManagerFactory';
|
|
16183
16349
|
class LoadBalancerStickinessManagerFactory extends factory.AbstractResourceFactory {
|
|
16184
16350
|
static async createLoadBalancerStickinessManager(config, options = {}) {
|
|
@@ -19250,6 +19416,7 @@ class Sentinel extends FameNode {
|
|
|
19250
19416
|
this.maxAttachTtlSec = opts.maxAttachTtlSec ?? null;
|
|
19251
19417
|
this.requestedLogicals = opts.requestedLogicals ?? [];
|
|
19252
19418
|
this.attachClient = opts.attachClient ?? null;
|
|
19419
|
+
this.connectionRetryPolicy = opts.connectionRetryPolicy ?? null;
|
|
19253
19420
|
this.nodeAttachFrameHandler = new NodeAttachFrameHandler({
|
|
19254
19421
|
routingNode: this,
|
|
19255
19422
|
routeManager: this.routeManager,
|
|
@@ -19799,6 +19966,7 @@ class Sentinel extends FameNode {
|
|
|
19799
19966
|
onAttach: (info, connector) => this.onNodeAttachToPeer(info, connector),
|
|
19800
19967
|
onEpochChange: (epoch) => this.onEpochChange(epoch),
|
|
19801
19968
|
onWelcome: async () => undefined,
|
|
19969
|
+
retryPolicy: this.connectionRetryPolicy,
|
|
19802
19970
|
});
|
|
19803
19971
|
await sessionManager.start();
|
|
19804
19972
|
const systemId = sessionManager.systemId;
|
|
@@ -34542,6 +34710,7 @@ class OAuth2AuthorizerFactory extends AuthorizerFactory {
|
|
|
34542
34710
|
defaultTtlSec: normalized.defaultTtlSec,
|
|
34543
34711
|
maxTtlSec: normalized.maxTtlSec,
|
|
34544
34712
|
reverseAuthTtlSec: normalized.reverseAuthTtlSec,
|
|
34713
|
+
enforceTokenSubjectNodeIdentity: normalized.enforceTokenSubjectNodeIdentity,
|
|
34545
34714
|
};
|
|
34546
34715
|
if (tokenIssuer) {
|
|
34547
34716
|
authorizerOptions.tokenIssuer = tokenIssuer;
|
|
@@ -34609,6 +34778,11 @@ function normalizeConfig$c(config) {
|
|
|
34609
34778
|
: typeof source.reverse_auth_ttl_sec === 'number'
|
|
34610
34779
|
? source.reverse_auth_ttl_sec
|
|
34611
34780
|
: DEFAULT_REVERSE_AUTH_TTL_SEC;
|
|
34781
|
+
const enforceTokenSubjectNodeIdentity = typeof source.enforceTokenSubjectNodeIdentity === 'boolean'
|
|
34782
|
+
? source.enforceTokenSubjectNodeIdentity
|
|
34783
|
+
: typeof source.enforce_token_subject_node_identity === 'boolean'
|
|
34784
|
+
? source.enforce_token_subject_node_identity
|
|
34785
|
+
: false;
|
|
34612
34786
|
const tokenVerifierConfigInput = source.tokenVerifierConfig ?? source.token_verifier_config ?? null;
|
|
34613
34787
|
const tokenVerifierConfig = normalizeTokenVerifierConfig({
|
|
34614
34788
|
config: tokenVerifierConfigInput,
|
|
@@ -34627,6 +34801,7 @@ function normalizeConfig$c(config) {
|
|
|
34627
34801
|
maxTtlSec,
|
|
34628
34802
|
tokenVerifierConfig,
|
|
34629
34803
|
reverseAuthTtlSec: reverseAuthCandidate,
|
|
34804
|
+
enforceTokenSubjectNodeIdentity,
|
|
34630
34805
|
...(audience ? { audience } : {}),
|
|
34631
34806
|
};
|
|
34632
34807
|
if (tokenIssuerConfig) {
|
|
@@ -39664,6 +39839,10 @@ function normalizeOptions$4(raw) {
|
|
|
39664
39839
|
: typeof snake.aud === 'string'
|
|
39665
39840
|
? snake.aud
|
|
39666
39841
|
: undefined);
|
|
39842
|
+
const enforceTokenSubjectNodeIdentity = camel.enforceTokenSubjectNodeIdentity ??
|
|
39843
|
+
(typeof snake.enforce_token_subject_node_identity === 'boolean'
|
|
39844
|
+
? snake.enforce_token_subject_node_identity
|
|
39845
|
+
: undefined);
|
|
39667
39846
|
return {
|
|
39668
39847
|
tokenVerifier,
|
|
39669
39848
|
tokenIssuer,
|
|
@@ -39673,6 +39852,7 @@ function normalizeOptions$4(raw) {
|
|
|
39673
39852
|
defaultTtlSec,
|
|
39674
39853
|
maxTtlSec,
|
|
39675
39854
|
reverseAuthTtlSec,
|
|
39855
|
+
enforceTokenSubjectNodeIdentity,
|
|
39676
39856
|
};
|
|
39677
39857
|
}
|
|
39678
39858
|
class OAuth2Authorizer {
|
|
@@ -39686,6 +39866,8 @@ class OAuth2Authorizer {
|
|
|
39686
39866
|
this.requireScope = options.requireScope ?? true;
|
|
39687
39867
|
this.reverseAuthTtlSec =
|
|
39688
39868
|
options.reverseAuthTtlSec ?? DEFAULT_REVERSE_AUTH_TTL_SEC;
|
|
39869
|
+
this.enforceTokenSubjectNodeIdentity =
|
|
39870
|
+
options.enforceTokenSubjectNodeIdentity ?? false;
|
|
39689
39871
|
}
|
|
39690
39872
|
get tokenVerifier() {
|
|
39691
39873
|
return this.tokenVerifierImpl;
|
|
@@ -39815,6 +39997,13 @@ class OAuth2Authorizer {
|
|
|
39815
39997
|
});
|
|
39816
39998
|
return undefined;
|
|
39817
39999
|
}
|
|
40000
|
+
// Enforce token subject node identity if enabled
|
|
40001
|
+
if (this.enforceTokenSubjectNodeIdentity) {
|
|
40002
|
+
const validationResult = await this.validateTokenSubjectNodeIdentity(frame.systemId, claims);
|
|
40003
|
+
if (!validationResult) {
|
|
40004
|
+
return undefined;
|
|
40005
|
+
}
|
|
40006
|
+
}
|
|
39818
40007
|
claims.instance_id = claims.instance_id ?? frame.instanceId;
|
|
39819
40008
|
claims.assigned_path = claims.assigned_path ?? frame.assignedPath;
|
|
39820
40009
|
claims.accepted_capabilities =
|
|
@@ -39892,6 +40081,33 @@ class OAuth2Authorizer {
|
|
|
39892
40081
|
}
|
|
39893
40082
|
return false;
|
|
39894
40083
|
}
|
|
40084
|
+
async validateTokenSubjectNodeIdentity(systemId, claims) {
|
|
40085
|
+
const sub = claims.sub;
|
|
40086
|
+
if (typeof sub !== 'string' || sub.trim().length === 0) {
|
|
40087
|
+
logger$3.warning('oauth2_attach_missing_subject_claim', {
|
|
40088
|
+
system_id: systemId,
|
|
40089
|
+
});
|
|
40090
|
+
return false;
|
|
40091
|
+
}
|
|
40092
|
+
const expectedPrefix = await core.generateIdAsync({
|
|
40093
|
+
mode: 'fingerprint',
|
|
40094
|
+
material: sub,
|
|
40095
|
+
length: 8,
|
|
40096
|
+
});
|
|
40097
|
+
if (!systemId.startsWith(`${expectedPrefix}-`)) {
|
|
40098
|
+
logger$3.warning('oauth2_attach_node_identity_mismatch', {
|
|
40099
|
+
system_id: systemId,
|
|
40100
|
+
expected_prefix: expectedPrefix,
|
|
40101
|
+
subject: sub,
|
|
40102
|
+
});
|
|
40103
|
+
return false;
|
|
40104
|
+
}
|
|
40105
|
+
logger$3.debug('oauth2_attach_node_identity_verified', {
|
|
40106
|
+
system_id: systemId,
|
|
40107
|
+
expected_prefix: expectedPrefix,
|
|
40108
|
+
});
|
|
40109
|
+
return true;
|
|
40110
|
+
}
|
|
39895
40111
|
}
|
|
39896
40112
|
|
|
39897
40113
|
var oauth2Authorizer = /*#__PURE__*/Object.freeze({
|
|
@@ -41544,13 +41760,17 @@ exports.BroadcastChannelListenerFactory = BroadcastChannelListenerFactory;
|
|
|
41544
41760
|
exports.BrowserAutoKeyCredentialProvider = BrowserAutoKeyCredentialProvider;
|
|
41545
41761
|
exports.BrowserWrappedKeyCredentialProvider = BrowserWrappedKeyCredentialProvider;
|
|
41546
41762
|
exports.CERTIFICATE_MANAGER_FACTORY_BASE_TYPE = CERTIFICATE_MANAGER_FACTORY_BASE_TYPE;
|
|
41763
|
+
exports.CONNECTION_RETRY_POLICY_FACTORY_BASE_TYPE = CONNECTION_RETRY_POLICY_FACTORY_BASE_TYPE;
|
|
41547
41764
|
exports.CREDENTIAL_PROVIDER_FACTORY_BASE_TYPE = CREDENTIAL_PROVIDER_FACTORY_BASE_TYPE;
|
|
41548
41765
|
exports.CRYPTO_LEVEL_SECURITY_ORDER = CRYPTO_LEVEL_SECURITY_ORDER;
|
|
41549
41766
|
exports.CertificateManagerFactory = CertificateManagerFactory;
|
|
41767
|
+
exports.ConnectionRetryPolicyFactory = ConnectionRetryPolicyFactory;
|
|
41550
41768
|
exports.ConnectorConfigDefaults = ConnectorConfigDefaults;
|
|
41551
41769
|
exports.ConnectorFactory = ConnectorFactory;
|
|
41552
41770
|
exports.ConsoleMetricsEmitter = ConsoleMetricsEmitter;
|
|
41553
41771
|
exports.DEFAULT_WELCOME_FACTORY_META = FACTORY_META$$;
|
|
41772
|
+
exports.DefaultConnectionRetryPolicy = DefaultConnectionRetryPolicy;
|
|
41773
|
+
exports.DefaultConnectionRetryPolicyFactory = DefaultConnectionRetryPolicyFactory;
|
|
41554
41774
|
exports.DefaultCryptoProvider = DefaultCryptoProvider;
|
|
41555
41775
|
exports.DefaultKeyManager = DefaultKeyManager;
|
|
41556
41776
|
exports.DefaultNodeIdentityPolicy = DefaultNodeIdentityPolicy;
|
|
@@ -41571,6 +41791,7 @@ exports.ENV_VAR_JWT_AUDIENCE = ENV_VAR_JWT_AUDIENCE$1;
|
|
|
41571
41791
|
exports.ENV_VAR_JWT_REVERSE_AUTH_AUDIENCE = ENV_VAR_JWT_REVERSE_AUTH_AUDIENCE;
|
|
41572
41792
|
exports.ENV_VAR_JWT_REVERSE_AUTH_TRUSTED_ISSUER = ENV_VAR_JWT_REVERSE_AUTH_TRUSTED_ISSUER;
|
|
41573
41793
|
exports.ENV_VAR_JWT_TRUSTED_ISSUER = ENV_VAR_JWT_TRUSTED_ISSUER;
|
|
41794
|
+
exports.ENV_VAR_SESSION_MAX_INITIAL_ATTEMPTS = ENV_VAR_SESSION_MAX_INITIAL_ATTEMPTS;
|
|
41574
41795
|
exports.ENV_VAR_SHOW_ENVELOPES = ENV_VAR_SHOW_ENVELOPES$1;
|
|
41575
41796
|
exports.EdDSAEnvelopeSigner = EdDSAEnvelopeSigner;
|
|
41576
41797
|
exports.EncryptedKeyValueStore = EncryptedKeyValueStore;
|