@naylence/runtime 0.3.15 → 0.3.16
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 +615 -442
- package/dist/browser/index.mjs +611 -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/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/sentinel/sentinel.js +2 -0
- package/dist/esm/version.js +2 -2
- package/dist/node/index.cjs +615 -442
- package/dist/node/index.mjs +611 -443
- package/dist/node/node.cjs +639 -466
- package/dist/node/node.mjs +635 -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/sentinel/sentinel.d.ts +1 -0
- package/dist/types/version.d.ts +1 -1
- package/package.json +1 -1
package/dist/node/index.cjs
CHANGED
|
@@ -14,12 +14,12 @@ var fastify = require('fastify');
|
|
|
14
14
|
var websocketPlugin = require('@fastify/websocket');
|
|
15
15
|
|
|
16
16
|
// This file is auto-generated during build - do not edit manually
|
|
17
|
-
// Generated from package.json version: 0.3.
|
|
17
|
+
// Generated from package.json version: 0.3.16
|
|
18
18
|
/**
|
|
19
19
|
* The package version, injected at build time.
|
|
20
20
|
* @internal
|
|
21
21
|
*/
|
|
22
|
-
const VERSION = '0.3.
|
|
22
|
+
const VERSION = '0.3.16';
|
|
23
23
|
|
|
24
24
|
/**
|
|
25
25
|
* Fame protocol specific error classes with WebSocket close codes and proper inheritance.
|
|
@@ -837,7 +837,7 @@ class TaskCancelledError extends Error {
|
|
|
837
837
|
* Provides functionality similar to Python's asyncio TaskSpawner with proper
|
|
838
838
|
* error handling, cancellation, and graceful shutdown capabilities.
|
|
839
839
|
*/
|
|
840
|
-
const logger$
|
|
840
|
+
const logger$1h = getLogger('naylence.fame.util.task_spawner');
|
|
841
841
|
function firstDefined(source, keys) {
|
|
842
842
|
for (const key of keys) {
|
|
843
843
|
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
@@ -998,7 +998,7 @@ class TaskSpawner {
|
|
|
998
998
|
const taskId = `task-${++this._taskCounter}`;
|
|
999
999
|
const taskName = normalizedOptions.name || `unnamed-${taskId}`;
|
|
1000
1000
|
const timeout = normalizedOptions.timeout ?? this._config.defaultTimeout;
|
|
1001
|
-
logger$
|
|
1001
|
+
logger$1h.debug('starting_background_task', {
|
|
1002
1002
|
task_name: taskName,
|
|
1003
1003
|
task_id: taskId,
|
|
1004
1004
|
});
|
|
@@ -1015,7 +1015,7 @@ class TaskSpawner {
|
|
|
1015
1015
|
task.promise
|
|
1016
1016
|
.then(() => {
|
|
1017
1017
|
if (!this._suppressCompletionLogging) {
|
|
1018
|
-
logger$
|
|
1018
|
+
logger$1h.debug('task_completed_successfully', {
|
|
1019
1019
|
task_name: taskName,
|
|
1020
1020
|
task_id: taskId,
|
|
1021
1021
|
duration_ms: Date.now() - task.startTime,
|
|
@@ -1069,7 +1069,7 @@ class TaskSpawner {
|
|
|
1069
1069
|
error.name === 'AbortError' ||
|
|
1070
1070
|
error.message === 'Task cancelled' ||
|
|
1071
1071
|
error.message === 'Aborted') {
|
|
1072
|
-
logger$
|
|
1072
|
+
logger$1h.debug('task_cancelled', {
|
|
1073
1073
|
task_name: taskName,
|
|
1074
1074
|
note: 'Task cancelled as requested',
|
|
1075
1075
|
});
|
|
@@ -1077,7 +1077,7 @@ class TaskSpawner {
|
|
|
1077
1077
|
}
|
|
1078
1078
|
// Handle timeout
|
|
1079
1079
|
if (error instanceof TaskTimeoutError) {
|
|
1080
|
-
logger$
|
|
1080
|
+
logger$1h.warning('task_timed_out', {
|
|
1081
1081
|
task_name: taskName,
|
|
1082
1082
|
error: error.message,
|
|
1083
1083
|
});
|
|
@@ -1089,7 +1089,7 @@ class TaskSpawner {
|
|
|
1089
1089
|
// Handle known WebSocket shutdown race condition (similar to Python version)
|
|
1090
1090
|
if (error.message.includes("await wasn't used with future") ||
|
|
1091
1091
|
error.message.includes('WebSocket closed during receive')) {
|
|
1092
|
-
logger$
|
|
1092
|
+
logger$1h.debug('task_shutdown_race_condition_handled', {
|
|
1093
1093
|
task_name: taskName,
|
|
1094
1094
|
note: 'Normal WebSocket close timing during shutdown - not an error',
|
|
1095
1095
|
});
|
|
@@ -1099,7 +1099,7 @@ class TaskSpawner {
|
|
|
1099
1099
|
if (error.name === 'FameTransportClose' ||
|
|
1100
1100
|
error.message.includes('normal closure') ||
|
|
1101
1101
|
error.message.includes('Connection closed')) {
|
|
1102
|
-
logger$
|
|
1102
|
+
logger$1h.debug('task_shutdown_completed_normally', {
|
|
1103
1103
|
task_name: taskName,
|
|
1104
1104
|
note: 'Task closed normally during shutdown',
|
|
1105
1105
|
});
|
|
@@ -1107,7 +1107,7 @@ class TaskSpawner {
|
|
|
1107
1107
|
}
|
|
1108
1108
|
// Handle PKCE redirect "errors" as info
|
|
1109
1109
|
if (error.name === 'OAuth2PkceRedirectInitiatedError') {
|
|
1110
|
-
logger$
|
|
1110
|
+
logger$1h.debug('background_task_redirecting', {
|
|
1111
1111
|
task_name: taskName,
|
|
1112
1112
|
note: 'Task interrupted for PKCE redirect',
|
|
1113
1113
|
});
|
|
@@ -1120,14 +1120,14 @@ class TaskSpawner {
|
|
|
1120
1120
|
// Log retriable errors as warnings (they'll be retried by upstream logic)
|
|
1121
1121
|
// Log non-retriable errors as errors (fatal failures)
|
|
1122
1122
|
if (isRetriableError) {
|
|
1123
|
-
logger$
|
|
1123
|
+
logger$1h.warning('background_task_failed', {
|
|
1124
1124
|
task_name: taskName,
|
|
1125
1125
|
error: error.message,
|
|
1126
1126
|
retriable: true,
|
|
1127
1127
|
});
|
|
1128
1128
|
}
|
|
1129
1129
|
else {
|
|
1130
|
-
logger$
|
|
1130
|
+
logger$1h.error('background_task_failed', {
|
|
1131
1131
|
task_name: taskName,
|
|
1132
1132
|
error: error.message,
|
|
1133
1133
|
stack: error.stack,
|
|
@@ -1146,11 +1146,11 @@ class TaskSpawner {
|
|
|
1146
1146
|
async shutdownTasks(options = {}) {
|
|
1147
1147
|
const { gracePeriod, cancelHanging, joinTimeout } = normalizeShutdownOptions(options);
|
|
1148
1148
|
if (this._tasks.size === 0) {
|
|
1149
|
-
logger$
|
|
1149
|
+
logger$1h.debug('shutdown_tasks_no_tasks_to_shutdown');
|
|
1150
1150
|
return;
|
|
1151
1151
|
}
|
|
1152
1152
|
this._suppressCompletionLogging = true;
|
|
1153
|
-
logger$
|
|
1153
|
+
logger$1h.debug('shutting_down_tasks', {
|
|
1154
1154
|
task_count: this._tasks.size,
|
|
1155
1155
|
task_names: Array.from(this._tasks.values()).map((t) => t.name),
|
|
1156
1156
|
grace_period_ms: gracePeriod,
|
|
@@ -1165,7 +1165,7 @@ class TaskSpawner {
|
|
|
1165
1165
|
if (cancelHanging) {
|
|
1166
1166
|
const stillRunning = tasks.filter((task) => task.getState() === TaskState.RUNNING && !completed.has(task));
|
|
1167
1167
|
if (stillRunning.length > 0) {
|
|
1168
|
-
logger$
|
|
1168
|
+
logger$1h.debug('tasks_did_not_complete_within_grace_period', {
|
|
1169
1169
|
hanging_count: stillRunning.length,
|
|
1170
1170
|
});
|
|
1171
1171
|
// Wait for them to finish with individual timeouts
|
|
@@ -1175,7 +1175,7 @@ class TaskSpawner {
|
|
|
1175
1175
|
}
|
|
1176
1176
|
catch (error) {
|
|
1177
1177
|
if (error instanceof TaskTimeoutError) {
|
|
1178
|
-
logger$
|
|
1178
|
+
logger$1h.warning('task_did_not_shutdown', {
|
|
1179
1179
|
task_name: task.name || task.id,
|
|
1180
1180
|
join_timeout_ms: joinTimeout,
|
|
1181
1181
|
});
|
|
@@ -1186,7 +1186,7 @@ class TaskSpawner {
|
|
|
1186
1186
|
}
|
|
1187
1187
|
else if (!(error instanceof TaskCancelledError)) {
|
|
1188
1188
|
/* istanbul ignore next - unreachable defensive branch */
|
|
1189
|
-
logger$
|
|
1189
|
+
logger$1h.error('task_raised_during_cancellation', {
|
|
1190
1190
|
task_name: task.name || task.id,
|
|
1191
1191
|
error: error instanceof Error ? error.message : String(error),
|
|
1192
1192
|
});
|
|
@@ -2323,7 +2323,7 @@ async function safeImport(loader, dependencyNameOrOptions, maybeOptions) {
|
|
|
2323
2323
|
* condition/promise and ensure at most one notifier coroutine exists for a
|
|
2324
2324
|
* flow at any time.
|
|
2325
2325
|
*/
|
|
2326
|
-
const logger$
|
|
2326
|
+
const logger$1g = getLogger('naylence.fame.flow.flow_controller');
|
|
2327
2327
|
/**
|
|
2328
2328
|
* Simple condition variable implementation for TypeScript/Node.js
|
|
2329
2329
|
* Similar to Python's asyncio.Condition
|
|
@@ -2457,7 +2457,7 @@ class FlowController {
|
|
|
2457
2457
|
const newBalance = Math.max(0, Math.min(this.initialWindow, prev + delta));
|
|
2458
2458
|
this.credits.set(flowId, newBalance);
|
|
2459
2459
|
const crossedZero = prev <= 0 && newBalance > 0;
|
|
2460
|
-
logger$
|
|
2460
|
+
logger$1g.debug('flow_controller_add_credits', {
|
|
2461
2461
|
flow_id: flowId,
|
|
2462
2462
|
delta,
|
|
2463
2463
|
prev_balance: prev,
|
|
@@ -2477,12 +2477,12 @@ class FlowController {
|
|
|
2477
2477
|
async acquire(flowId) {
|
|
2478
2478
|
this.ensureFlow(flowId);
|
|
2479
2479
|
const condition = this.conditions.get(flowId);
|
|
2480
|
-
logger$
|
|
2480
|
+
logger$1g.debug('flow_controller_acquire_attempt', {
|
|
2481
2481
|
flow_id: flowId,
|
|
2482
2482
|
current_balance: this.credits.get(flowId),
|
|
2483
2483
|
});
|
|
2484
2484
|
while (this.credits.get(flowId) <= 0) {
|
|
2485
|
-
logger$
|
|
2485
|
+
logger$1g.debug('flow_controller_waiting_for_credits', {
|
|
2486
2486
|
flow_id: flowId,
|
|
2487
2487
|
current_balance: this.credits.get(flowId),
|
|
2488
2488
|
});
|
|
@@ -2490,12 +2490,12 @@ class FlowController {
|
|
|
2490
2490
|
}
|
|
2491
2491
|
const newBalance = this.credits.get(flowId) - 1;
|
|
2492
2492
|
this.credits.set(flowId, newBalance);
|
|
2493
|
-
logger$
|
|
2493
|
+
logger$1g.debug('flow_controller_acquire_success', {
|
|
2494
2494
|
flow_id: flowId,
|
|
2495
2495
|
new_balance: newBalance,
|
|
2496
2496
|
});
|
|
2497
2497
|
if (newBalance <= this.lowWatermark) {
|
|
2498
|
-
logger$
|
|
2498
|
+
logger$1g.debug('flow_controller_acquire_below_low_watermark', {
|
|
2499
2499
|
flow_id: flowId,
|
|
2500
2500
|
low_watermark: this.lowWatermark,
|
|
2501
2501
|
});
|
|
@@ -2519,7 +2519,7 @@ class FlowController {
|
|
|
2519
2519
|
const current = this.credits.get(flowId);
|
|
2520
2520
|
const remaining = Math.max(current - credits, 0);
|
|
2521
2521
|
this.credits.set(flowId, remaining);
|
|
2522
|
-
logger$
|
|
2522
|
+
logger$1g.debug('flow_controller_consume', {
|
|
2523
2523
|
flow_id: flowId,
|
|
2524
2524
|
requested: credits,
|
|
2525
2525
|
prev_balance: current,
|
|
@@ -2545,7 +2545,7 @@ class FlowController {
|
|
|
2545
2545
|
this.windowIds.delete(flowId);
|
|
2546
2546
|
this.credits.set(flowId, this.initialWindow);
|
|
2547
2547
|
this.wakeWaiters(flowId);
|
|
2548
|
-
logger$
|
|
2548
|
+
logger$1g.debug('flow_controller_flow_reset', {
|
|
2549
2549
|
flow_id: flowId,
|
|
2550
2550
|
reset_balance: this.initialWindow,
|
|
2551
2551
|
});
|
|
@@ -2833,7 +2833,7 @@ class InMemoryBinding {
|
|
|
2833
2833
|
* TypeScript port of Python's InMemoryFanoutBroker that extends TaskSpawner
|
|
2834
2834
|
* to manage multiple WriteChannel subscribers with concurrent message distribution.
|
|
2835
2835
|
*/
|
|
2836
|
-
const logger$
|
|
2836
|
+
const logger$1f = getLogger('naylence.fame.channel.in_memory.in_memory_fanout_broker');
|
|
2837
2837
|
// Sentinel object for shutdown signaling
|
|
2838
2838
|
const SENTINEL = Symbol('fanout-broker-sentinel');
|
|
2839
2839
|
function isCloseable(obj) {
|
|
@@ -2886,7 +2886,7 @@ class InMemoryFanoutBroker extends TaskSpawner {
|
|
|
2886
2886
|
}
|
|
2887
2887
|
catch (error) {
|
|
2888
2888
|
// Ignore errors when sending sentinel (sink might be closed)
|
|
2889
|
-
logger$
|
|
2889
|
+
logger$1f.debug('error_sending_sentinel', {
|
|
2890
2890
|
error: error.message,
|
|
2891
2891
|
});
|
|
2892
2892
|
}
|
|
@@ -2900,7 +2900,7 @@ class InMemoryFanoutBroker extends TaskSpawner {
|
|
|
2900
2900
|
await sub.close();
|
|
2901
2901
|
}
|
|
2902
2902
|
catch (error) {
|
|
2903
|
-
logger$
|
|
2903
|
+
logger$1f.error('error_closing_subscriber', {
|
|
2904
2904
|
subscriber: sub.toString(),
|
|
2905
2905
|
error: error.message,
|
|
2906
2906
|
});
|
|
@@ -2940,7 +2940,7 @@ class InMemoryFanoutBroker extends TaskSpawner {
|
|
|
2940
2940
|
[envelope, context] = core.extractEnvelopeAndContext(msg);
|
|
2941
2941
|
}
|
|
2942
2942
|
catch (error) {
|
|
2943
|
-
logger$
|
|
2943
|
+
logger$1f.debug('failed_to_extract_envelope', {
|
|
2944
2944
|
error: error.message,
|
|
2945
2945
|
});
|
|
2946
2946
|
continue;
|
|
@@ -2962,7 +2962,7 @@ class InMemoryFanoutBroker extends TaskSpawner {
|
|
|
2962
2962
|
await sub.send(messageToSend);
|
|
2963
2963
|
}
|
|
2964
2964
|
catch (error) {
|
|
2965
|
-
logger$
|
|
2965
|
+
logger$1f.error('error_sending_to_subscriber', {
|
|
2966
2966
|
subscriber: sub.toString(),
|
|
2967
2967
|
error: error.message,
|
|
2968
2968
|
action: 'unsubscribing',
|
|
@@ -2978,7 +2978,7 @@ class InMemoryFanoutBroker extends TaskSpawner {
|
|
|
2978
2978
|
}
|
|
2979
2979
|
catch (error) {
|
|
2980
2980
|
// Critical broker-level error: log and back off, but keep the loop running
|
|
2981
|
-
logger$
|
|
2981
|
+
logger$1f.critical('receive_loop_failed_unexpectedly', {
|
|
2982
2982
|
error: error.message,
|
|
2983
2983
|
stack: error.stack,
|
|
2984
2984
|
});
|
|
@@ -3196,7 +3196,7 @@ class EnvCredentialProviderFactory extends CredentialProviderFactory {
|
|
|
3196
3196
|
return new EnvCredentialProvider(resolved.varName);
|
|
3197
3197
|
}
|
|
3198
3198
|
}
|
|
3199
|
-
const FACTORY_META$
|
|
3199
|
+
const FACTORY_META$1c = {
|
|
3200
3200
|
base: CREDENTIAL_PROVIDER_FACTORY_BASE_TYPE,
|
|
3201
3201
|
key: 'EnvCredentialProvider',
|
|
3202
3202
|
};
|
|
@@ -3204,7 +3204,7 @@ const FACTORY_META$1b = {
|
|
|
3204
3204
|
var envCredentialProviderFactory = /*#__PURE__*/Object.freeze({
|
|
3205
3205
|
__proto__: null,
|
|
3206
3206
|
EnvCredentialProviderFactory: EnvCredentialProviderFactory,
|
|
3207
|
-
FACTORY_META: FACTORY_META$
|
|
3207
|
+
FACTORY_META: FACTORY_META$1c,
|
|
3208
3208
|
default: EnvCredentialProviderFactory,
|
|
3209
3209
|
normalizeEnvConfig: normalizeEnvConfig
|
|
3210
3210
|
});
|
|
@@ -3302,14 +3302,14 @@ class PromptCredentialProviderFactory extends CredentialProviderFactory {
|
|
|
3302
3302
|
return new PromptCredentialProvider(resolved.credentialName);
|
|
3303
3303
|
}
|
|
3304
3304
|
}
|
|
3305
|
-
const FACTORY_META$
|
|
3305
|
+
const FACTORY_META$1b = {
|
|
3306
3306
|
base: CREDENTIAL_PROVIDER_FACTORY_BASE_TYPE,
|
|
3307
3307
|
key: 'PromptCredentialProvider',
|
|
3308
3308
|
};
|
|
3309
3309
|
|
|
3310
3310
|
var promptCredentialProviderFactory = /*#__PURE__*/Object.freeze({
|
|
3311
3311
|
__proto__: null,
|
|
3312
|
-
FACTORY_META: FACTORY_META$
|
|
3312
|
+
FACTORY_META: FACTORY_META$1b,
|
|
3313
3313
|
PromptCredentialProviderFactory: PromptCredentialProviderFactory,
|
|
3314
3314
|
default: PromptCredentialProviderFactory,
|
|
3315
3315
|
normalizePromptConfig: normalizePromptConfig
|
|
@@ -3363,14 +3363,14 @@ class SecretStoreCredentialProviderFactory extends CredentialProviderFactory {
|
|
|
3363
3363
|
return new SecretStoreCredentialProvider(resolved.secretName);
|
|
3364
3364
|
}
|
|
3365
3365
|
}
|
|
3366
|
-
const FACTORY_META$
|
|
3366
|
+
const FACTORY_META$1a = {
|
|
3367
3367
|
base: CREDENTIAL_PROVIDER_FACTORY_BASE_TYPE,
|
|
3368
3368
|
key: 'SecretStoreCredentialProvider',
|
|
3369
3369
|
};
|
|
3370
3370
|
|
|
3371
3371
|
var secretStoreCredentialProviderFactory = /*#__PURE__*/Object.freeze({
|
|
3372
3372
|
__proto__: null,
|
|
3373
|
-
FACTORY_META: FACTORY_META$
|
|
3373
|
+
FACTORY_META: FACTORY_META$1a,
|
|
3374
3374
|
SecretStoreCredentialProviderFactory: SecretStoreCredentialProviderFactory,
|
|
3375
3375
|
default: SecretStoreCredentialProviderFactory,
|
|
3376
3376
|
normalizeSecretStoreConfig: normalizeSecretStoreConfig
|
|
@@ -3419,14 +3419,14 @@ class StaticCredentialProviderFactory extends CredentialProviderFactory {
|
|
|
3419
3419
|
return new StaticCredentialProvider(resolved.credentialValue);
|
|
3420
3420
|
}
|
|
3421
3421
|
}
|
|
3422
|
-
const FACTORY_META$
|
|
3422
|
+
const FACTORY_META$19 = {
|
|
3423
3423
|
base: CREDENTIAL_PROVIDER_FACTORY_BASE_TYPE,
|
|
3424
3424
|
key: 'StaticCredentialProvider',
|
|
3425
3425
|
};
|
|
3426
3426
|
|
|
3427
3427
|
var staticCredentialProviderFactory = /*#__PURE__*/Object.freeze({
|
|
3428
3428
|
__proto__: null,
|
|
3429
|
-
FACTORY_META: FACTORY_META$
|
|
3429
|
+
FACTORY_META: FACTORY_META$19,
|
|
3430
3430
|
StaticCredentialProviderFactory: StaticCredentialProviderFactory,
|
|
3431
3431
|
default: StaticCredentialProviderFactory,
|
|
3432
3432
|
normalizeStaticConfig: normalizeStaticConfig
|
|
@@ -4654,7 +4654,7 @@ function normalizeResponseType(value) {
|
|
|
4654
4654
|
return value;
|
|
4655
4655
|
}
|
|
4656
4656
|
|
|
4657
|
-
const logger$
|
|
4657
|
+
const logger$1e = getLogger('naylence.fame.node.binding_manager');
|
|
4658
4658
|
const SYSTEM_INBOX$3 = '__sys__';
|
|
4659
4659
|
const DEFAULT_ACK_TIMEOUT_MS = 20000;
|
|
4660
4660
|
class BindingStoreEntryRecord {
|
|
@@ -4740,7 +4740,7 @@ class BindingManager {
|
|
|
4740
4740
|
if (!this.bindings.has(key)) {
|
|
4741
4741
|
const binding = this.bindingFactory(new core.FameAddress(key));
|
|
4742
4742
|
this.bindings.set(key, binding);
|
|
4743
|
-
logger$
|
|
4743
|
+
logger$1e.debug('restored_binding', { address: key });
|
|
4744
4744
|
}
|
|
4745
4745
|
}
|
|
4746
4746
|
if (!this.hasUpstream) {
|
|
@@ -4750,13 +4750,13 @@ class BindingManager {
|
|
|
4750
4750
|
await this.readvertiseCapabilitiesUpstream();
|
|
4751
4751
|
}
|
|
4752
4752
|
async bind(participant, capabilities) {
|
|
4753
|
-
logger$
|
|
4753
|
+
logger$1e.debug('binding_participant', { participant });
|
|
4754
4754
|
const { prefixAddress, addresses, propagateAddress, capabilityAddress } = this.computeBindingAddresses(participant);
|
|
4755
4755
|
for (const address of addresses) {
|
|
4756
4756
|
if (!this.bindings.has(address)) {
|
|
4757
4757
|
const binding = this.bindingFactory(new core.FameAddress(address));
|
|
4758
4758
|
this.bindings.set(address, binding);
|
|
4759
|
-
logger$
|
|
4759
|
+
logger$1e.debug('bound_address', { address, participant });
|
|
4760
4760
|
}
|
|
4761
4761
|
}
|
|
4762
4762
|
let propagatedAddress = null;
|
|
@@ -4785,7 +4785,7 @@ class BindingManager {
|
|
|
4785
4785
|
await this.unbindAddressUpstream(propagatedAddress);
|
|
4786
4786
|
}
|
|
4787
4787
|
catch (rollbackError) {
|
|
4788
|
-
logger$
|
|
4788
|
+
logger$1e.error('bind_rollback_failed', {
|
|
4789
4789
|
address: propagatedAddress.toString(),
|
|
4790
4790
|
error: rollbackError.message,
|
|
4791
4791
|
});
|
|
@@ -4804,7 +4804,7 @@ class BindingManager {
|
|
|
4804
4804
|
physicalPath: null,
|
|
4805
4805
|
});
|
|
4806
4806
|
}
|
|
4807
|
-
logger$
|
|
4807
|
+
logger$1e.debug('bind_success', {
|
|
4808
4808
|
participant,
|
|
4809
4809
|
address: prefixAddress.toString(),
|
|
4810
4810
|
capabilities,
|
|
@@ -4840,7 +4840,7 @@ class BindingManager {
|
|
|
4840
4840
|
await this.bindingStore.delete(address);
|
|
4841
4841
|
}
|
|
4842
4842
|
}
|
|
4843
|
-
logger$
|
|
4843
|
+
logger$1e.debug('unbind_success', {
|
|
4844
4844
|
participant,
|
|
4845
4845
|
address: prefixAddress.toString(),
|
|
4846
4846
|
totalBindings: this.bindings.size,
|
|
@@ -4870,7 +4870,7 @@ class BindingManager {
|
|
|
4870
4870
|
await this.bindAddressUpstream(new core.FameAddress(address));
|
|
4871
4871
|
}
|
|
4872
4872
|
catch (error) {
|
|
4873
|
-
logger$
|
|
4873
|
+
logger$1e.error('rebind_failed', {
|
|
4874
4874
|
address,
|
|
4875
4875
|
error: error.message,
|
|
4876
4876
|
});
|
|
@@ -4889,7 +4889,7 @@ class BindingManager {
|
|
|
4889
4889
|
await this.advertiseCapabilities(new core.FameAddress(address), Array.from(capabilities));
|
|
4890
4890
|
}
|
|
4891
4891
|
catch (error) {
|
|
4892
|
-
logger$
|
|
4892
|
+
logger$1e.error('capability_replay_failed', {
|
|
4893
4893
|
address,
|
|
4894
4894
|
error: error.message,
|
|
4895
4895
|
});
|
|
@@ -5156,7 +5156,7 @@ class BindingManager {
|
|
|
5156
5156
|
}
|
|
5157
5157
|
}
|
|
5158
5158
|
|
|
5159
|
-
const logger$
|
|
5159
|
+
const logger$1d = getLogger('naylence.fame.node.response_context_manager');
|
|
5160
5160
|
function cloneSecurityContext(source) {
|
|
5161
5161
|
if (!source) {
|
|
5162
5162
|
return undefined;
|
|
@@ -5184,7 +5184,7 @@ class ResponseContextManager {
|
|
|
5184
5184
|
security: responseSecurity,
|
|
5185
5185
|
expectedResponseType: core.FameResponseType.NONE,
|
|
5186
5186
|
};
|
|
5187
|
-
logger$
|
|
5187
|
+
logger$1d.debug('created_response_context', {
|
|
5188
5188
|
request_id: requestEnvelope.id,
|
|
5189
5189
|
inherited_crypto_level: responseSecurity?.inboundCryptoLevel ?? null,
|
|
5190
5190
|
channel_id: responseSecurity?.cryptoChannelId ?? null,
|
|
@@ -5204,14 +5204,14 @@ class ResponseContextManager {
|
|
|
5204
5204
|
responseContext.fromSystemId = this.getId();
|
|
5205
5205
|
}
|
|
5206
5206
|
// Envelope-level metadata is intentionally omitted to defer to context usage.
|
|
5207
|
-
logger$
|
|
5207
|
+
logger$1d.debug('ensured_response_metadata', {
|
|
5208
5208
|
response_id: responseEnvelope.id,
|
|
5209
5209
|
request_id: requestEnvelope.id,
|
|
5210
5210
|
});
|
|
5211
5211
|
}
|
|
5212
5212
|
}
|
|
5213
5213
|
|
|
5214
|
-
const logger$
|
|
5214
|
+
const logger$1c = getLogger('naylence.fame.node.streaming_response_handler');
|
|
5215
5215
|
function isObject(value) {
|
|
5216
5216
|
return typeof value === 'object' && value !== null;
|
|
5217
5217
|
}
|
|
@@ -5330,12 +5330,12 @@ class StreamingResponseHandler {
|
|
|
5330
5330
|
}
|
|
5331
5331
|
async handleStreamingFameMessageResponses(responses, requestEnvelope, requestContext) {
|
|
5332
5332
|
const asyncResponses = toAsyncIterable(responses);
|
|
5333
|
-
logger$
|
|
5333
|
+
logger$1c.debug('handling_streaming_fame_message_responses', {
|
|
5334
5334
|
request_id: requestEnvelope.id,
|
|
5335
5335
|
});
|
|
5336
5336
|
for await (const response of asyncResponses) {
|
|
5337
5337
|
if (!response?.envelope) {
|
|
5338
|
-
logger$
|
|
5338
|
+
logger$1c.warning('invalid_streaming_response_type', {
|
|
5339
5339
|
request_id: requestEnvelope.id,
|
|
5340
5340
|
actual_type: typeof response,
|
|
5341
5341
|
});
|
|
@@ -5349,7 +5349,7 @@ class StreamingResponseHandler {
|
|
|
5349
5349
|
}
|
|
5350
5350
|
async handleStreamingResponse(result, requestEnvelope, requestContext, replyTo, requestId) {
|
|
5351
5351
|
const iterable = toAsyncIterable(result);
|
|
5352
|
-
logger$
|
|
5352
|
+
logger$1c.debug('handling_streaming_response', {
|
|
5353
5353
|
request_id: requestId,
|
|
5354
5354
|
reply_to: replyTo,
|
|
5355
5355
|
});
|
|
@@ -5360,7 +5360,7 @@ class StreamingResponseHandler {
|
|
|
5360
5360
|
await this.sendRpcResponse(null, requestEnvelope, requestContext, replyTo, requestId);
|
|
5361
5361
|
}
|
|
5362
5362
|
catch (error) {
|
|
5363
|
-
logger$
|
|
5363
|
+
logger$1c.error('streaming_response_handler_error', {
|
|
5364
5364
|
request_id: requestId,
|
|
5365
5365
|
error: error instanceof Error ? error.message : String(error),
|
|
5366
5366
|
});
|
|
@@ -5387,7 +5387,7 @@ class StreamingResponseHandler {
|
|
|
5387
5387
|
});
|
|
5388
5388
|
const responseContext = this.responseContextManager.createResponseContext(requestEnvelope, requestContext);
|
|
5389
5389
|
this.responseContextManager.ensureResponseMetadata(responseEnvelope, requestEnvelope, responseContext);
|
|
5390
|
-
logger$
|
|
5390
|
+
logger$1c.debug('sending_streaming_rpc_response', {
|
|
5391
5391
|
request_id: requestId,
|
|
5392
5392
|
response_envelope_id: responseEnvelope.id,
|
|
5393
5393
|
reply_to: replyTo,
|
|
@@ -5400,7 +5400,7 @@ class StreamingResponseHandler {
|
|
|
5400
5400
|
}
|
|
5401
5401
|
}
|
|
5402
5402
|
|
|
5403
|
-
const logger$
|
|
5403
|
+
const logger$1b = getLogger('naylence.fame.node.channel_polling_manager');
|
|
5404
5404
|
class ChannelPollingManager {
|
|
5405
5405
|
constructor(deliverWrapper, responseContextManager, streamingResponseHandler) {
|
|
5406
5406
|
this.deliverWrapper = deliverWrapper;
|
|
@@ -5408,7 +5408,7 @@ class ChannelPollingManager {
|
|
|
5408
5408
|
this.streamingResponseHandler = streamingResponseHandler;
|
|
5409
5409
|
}
|
|
5410
5410
|
async startPollingLoop(serviceName, channel, handler, stopState, pollTimeoutMs = core.DEFAULT_POLLING_TIMEOUT_MS) {
|
|
5411
|
-
logger$
|
|
5411
|
+
logger$1b.debug('poll_loop_started', {
|
|
5412
5412
|
recipient: serviceName,
|
|
5413
5413
|
});
|
|
5414
5414
|
try {
|
|
@@ -5416,7 +5416,7 @@ class ChannelPollingManager {
|
|
|
5416
5416
|
while (true) {
|
|
5417
5417
|
if (this.isStopRequested(stopState) && !draining) {
|
|
5418
5418
|
draining = true;
|
|
5419
|
-
logger$
|
|
5419
|
+
logger$1b.debug('poll_loop_draining_pending_messages', {
|
|
5420
5420
|
recipient: serviceName,
|
|
5421
5421
|
});
|
|
5422
5422
|
}
|
|
@@ -5426,7 +5426,7 @@ class ChannelPollingManager {
|
|
|
5426
5426
|
}
|
|
5427
5427
|
catch (error) {
|
|
5428
5428
|
if (error instanceof FameTransportClose) {
|
|
5429
|
-
logger$
|
|
5429
|
+
logger$1b.debug('channel_closed', {
|
|
5430
5430
|
recipient: serviceName,
|
|
5431
5431
|
message: error.message,
|
|
5432
5432
|
});
|
|
@@ -5439,7 +5439,7 @@ class ChannelPollingManager {
|
|
|
5439
5439
|
continue;
|
|
5440
5440
|
}
|
|
5441
5441
|
if (error instanceof Error && error.name === 'AbortError') {
|
|
5442
|
-
logger$
|
|
5442
|
+
logger$1b.debug('listener_cancelled', {
|
|
5443
5443
|
recipient: serviceName,
|
|
5444
5444
|
});
|
|
5445
5445
|
throw error;
|
|
@@ -5451,13 +5451,13 @@ class ChannelPollingManager {
|
|
|
5451
5451
|
continue;
|
|
5452
5452
|
}
|
|
5453
5453
|
if (error instanceof Error && error.message === 'Channel is closed') {
|
|
5454
|
-
logger$
|
|
5454
|
+
logger$1b.debug('channel_closed', {
|
|
5455
5455
|
recipient: serviceName,
|
|
5456
5456
|
});
|
|
5457
5457
|
break;
|
|
5458
5458
|
}
|
|
5459
5459
|
if (error instanceof Error && error.name === 'TaskCancelledError') {
|
|
5460
|
-
logger$
|
|
5460
|
+
logger$1b.debug('listener_cancelled', {
|
|
5461
5461
|
recipient: serviceName,
|
|
5462
5462
|
});
|
|
5463
5463
|
throw error;
|
|
@@ -5469,12 +5469,12 @@ class ChannelPollingManager {
|
|
|
5469
5469
|
continue;
|
|
5470
5470
|
}
|
|
5471
5471
|
if (error instanceof Error && error.message.includes('closed')) {
|
|
5472
|
-
logger$
|
|
5472
|
+
logger$1b.debug('channel_closed', {
|
|
5473
5473
|
recipient: serviceName,
|
|
5474
5474
|
});
|
|
5475
5475
|
break;
|
|
5476
5476
|
}
|
|
5477
|
-
logger$
|
|
5477
|
+
logger$1b.error('transport_error', {
|
|
5478
5478
|
recipient: serviceName,
|
|
5479
5479
|
error: error instanceof Error ? error.message : String(error),
|
|
5480
5480
|
});
|
|
@@ -5490,7 +5490,7 @@ class ChannelPollingManager {
|
|
|
5490
5490
|
}
|
|
5491
5491
|
}
|
|
5492
5492
|
finally {
|
|
5493
|
-
logger$
|
|
5493
|
+
logger$1b.debug('poll_loop_exiting', {
|
|
5494
5494
|
recipient: serviceName,
|
|
5495
5495
|
});
|
|
5496
5496
|
}
|
|
@@ -5503,7 +5503,7 @@ class ChannelPollingManager {
|
|
|
5503
5503
|
await this.processHandlerResult(result, envelope, deliveryContext, serviceName);
|
|
5504
5504
|
}
|
|
5505
5505
|
catch (error) {
|
|
5506
|
-
logger$
|
|
5506
|
+
logger$1b.error('handler_crashed', {
|
|
5507
5507
|
recipient: serviceName,
|
|
5508
5508
|
error: error instanceof Error ? error.message : String(error),
|
|
5509
5509
|
});
|
|
@@ -5517,7 +5517,7 @@ class ChannelPollingManager {
|
|
|
5517
5517
|
return;
|
|
5518
5518
|
}
|
|
5519
5519
|
if (this.streamingResponseHandler.isStreamingFameMessageResponse(result)) {
|
|
5520
|
-
logger$
|
|
5520
|
+
logger$1b.debug('handling_streaming_fame_message_responses', {
|
|
5521
5521
|
service_name: serviceName,
|
|
5522
5522
|
envelope_id: envelope.id,
|
|
5523
5523
|
});
|
|
@@ -5525,7 +5525,7 @@ class ChannelPollingManager {
|
|
|
5525
5525
|
}
|
|
5526
5526
|
}
|
|
5527
5527
|
async handleMessageResponse(response, requestEnvelope, requestContext, serviceName) {
|
|
5528
|
-
logger$
|
|
5528
|
+
logger$1b.debug('delivering_envelope_response_message', {
|
|
5529
5529
|
service_name: serviceName,
|
|
5530
5530
|
response_envelope_id: response.envelope.id,
|
|
5531
5531
|
});
|
|
@@ -5545,7 +5545,7 @@ class ChannelPollingManager {
|
|
|
5545
5545
|
}
|
|
5546
5546
|
}
|
|
5547
5547
|
|
|
5548
|
-
const logger$
|
|
5548
|
+
const logger$1a = getLogger('naylence.fame.node.rpc_server_handler');
|
|
5549
5549
|
function isPlainRecord$6(value) {
|
|
5550
5550
|
if (typeof value !== 'object' || value === null) {
|
|
5551
5551
|
return false;
|
|
@@ -5589,13 +5589,13 @@ class RPCServerHandler {
|
|
|
5589
5589
|
}
|
|
5590
5590
|
async handleRpcRequest(envelope, handlerContext, handler, serviceName) {
|
|
5591
5591
|
if (!this.isDataFrame(envelope.frame)) {
|
|
5592
|
-
logger$
|
|
5592
|
+
logger$1a.warning('rpc_request_missing_data_frame', {
|
|
5593
5593
|
service_name: serviceName,
|
|
5594
5594
|
envelope_id: envelope.id,
|
|
5595
5595
|
});
|
|
5596
5596
|
return;
|
|
5597
5597
|
}
|
|
5598
|
-
logger$
|
|
5598
|
+
logger$1a.debug('rpc_request_received', {
|
|
5599
5599
|
service_name: serviceName,
|
|
5600
5600
|
envelope_id: envelope.id,
|
|
5601
5601
|
trace_id: envelope.traceId,
|
|
@@ -5607,7 +5607,7 @@ class RPCServerHandler {
|
|
|
5607
5607
|
request = core.parseRequest(envelope.frame.payload);
|
|
5608
5608
|
params = cloneParams(request.params);
|
|
5609
5609
|
const paramKeys = Object.keys(params);
|
|
5610
|
-
logger$
|
|
5610
|
+
logger$1a.debug('parsed_rpc_request', {
|
|
5611
5611
|
service_name: serviceName,
|
|
5612
5612
|
method: request.method,
|
|
5613
5613
|
request_id: request.id,
|
|
@@ -5616,7 +5616,7 @@ class RPCServerHandler {
|
|
|
5616
5616
|
});
|
|
5617
5617
|
}
|
|
5618
5618
|
catch (error) {
|
|
5619
|
-
logger$
|
|
5619
|
+
logger$1a.warning('request_decode_error', {
|
|
5620
5620
|
service_name: serviceName,
|
|
5621
5621
|
envelope_id: envelope.id,
|
|
5622
5622
|
error: error instanceof Error ? error.message : String(error),
|
|
@@ -5624,7 +5624,7 @@ class RPCServerHandler {
|
|
|
5624
5624
|
return;
|
|
5625
5625
|
}
|
|
5626
5626
|
if (request.id == null) {
|
|
5627
|
-
logger$
|
|
5627
|
+
logger$1a.warning('request_missing_id', {
|
|
5628
5628
|
service_name: serviceName,
|
|
5629
5629
|
envelope_id: envelope.id,
|
|
5630
5630
|
});
|
|
@@ -5632,7 +5632,7 @@ class RPCServerHandler {
|
|
|
5632
5632
|
}
|
|
5633
5633
|
const replyTo = this.resolveReplyTo(envelope, params);
|
|
5634
5634
|
if (!replyTo) {
|
|
5635
|
-
logger$
|
|
5635
|
+
logger$1a.warning('missing_reply_to', {
|
|
5636
5636
|
service_name: serviceName,
|
|
5637
5637
|
envelope_id: envelope.id,
|
|
5638
5638
|
request_id: request.id,
|
|
@@ -5641,13 +5641,13 @@ class RPCServerHandler {
|
|
|
5641
5641
|
}
|
|
5642
5642
|
let handlerResult;
|
|
5643
5643
|
try {
|
|
5644
|
-
logger$
|
|
5644
|
+
logger$1a.debug('calling_rpc_handler', {
|
|
5645
5645
|
service_name: serviceName,
|
|
5646
5646
|
method: request.method,
|
|
5647
5647
|
request_id: request.id,
|
|
5648
5648
|
});
|
|
5649
5649
|
handlerResult = await handler(request.method, params);
|
|
5650
|
-
logger$
|
|
5650
|
+
logger$1a.debug('rpc_handler_returned', {
|
|
5651
5651
|
service_name: serviceName,
|
|
5652
5652
|
method: request.method,
|
|
5653
5653
|
request_id: request.id,
|
|
@@ -5656,7 +5656,7 @@ class RPCServerHandler {
|
|
|
5656
5656
|
});
|
|
5657
5657
|
}
|
|
5658
5658
|
catch (error) {
|
|
5659
|
-
logger$
|
|
5659
|
+
logger$1a.error('rpc_handler_error', {
|
|
5660
5660
|
service_name: serviceName,
|
|
5661
5661
|
request_id: request.id,
|
|
5662
5662
|
envelope_id: envelope.id,
|
|
@@ -5666,7 +5666,7 @@ class RPCServerHandler {
|
|
|
5666
5666
|
return this.createTraditionalResponse(response, request.id, envelope, replyTo, handlerContext, serviceName);
|
|
5667
5667
|
}
|
|
5668
5668
|
if (core.isFameMessageResponse(handlerResult)) {
|
|
5669
|
-
logger$
|
|
5669
|
+
logger$1a.debug('returning_response_message', {
|
|
5670
5670
|
service_name: serviceName,
|
|
5671
5671
|
request_id: request.id,
|
|
5672
5672
|
response_envelope_id: handlerResult.envelope.id,
|
|
@@ -5674,7 +5674,7 @@ class RPCServerHandler {
|
|
|
5674
5674
|
return handlerResult;
|
|
5675
5675
|
}
|
|
5676
5676
|
if (this.streamingResponseHandler.isStreamingResult(handlerResult)) {
|
|
5677
|
-
logger$
|
|
5677
|
+
logger$1a.debug('handling_streaming_response', {
|
|
5678
5678
|
service_name: serviceName,
|
|
5679
5679
|
request_id: request.id,
|
|
5680
5680
|
envelope_id: envelope.id,
|
|
@@ -5703,7 +5703,7 @@ class RPCServerHandler {
|
|
|
5703
5703
|
return null;
|
|
5704
5704
|
}
|
|
5705
5705
|
async createTraditionalResponse(payload, requestId, requestEnvelope, replyTo, handlerContext, serviceName) {
|
|
5706
|
-
logger$
|
|
5706
|
+
logger$1a.debug('creating_traditional_response_envelope', {
|
|
5707
5707
|
service_name: serviceName,
|
|
5708
5708
|
request_id: requestId,
|
|
5709
5709
|
envelope_id: requestEnvelope.id,
|
|
@@ -5727,7 +5727,7 @@ class RPCServerHandler {
|
|
|
5727
5727
|
if (requestEnvelope.id) {
|
|
5728
5728
|
responseContext.meta['response-to-id'] = requestEnvelope.id;
|
|
5729
5729
|
}
|
|
5730
|
-
logger$
|
|
5730
|
+
logger$1a.debug('returning_traditional_response', {
|
|
5731
5731
|
service_name: serviceName,
|
|
5732
5732
|
request_id: requestId,
|
|
5733
5733
|
envelope_id: requestEnvelope.id,
|
|
@@ -5792,7 +5792,7 @@ function normalizeErrorCode(code) {
|
|
|
5792
5792
|
return code;
|
|
5793
5793
|
}
|
|
5794
5794
|
|
|
5795
|
-
const logger$
|
|
5795
|
+
const logger$19 = getLogger('naylence.fame.node.rpc_client_manager');
|
|
5796
5796
|
function isPlainRecord$5(value) {
|
|
5797
5797
|
if (typeof value !== 'object' || value === null) {
|
|
5798
5798
|
return false;
|
|
@@ -6009,7 +6009,7 @@ class RPCClientManager {
|
|
|
6009
6009
|
const metaReason = tracked.meta?.['nack_reason'];
|
|
6010
6010
|
const formattedMessage = formatDeliveryErrorMessage(typeof metaCode === 'string' ? metaCode : 'DELIVERY_ERROR', reason ??
|
|
6011
6011
|
(typeof metaReason === 'string' ? metaReason : undefined));
|
|
6012
|
-
logger$
|
|
6012
|
+
logger$19.debug('pending_request_rejected_by_delivery_nack', {
|
|
6013
6013
|
envelope_id: envelopeId,
|
|
6014
6014
|
request_id: requestId,
|
|
6015
6015
|
code: typeof metaCode === 'string' ? metaCode : 'DELIVERY_ERROR',
|
|
@@ -6032,7 +6032,7 @@ class RPCClientManager {
|
|
|
6032
6032
|
this.trackerWithEvents.removeEventHandler?.(this.trackerEventHandler);
|
|
6033
6033
|
}
|
|
6034
6034
|
catch (error) {
|
|
6035
|
-
logger$
|
|
6035
|
+
logger$19.debug('rpc_tracker_handler_remove_failed', {
|
|
6036
6036
|
error: error instanceof Error ? error.message : String(error),
|
|
6037
6037
|
});
|
|
6038
6038
|
}
|
|
@@ -6075,7 +6075,7 @@ class RPCClientManager {
|
|
|
6075
6075
|
this.rpcListenerAddress = await this.listenCallback(recipient, handler);
|
|
6076
6076
|
this.rpcBound = true;
|
|
6077
6077
|
this.boundPhysicalPath = currentPhysicalPath;
|
|
6078
|
-
logger$
|
|
6078
|
+
logger$19.debug('rpc_reply_listener_bound', {
|
|
6079
6079
|
reply_recipient: recipient,
|
|
6080
6080
|
reply_address: this.rpcReplyAddress?.toString(),
|
|
6081
6081
|
listener_address: this.rpcListenerAddress?.toString(),
|
|
@@ -6169,7 +6169,7 @@ class RPCClientManager {
|
|
|
6169
6169
|
const finalizePromise = this.notifyStreamClosed(envelopeId);
|
|
6170
6170
|
if (finalizePromise) {
|
|
6171
6171
|
finalizePromise.catch((notifyError) => {
|
|
6172
|
-
logger$
|
|
6172
|
+
logger$19.debug('stream_tracker_finalize_failed', {
|
|
6173
6173
|
request_id: requestId,
|
|
6174
6174
|
envelope_id: envelopeId,
|
|
6175
6175
|
error: notifyError instanceof Error
|
|
@@ -6230,7 +6230,7 @@ class RPCClientManager {
|
|
|
6230
6230
|
return iterator;
|
|
6231
6231
|
}
|
|
6232
6232
|
async sendRpcRequest(requestId, envelope, expectedResponseType, timeoutMs) {
|
|
6233
|
-
logger$
|
|
6233
|
+
logger$19.debug('sending_rpc_request', {
|
|
6234
6234
|
envp_id: envelope.id,
|
|
6235
6235
|
corr_id: envelope.corrId,
|
|
6236
6236
|
request_id: requestId,
|
|
@@ -6246,7 +6246,7 @@ class RPCClientManager {
|
|
|
6246
6246
|
}
|
|
6247
6247
|
}
|
|
6248
6248
|
catch (error) {
|
|
6249
|
-
logger$
|
|
6249
|
+
logger$19.warning('delivery_tracker_track_failed', {
|
|
6250
6250
|
request_id: requestId,
|
|
6251
6251
|
error: error instanceof Error ? error.message : String(error),
|
|
6252
6252
|
});
|
|
@@ -6259,14 +6259,14 @@ class RPCClientManager {
|
|
|
6259
6259
|
await this.deliverWrapper()(envelope, context);
|
|
6260
6260
|
}
|
|
6261
6261
|
async handleReplyEnvelope(envelope) {
|
|
6262
|
-
logger$
|
|
6262
|
+
logger$19.debug('handle_reply_envelope_received', {
|
|
6263
6263
|
envelope_id: envelope.id,
|
|
6264
6264
|
corr_id: envelope.corrId,
|
|
6265
6265
|
frame_type: envelope.frame?.['type'],
|
|
6266
6266
|
});
|
|
6267
6267
|
let requestId = envelope.corrId ?? envelope.id;
|
|
6268
6268
|
if (!requestId) {
|
|
6269
|
-
logger$
|
|
6269
|
+
logger$19.warning('reply_envelope_missing_corr_id', {
|
|
6270
6270
|
envelope_id: envelope.id,
|
|
6271
6271
|
});
|
|
6272
6272
|
return;
|
|
@@ -6284,12 +6284,12 @@ class RPCClientManager {
|
|
|
6284
6284
|
}
|
|
6285
6285
|
}
|
|
6286
6286
|
if (!entry) {
|
|
6287
|
-
logger$
|
|
6287
|
+
logger$19.debug('no_pending_request_for_reply', {
|
|
6288
6288
|
request_id: requestId,
|
|
6289
6289
|
});
|
|
6290
6290
|
return;
|
|
6291
6291
|
}
|
|
6292
|
-
logger$
|
|
6292
|
+
logger$19.debug('handle_reply_envelope', {
|
|
6293
6293
|
envelope_id: envelope.id,
|
|
6294
6294
|
request_id: requestId,
|
|
6295
6295
|
corr_id: envelope.corrId,
|
|
@@ -6302,7 +6302,7 @@ class RPCClientManager {
|
|
|
6302
6302
|
const ackIndicatesSuccess = frame.ok === true ||
|
|
6303
6303
|
(frame.ok === undefined && !frame.code && !frame.reason);
|
|
6304
6304
|
if (ackIndicatesSuccess) {
|
|
6305
|
-
logger$
|
|
6305
|
+
logger$19.debug('pending_request_delivery_acknowledged', {
|
|
6306
6306
|
request_id: requestId,
|
|
6307
6307
|
envelope_id: envelope.id,
|
|
6308
6308
|
ref_id: frame.refId ?? null,
|
|
@@ -6330,7 +6330,7 @@ class RPCClientManager {
|
|
|
6330
6330
|
entry.timer = null;
|
|
6331
6331
|
}
|
|
6332
6332
|
if (!this.isDataFrame(envelope.frame)) {
|
|
6333
|
-
logger$
|
|
6333
|
+
logger$19.warning('unexpected_reply_frame_type', {
|
|
6334
6334
|
request_id: requestId,
|
|
6335
6335
|
frame_type: envelope.frame?.['type'],
|
|
6336
6336
|
});
|
|
@@ -6396,7 +6396,7 @@ class RPCClientManager {
|
|
|
6396
6396
|
return;
|
|
6397
6397
|
}
|
|
6398
6398
|
Promise.resolve(this.deliveryTracker.onStreamItem(envelopeId, envelope)).catch((error) => {
|
|
6399
|
-
logger$
|
|
6399
|
+
logger$19.debug('stream_tracker_push_failed', {
|
|
6400
6400
|
envelope_id: envelopeId,
|
|
6401
6401
|
error: error instanceof Error ? error.message : String(error),
|
|
6402
6402
|
});
|
|
@@ -6511,7 +6511,7 @@ function normalizeMailbox(mailbox) {
|
|
|
6511
6511
|
return mailbox;
|
|
6512
6512
|
}
|
|
6513
6513
|
|
|
6514
|
-
const logger$
|
|
6514
|
+
const logger$18 = getLogger('naylence.fame.node.envelope_listener_manager');
|
|
6515
6515
|
const SYSTEM_INBOX$2 = '__sys__';
|
|
6516
6516
|
class EnvelopeListener {
|
|
6517
6517
|
constructor(stopFn, task) {
|
|
@@ -6519,7 +6519,7 @@ class EnvelopeListener {
|
|
|
6519
6519
|
this.task = task;
|
|
6520
6520
|
}
|
|
6521
6521
|
stop() {
|
|
6522
|
-
logger$
|
|
6522
|
+
logger$18.debug('stopping_listener', {
|
|
6523
6523
|
task_name: this.task.name,
|
|
6524
6524
|
});
|
|
6525
6525
|
try {
|
|
@@ -6527,7 +6527,7 @@ class EnvelopeListener {
|
|
|
6527
6527
|
if (maybeCleanup &&
|
|
6528
6528
|
typeof maybeCleanup.then === 'function') {
|
|
6529
6529
|
void maybeCleanup.catch((error) => {
|
|
6530
|
-
logger$
|
|
6530
|
+
logger$18.debug('listener_stop_cleanup_failed', {
|
|
6531
6531
|
task_name: this.task.name,
|
|
6532
6532
|
error: error instanceof Error ? error.message : String(error),
|
|
6533
6533
|
});
|
|
@@ -6535,7 +6535,7 @@ class EnvelopeListener {
|
|
|
6535
6535
|
}
|
|
6536
6536
|
}
|
|
6537
6537
|
catch (error) {
|
|
6538
|
-
logger$
|
|
6538
|
+
logger$18.debug('listener_stop_cleanup_failed', {
|
|
6539
6539
|
task_name: this.task.name,
|
|
6540
6540
|
error: error instanceof Error ? error.message : String(error),
|
|
6541
6541
|
});
|
|
@@ -6565,7 +6565,7 @@ class EnvelopeListenerManager extends TaskSpawner {
|
|
|
6565
6565
|
envelope.replyTo = core.formatAddress(SYSTEM_INBOX$2, this.nodeLike.physicalPath);
|
|
6566
6566
|
}
|
|
6567
6567
|
catch (error) {
|
|
6568
|
-
logger$
|
|
6568
|
+
logger$18.warning('default_reply_to_assignment_failed', {
|
|
6569
6569
|
envelope_id: envelope.id,
|
|
6570
6570
|
service_name: envelope.capabilities?.[0] ?? null,
|
|
6571
6571
|
error: error instanceof Error ? error.message : String(error),
|
|
@@ -6590,7 +6590,7 @@ class EnvelopeListenerManager extends TaskSpawner {
|
|
|
6590
6590
|
if (serviceName === SYSTEM_INBOX$2) {
|
|
6591
6591
|
continue;
|
|
6592
6592
|
}
|
|
6593
|
-
logger$
|
|
6593
|
+
logger$18.debug('stopping_listener_for_service', {
|
|
6594
6594
|
service_name: serviceName,
|
|
6595
6595
|
});
|
|
6596
6596
|
entry.listener.stop();
|
|
@@ -6600,7 +6600,7 @@ class EnvelopeListenerManager extends TaskSpawner {
|
|
|
6600
6600
|
catch (error) {
|
|
6601
6601
|
if (!(error instanceof Error) ||
|
|
6602
6602
|
error.name !== 'TaskCancelledError') {
|
|
6603
|
-
logger$
|
|
6603
|
+
logger$18.debug('listener_task_stopped', {
|
|
6604
6604
|
service_name: serviceName,
|
|
6605
6605
|
error: error instanceof Error ? error.message : String(error),
|
|
6606
6606
|
});
|
|
@@ -6608,7 +6608,7 @@ class EnvelopeListenerManager extends TaskSpawner {
|
|
|
6608
6608
|
}
|
|
6609
6609
|
}
|
|
6610
6610
|
if (systemEntry) {
|
|
6611
|
-
logger$
|
|
6611
|
+
logger$18.debug('stopping_listener_for_service', {
|
|
6612
6612
|
service_name: SYSTEM_INBOX$2,
|
|
6613
6613
|
});
|
|
6614
6614
|
systemEntry.listener.stop();
|
|
@@ -6618,7 +6618,7 @@ class EnvelopeListenerManager extends TaskSpawner {
|
|
|
6618
6618
|
catch (error) {
|
|
6619
6619
|
if (!(error instanceof Error) ||
|
|
6620
6620
|
error.name !== 'TaskCancelledError') {
|
|
6621
|
-
logger$
|
|
6621
|
+
logger$18.debug('listener_task_stopped', {
|
|
6622
6622
|
service_name: SYSTEM_INBOX$2,
|
|
6623
6623
|
error: error instanceof Error ? error.message : String(error),
|
|
6624
6624
|
});
|
|
@@ -6635,13 +6635,13 @@ class EnvelopeListenerManager extends TaskSpawner {
|
|
|
6635
6635
|
}
|
|
6636
6636
|
async recoverUnhandledInboundEnvelopes() {
|
|
6637
6637
|
if (typeof this.deliveryTracker.listInbound !== 'function') {
|
|
6638
|
-
logger$
|
|
6638
|
+
logger$18.debug('delivery_tracker_missing_inbound_listing');
|
|
6639
6639
|
return;
|
|
6640
6640
|
}
|
|
6641
6641
|
const failedInbound = await this.deliveryTracker.listInbound((env) => env.status === EnvelopeStatus.RECEIVED ||
|
|
6642
6642
|
env.status === EnvelopeStatus.FAILED_TO_HANDLE);
|
|
6643
6643
|
if (!failedInbound.length) {
|
|
6644
|
-
logger$
|
|
6644
|
+
logger$18.debug('no_failed_inbound_envelopes_to_recover');
|
|
6645
6645
|
return;
|
|
6646
6646
|
}
|
|
6647
6647
|
const grouped = new Map();
|
|
@@ -6658,7 +6658,7 @@ class EnvelopeListenerManager extends TaskSpawner {
|
|
|
6658
6658
|
this.pendingRecoveryEnvelopes.set(serviceName, envelopes);
|
|
6659
6659
|
}
|
|
6660
6660
|
});
|
|
6661
|
-
logger$
|
|
6661
|
+
logger$18.debug('discovered_failed_inbound_envelopes', {
|
|
6662
6662
|
total: failedInbound.length,
|
|
6663
6663
|
services: Array.from(grouped.keys()),
|
|
6664
6664
|
});
|
|
@@ -6668,7 +6668,7 @@ class EnvelopeListenerManager extends TaskSpawner {
|
|
|
6668
6668
|
const pollTimeoutMs = options.pollTimeoutMs ??
|
|
6669
6669
|
options.poll_timeout_ms ??
|
|
6670
6670
|
core.DEFAULT_POLLING_TIMEOUT_MS;
|
|
6671
|
-
logger$
|
|
6671
|
+
logger$18.debug('listen_start', {
|
|
6672
6672
|
recipient: serviceName,
|
|
6673
6673
|
poll_timeout_ms: pollTimeoutMs ?? core.DEFAULT_POLLING_TIMEOUT_MS,
|
|
6674
6674
|
});
|
|
@@ -6699,7 +6699,7 @@ class EnvelopeListenerManager extends TaskSpawner {
|
|
|
6699
6699
|
tracked?.mailboxType === MailboxType.OUTBOX ||
|
|
6700
6700
|
envelope.frame?.['type'] === 'DeliveryAck';
|
|
6701
6701
|
if (!shouldInvoke) {
|
|
6702
|
-
logger$
|
|
6702
|
+
logger$18.debug('skipping_listener_handler', {
|
|
6703
6703
|
recipient: serviceName,
|
|
6704
6704
|
envelope_id: envelope.id,
|
|
6705
6705
|
tracked_status: tracked?.status,
|
|
@@ -6713,13 +6713,13 @@ class EnvelopeListenerManager extends TaskSpawner {
|
|
|
6713
6713
|
? undefined
|
|
6714
6714
|
: (tracked ?? undefined);
|
|
6715
6715
|
if (trackedForHandler && trackedForHandler.attempt > 0) {
|
|
6716
|
-
logger$
|
|
6716
|
+
logger$18.info('resuming_handler_retry_after_restart', {
|
|
6717
6717
|
envelope_id: envelope.id,
|
|
6718
6718
|
current_attempts: trackedForHandler.attempt,
|
|
6719
6719
|
service_name: serviceName,
|
|
6720
6720
|
});
|
|
6721
6721
|
}
|
|
6722
|
-
logger$
|
|
6722
|
+
logger$18.debug('forwarding_to_listener_handler', {
|
|
6723
6723
|
recipient: serviceName,
|
|
6724
6724
|
envelope_id: envelope.id,
|
|
6725
6725
|
frame_type: envelope.frame?.['type'],
|
|
@@ -6738,7 +6738,7 @@ class EnvelopeListenerManager extends TaskSpawner {
|
|
|
6738
6738
|
await channel.send(null);
|
|
6739
6739
|
}
|
|
6740
6740
|
catch (error) {
|
|
6741
|
-
logger$
|
|
6741
|
+
logger$18.debug('listener_stop_signal_failed', {
|
|
6742
6742
|
service_name: serviceName,
|
|
6743
6743
|
error: error instanceof Error ? error.message : String(error),
|
|
6744
6744
|
});
|
|
@@ -6747,7 +6747,7 @@ class EnvelopeListenerManager extends TaskSpawner {
|
|
|
6747
6747
|
await this.listenersLock.runExclusive(async () => {
|
|
6748
6748
|
const existing = this.listeners.get(serviceName);
|
|
6749
6749
|
if (existing) {
|
|
6750
|
-
logger$
|
|
6750
|
+
logger$18.debug('replacing_envelope_listener', { recipient: serviceName });
|
|
6751
6751
|
existing.listener.stop();
|
|
6752
6752
|
try {
|
|
6753
6753
|
await existing.listener.task.promise;
|
|
@@ -6765,13 +6765,13 @@ class EnvelopeListenerManager extends TaskSpawner {
|
|
|
6765
6765
|
return binding.address;
|
|
6766
6766
|
}
|
|
6767
6767
|
async listenRpc(serviceName, handler, options = {}) {
|
|
6768
|
-
logger$
|
|
6768
|
+
logger$18.debug('rpc_listen_start', { service_name: serviceName });
|
|
6769
6769
|
const rpcHandler = async (envelope, context) => {
|
|
6770
6770
|
const result = await this.rpcServerHandler.handleRpcRequest(envelope, context, handler, serviceName);
|
|
6771
6771
|
return result ?? null;
|
|
6772
6772
|
};
|
|
6773
6773
|
const address = await this.listen(serviceName, rpcHandler, options);
|
|
6774
|
-
logger$
|
|
6774
|
+
logger$18.debug('rpc_listen_bound', {
|
|
6775
6775
|
service_name: serviceName,
|
|
6776
6776
|
address: address.toString(),
|
|
6777
6777
|
});
|
|
@@ -6840,12 +6840,12 @@ class EnvelopeListenerManager extends TaskSpawner {
|
|
|
6840
6840
|
return cached;
|
|
6841
6841
|
});
|
|
6842
6842
|
if (!envelopes.length) {
|
|
6843
|
-
logger$
|
|
6843
|
+
logger$18.debug('no_cached_recovery_for_service', {
|
|
6844
6844
|
service_name: serviceName,
|
|
6845
6845
|
});
|
|
6846
6846
|
return;
|
|
6847
6847
|
}
|
|
6848
|
-
logger$
|
|
6848
|
+
logger$18.debug('recovering_unhandled_envelopes_on_listen', {
|
|
6849
6849
|
service_name: serviceName,
|
|
6850
6850
|
count: envelopes.length,
|
|
6851
6851
|
envelope_ids: envelopes.map((trackedEnvelope) => trackedEnvelope.envelopeId),
|
|
@@ -6856,7 +6856,7 @@ class EnvelopeListenerManager extends TaskSpawner {
|
|
|
6856
6856
|
async recoverServiceEnvelopes(serviceName, envelopes, handler) {
|
|
6857
6857
|
for (const tracked of envelopes) {
|
|
6858
6858
|
try {
|
|
6859
|
-
logger$
|
|
6859
|
+
logger$18.warning('recovering_unhandled_envelope', {
|
|
6860
6860
|
envelope_id: tracked.envelopeId,
|
|
6861
6861
|
service_name: serviceName,
|
|
6862
6862
|
current_attempts: tracked.attempt,
|
|
@@ -6865,13 +6865,13 @@ class EnvelopeListenerManager extends TaskSpawner {
|
|
|
6865
6865
|
const originalEnvelope = tracked.originalEnvelope;
|
|
6866
6866
|
const receiverPolicy = this.nodeLike.deliveryPolicy?.receiverRetryPolicy ?? undefined;
|
|
6867
6867
|
await this.executeHandlerWithRetries(handler, originalEnvelope, undefined, receiverPolicy, tracked, serviceName);
|
|
6868
|
-
logger$
|
|
6868
|
+
logger$18.debug('envelope_recovery_completed', {
|
|
6869
6869
|
envelope_id: tracked.envelopeId,
|
|
6870
6870
|
service_name: serviceName,
|
|
6871
6871
|
});
|
|
6872
6872
|
}
|
|
6873
6873
|
catch (error) {
|
|
6874
|
-
logger$
|
|
6874
|
+
logger$18.error('envelope_recovery_failed', {
|
|
6875
6875
|
envelope_id: tracked.envelopeId,
|
|
6876
6876
|
service_name: serviceName,
|
|
6877
6877
|
error: error instanceof Error ? error.message : String(error),
|
|
@@ -6917,7 +6917,7 @@ class EnvelopeListenerManager extends TaskSpawner {
|
|
|
6917
6917
|
await this.deliveryTracker.onEnvelopeHandled(trackedEnvelope);
|
|
6918
6918
|
}
|
|
6919
6919
|
if (currentAttempt > 0) {
|
|
6920
|
-
logger$
|
|
6920
|
+
logger$18.info('handler_retry_succeeded', {
|
|
6921
6921
|
envelope_id: envelope.id,
|
|
6922
6922
|
attempt: currentAttempt + 1,
|
|
6923
6923
|
total_attempts: currentAttempt + 1,
|
|
@@ -6933,7 +6933,7 @@ class EnvelopeListenerManager extends TaskSpawner {
|
|
|
6933
6933
|
await this.deliveryTracker.onEnvelopeHandleFailed(inboxName, trackedEnvelope, context, error instanceof Error ? error : new Error(String(error)), isFinalAttempt);
|
|
6934
6934
|
}
|
|
6935
6935
|
if (isFinalAttempt) {
|
|
6936
|
-
logger$
|
|
6936
|
+
logger$18.error('handler_execution_failed_exhausted_retries', {
|
|
6937
6937
|
envelope_id: envelope.id,
|
|
6938
6938
|
total_attempts: attemptNumber,
|
|
6939
6939
|
max_retries: retryPolicy?.maxRetries ?? 0,
|
|
@@ -6942,7 +6942,7 @@ class EnvelopeListenerManager extends TaskSpawner {
|
|
|
6942
6942
|
break;
|
|
6943
6943
|
}
|
|
6944
6944
|
const delayMs = retryPolicy?.nextDelayMs(attemptNumber) ?? 0;
|
|
6945
|
-
logger$
|
|
6945
|
+
logger$18.warning('handler_execution_failed_will_retry', {
|
|
6946
6946
|
envelope_id: envelope.id,
|
|
6947
6947
|
attempt: attemptNumber,
|
|
6948
6948
|
max_retries: retryPolicy?.maxRetries ?? 0,
|
|
@@ -6972,7 +6972,7 @@ class EnvelopeListenerManager extends TaskSpawner {
|
|
|
6972
6972
|
}
|
|
6973
6973
|
}
|
|
6974
6974
|
|
|
6975
|
-
const logger$
|
|
6975
|
+
const logger$17 = getLogger('naylence.fame.delivery.default_delivery_tracker');
|
|
6976
6976
|
const STREAM_END = Symbol('stream-end');
|
|
6977
6977
|
const SWEEPER_TICK = Symbol('tracker-sweeper-tick');
|
|
6978
6978
|
function createDeferred$2() {
|
|
@@ -7191,7 +7191,7 @@ class DefaultDeliveryTracker extends TaskSpawner {
|
|
|
7191
7191
|
const expectedResponseType = options.expectedResponseType;
|
|
7192
7192
|
const tracked = await this.lock.runExclusive(async () => {
|
|
7193
7193
|
if (this.ackFutures.has(envelope.id)) {
|
|
7194
|
-
logger$
|
|
7194
|
+
logger$17.debug('tracker_envelope_already_tracked', {
|
|
7195
7195
|
envp_id: envelope.id,
|
|
7196
7196
|
});
|
|
7197
7197
|
return null;
|
|
@@ -7201,7 +7201,7 @@ class DefaultDeliveryTracker extends TaskSpawner {
|
|
|
7201
7201
|
if (expectedResponseType & core.FameResponseType.REPLY ||
|
|
7202
7202
|
expectedResponseType & core.FameResponseType.STREAM) {
|
|
7203
7203
|
if (existingEnvId && existingEnvId !== envelope.id) {
|
|
7204
|
-
logger$
|
|
7204
|
+
logger$17.debug('envelope_already_tracked_for_replies', {
|
|
7205
7205
|
envp_id: envelope.id,
|
|
7206
7206
|
corr_id: corrId,
|
|
7207
7207
|
expected_response_type: expectedResponseType,
|
|
@@ -7250,7 +7250,7 @@ class DefaultDeliveryTracker extends TaskSpawner {
|
|
|
7250
7250
|
return null;
|
|
7251
7251
|
}
|
|
7252
7252
|
await this.scheduleTimer(tracked, options.retryPolicy ?? null, options.retryHandler ?? null);
|
|
7253
|
-
logger$
|
|
7253
|
+
logger$17.debug('tracker_registered_envelope', {
|
|
7254
7254
|
envp_id: envelope.id,
|
|
7255
7255
|
corr_id: tracked.originalEnvelope.corrId,
|
|
7256
7256
|
expected_response: tracked.expectedResponseType,
|
|
@@ -7274,21 +7274,21 @@ class DefaultDeliveryTracker extends TaskSpawner {
|
|
|
7274
7274
|
return this.awaitEnvelopeFuture(envelopeId, core.FameResponseType.REPLY | core.FameResponseType.STREAM, future, timeoutMs);
|
|
7275
7275
|
}
|
|
7276
7276
|
async onEnvelopeDelivered(inboxName, envelope, context) {
|
|
7277
|
-
logger$
|
|
7277
|
+
logger$17.debug('envelope_delivered', {
|
|
7278
7278
|
envp_id: envelope.id,
|
|
7279
7279
|
corr_id: envelope.corrId,
|
|
7280
7280
|
rtype: envelope.rtype ?? core.FameResponseType.NONE,
|
|
7281
7281
|
frame_type: envelope.frame?.type ?? 'unknown',
|
|
7282
7282
|
});
|
|
7283
7283
|
if (!envelope.corrId) {
|
|
7284
|
-
logger$
|
|
7284
|
+
logger$17.debug('envelope_delivered_no_corr_id', {
|
|
7285
7285
|
envelope_id: envelope.id,
|
|
7286
7286
|
});
|
|
7287
7287
|
return null;
|
|
7288
7288
|
}
|
|
7289
7289
|
if (this.isDeliveryAckFrame(envelope.frame)) {
|
|
7290
7290
|
if (!envelope.frame.refId) {
|
|
7291
|
-
logger$
|
|
7291
|
+
logger$17.debug('envelope_delivered_no_ref_id', {
|
|
7292
7292
|
envelope_id: envelope.id,
|
|
7293
7293
|
});
|
|
7294
7294
|
return null;
|
|
@@ -7325,7 +7325,7 @@ class DefaultDeliveryTracker extends TaskSpawner {
|
|
|
7325
7325
|
await inbox.set(envelope.id, tracked);
|
|
7326
7326
|
}
|
|
7327
7327
|
else {
|
|
7328
|
-
logger$
|
|
7328
|
+
logger$17.debug('tracker_duplicate_envelope_already_handled', {
|
|
7329
7329
|
envp_id: envelope.id,
|
|
7330
7330
|
status: tracked.status,
|
|
7331
7331
|
});
|
|
@@ -7367,7 +7367,7 @@ class DefaultDeliveryTracker extends TaskSpawner {
|
|
|
7367
7367
|
}
|
|
7368
7368
|
if (isFinalFailure) {
|
|
7369
7369
|
envelope.status = EnvelopeStatus.FAILED_TO_HANDLE;
|
|
7370
|
-
logger$
|
|
7370
|
+
logger$17.error('envelope_handle_failed_final', {
|
|
7371
7371
|
inbox_name: inboxName,
|
|
7372
7372
|
envp_id: envelope.originalEnvelope.id,
|
|
7373
7373
|
error: error?.message ?? 'unknown',
|
|
@@ -7378,7 +7378,7 @@ class DefaultDeliveryTracker extends TaskSpawner {
|
|
|
7378
7378
|
await inbox.delete(envelope.originalEnvelope.id);
|
|
7379
7379
|
return;
|
|
7380
7380
|
}
|
|
7381
|
-
logger$
|
|
7381
|
+
logger$17.warning('envelope_handle_failed_retry', {
|
|
7382
7382
|
inbox_name: inboxName,
|
|
7383
7383
|
envp_id: envelope.originalEnvelope.id,
|
|
7384
7384
|
error: error?.message ?? 'unknown',
|
|
@@ -7423,14 +7423,14 @@ class DefaultDeliveryTracker extends TaskSpawner {
|
|
|
7423
7423
|
if (handledViaFuture) {
|
|
7424
7424
|
await this.markDoneSince(this.ackFutures, refId, this.ackDoneSince);
|
|
7425
7425
|
await this.clearTimer(refId);
|
|
7426
|
-
logger$
|
|
7426
|
+
logger$17.debug('tracker_ack_resolved_without_tracked_envelope', {
|
|
7427
7427
|
envp_id: envelope.id,
|
|
7428
7428
|
ref_id: refId,
|
|
7429
7429
|
corr_id: envelope.corrId,
|
|
7430
7430
|
});
|
|
7431
7431
|
return;
|
|
7432
7432
|
}
|
|
7433
|
-
logger$
|
|
7433
|
+
logger$17.debug('tracker_ack_for_unknown_envelope', {
|
|
7434
7434
|
envp_id: envelope.id,
|
|
7435
7435
|
ref_id: refId,
|
|
7436
7436
|
corr_id: envelope.corrId,
|
|
@@ -7438,7 +7438,7 @@ class DefaultDeliveryTracker extends TaskSpawner {
|
|
|
7438
7438
|
return;
|
|
7439
7439
|
}
|
|
7440
7440
|
if (tracked.originalEnvelope.corrId !== envelope.corrId) {
|
|
7441
|
-
logger$
|
|
7441
|
+
logger$17.debug('tracker_ack_corr_id_mismatch', {
|
|
7442
7442
|
envp_id: envelope.id,
|
|
7443
7443
|
expected_corr_id: tracked.originalEnvelope.corrId,
|
|
7444
7444
|
actual_corr_id: envelope.corrId,
|
|
@@ -7463,7 +7463,7 @@ class DefaultDeliveryTracker extends TaskSpawner {
|
|
|
7463
7463
|
for (const handler of this.eventHandlers) {
|
|
7464
7464
|
await handler.onEnvelopeAcked?.(tracked);
|
|
7465
7465
|
}
|
|
7466
|
-
logger$
|
|
7466
|
+
logger$17.debug('tracker_envelope_acked', {
|
|
7467
7467
|
envp_id: tracked.originalEnvelope.id,
|
|
7468
7468
|
});
|
|
7469
7469
|
}
|
|
@@ -7480,13 +7480,13 @@ class DefaultDeliveryTracker extends TaskSpawner {
|
|
|
7480
7480
|
const outbox = this.ensureOutbox();
|
|
7481
7481
|
const tracked = await outbox.get(envelope.frame.refId);
|
|
7482
7482
|
if (!tracked) {
|
|
7483
|
-
logger$
|
|
7483
|
+
logger$17.debug('tracker_nack_for_unknown_envelope', {
|
|
7484
7484
|
envp_id: envelope.id,
|
|
7485
7485
|
});
|
|
7486
7486
|
return;
|
|
7487
7487
|
}
|
|
7488
7488
|
if (tracked.originalEnvelope.corrId !== envelope.corrId) {
|
|
7489
|
-
logger$
|
|
7489
|
+
logger$17.debug('tracker_nack_corr_id_mismatch', {
|
|
7490
7490
|
envp_id: envelope.id,
|
|
7491
7491
|
expected_corr_id: tracked.originalEnvelope.corrId,
|
|
7492
7492
|
actual_corr_id: envelope.corrId,
|
|
@@ -7528,7 +7528,7 @@ class DefaultDeliveryTracker extends TaskSpawner {
|
|
|
7528
7528
|
for (const handler of this.eventHandlers) {
|
|
7529
7529
|
await handler.onEnvelopeNacked?.(tracked, ackFrame.reason ?? null);
|
|
7530
7530
|
}
|
|
7531
|
-
logger$
|
|
7531
|
+
logger$17.debug('tracker_envelope_nacked', {
|
|
7532
7532
|
envp_id: tracked.originalEnvelope.id,
|
|
7533
7533
|
reason: ackFrame.reason,
|
|
7534
7534
|
});
|
|
@@ -7575,7 +7575,7 @@ class DefaultDeliveryTracker extends TaskSpawner {
|
|
|
7575
7575
|
for (const handler of this.eventHandlers) {
|
|
7576
7576
|
await handler.onEnvelopeReplied?.(trackedEnvelope, envelope);
|
|
7577
7577
|
}
|
|
7578
|
-
logger$
|
|
7578
|
+
logger$17.debug('tracked_envelope_replied', {
|
|
7579
7579
|
envp_id: trackedEnvelope.originalEnvelope.id,
|
|
7580
7580
|
corr_id: envelope.corrId,
|
|
7581
7581
|
});
|
|
@@ -7649,7 +7649,7 @@ class DefaultDeliveryTracker extends TaskSpawner {
|
|
|
7649
7649
|
async addToInboxDlq(trackedEnvelope, reason = null) {
|
|
7650
7650
|
const dlq = this.inboxDlq;
|
|
7651
7651
|
if (!dlq) {
|
|
7652
|
-
logger$
|
|
7652
|
+
logger$17.error('dlq_not_initialized', {
|
|
7653
7653
|
envp_id: trackedEnvelope.originalEnvelope.id,
|
|
7654
7654
|
});
|
|
7655
7655
|
return;
|
|
@@ -7664,7 +7664,7 @@ class DefaultDeliveryTracker extends TaskSpawner {
|
|
|
7664
7664
|
const deadLetteredAt = Date.now();
|
|
7665
7665
|
setMetaWithLegacy(trackedEnvelope.meta, 'deadLetteredAtMs', 'dead_lettered_at_ms', deadLetteredAt);
|
|
7666
7666
|
await dlq.set(trackedEnvelope.originalEnvelope.id, trackedEnvelope);
|
|
7667
|
-
logger$
|
|
7667
|
+
logger$17.warning('envelope_moved_to_dlq', {
|
|
7668
7668
|
envp_id: trackedEnvelope.originalEnvelope.id,
|
|
7669
7669
|
service_name: trackedEnvelope.serviceName,
|
|
7670
7670
|
});
|
|
@@ -7693,7 +7693,7 @@ class DefaultDeliveryTracker extends TaskSpawner {
|
|
|
7693
7693
|
const toDelete = Object.entries(items).filter(([, value]) => predicate ? predicate(value) : true);
|
|
7694
7694
|
await Promise.all(toDelete.map(([key]) => dlq.delete(key)));
|
|
7695
7695
|
if (toDelete.length) {
|
|
7696
|
-
logger$
|
|
7696
|
+
logger$17.debug('dlq_purged', { count: toDelete.length });
|
|
7697
7697
|
}
|
|
7698
7698
|
return toDelete.length;
|
|
7699
7699
|
}
|
|
@@ -7746,11 +7746,11 @@ class DefaultDeliveryTracker extends TaskSpawner {
|
|
|
7746
7746
|
}
|
|
7747
7747
|
this.futuresSweeper = null;
|
|
7748
7748
|
}
|
|
7749
|
-
logger$
|
|
7749
|
+
logger$17.debug('tracker_cleanup_completed');
|
|
7750
7750
|
}
|
|
7751
7751
|
async recoverPending() {
|
|
7752
7752
|
const pending = await this.listPending();
|
|
7753
|
-
logger$
|
|
7753
|
+
logger$17.debug('tracker_recovering_pending', { count: pending.length });
|
|
7754
7754
|
await this.lock.runExclusive(async () => {
|
|
7755
7755
|
for (const tracked of pending) {
|
|
7756
7756
|
if (tracked.expectedResponseType & core.FameResponseType.ACK) {
|
|
@@ -7776,7 +7776,7 @@ class DefaultDeliveryTracker extends TaskSpawner {
|
|
|
7776
7776
|
for (const tracked of pending) {
|
|
7777
7777
|
await this.scheduleTimer(tracked, null, null);
|
|
7778
7778
|
}
|
|
7779
|
-
logger$
|
|
7779
|
+
logger$17.debug('tracker_recovery_completed', { count: pending.length });
|
|
7780
7780
|
}
|
|
7781
7781
|
ensureOutbox() {
|
|
7782
7782
|
if (!this.outbox) {
|
|
@@ -7791,7 +7791,7 @@ class DefaultDeliveryTracker extends TaskSpawner {
|
|
|
7791
7791
|
return this.inbox;
|
|
7792
7792
|
}
|
|
7793
7793
|
async waitForPendingAcks() {
|
|
7794
|
-
logger$
|
|
7794
|
+
logger$17.debug('tracker_node_preparing_to_stop_waiting_for_pending_acks');
|
|
7795
7795
|
const outbox = this.outbox;
|
|
7796
7796
|
if (!outbox) {
|
|
7797
7797
|
return;
|
|
@@ -7803,7 +7803,7 @@ class DefaultDeliveryTracker extends TaskSpawner {
|
|
|
7803
7803
|
continue;
|
|
7804
7804
|
}
|
|
7805
7805
|
if (!future.done) {
|
|
7806
|
-
logger$
|
|
7806
|
+
logger$17.debug('tracker_pending_ack_future_detected', {
|
|
7807
7807
|
envelope_id: envelopeId,
|
|
7808
7808
|
});
|
|
7809
7809
|
pending.push({ envelopeId, future });
|
|
@@ -7811,10 +7811,10 @@ class DefaultDeliveryTracker extends TaskSpawner {
|
|
|
7811
7811
|
}
|
|
7812
7812
|
});
|
|
7813
7813
|
if (!pending.length) {
|
|
7814
|
-
logger$
|
|
7814
|
+
logger$17.debug('tracker_no_pending_acks_to_wait_for');
|
|
7815
7815
|
return;
|
|
7816
7816
|
}
|
|
7817
|
-
logger$
|
|
7817
|
+
logger$17.debug('tracker_waiting_for_pending_acks', { count: pending.length });
|
|
7818
7818
|
for (const entry of pending) {
|
|
7819
7819
|
if (!entry) {
|
|
7820
7820
|
continue;
|
|
@@ -7831,19 +7831,19 @@ class DefaultDeliveryTracker extends TaskSpawner {
|
|
|
7831
7831
|
}
|
|
7832
7832
|
try {
|
|
7833
7833
|
await this.awaitWithTimeout(entry.future.promise, remainingMs);
|
|
7834
|
-
logger$
|
|
7834
|
+
logger$17.debug('tracker_received_ack', {
|
|
7835
7835
|
envelope_id: entry.envelopeId,
|
|
7836
7836
|
});
|
|
7837
7837
|
await outbox.delete(entry.envelopeId);
|
|
7838
7838
|
}
|
|
7839
7839
|
catch (error) {
|
|
7840
7840
|
if (error instanceof Error && error.name === 'TimeoutError') {
|
|
7841
|
-
logger$
|
|
7841
|
+
logger$17.debug('tracker_ack_timeout_expired', {
|
|
7842
7842
|
envelope_id: entry.envelopeId,
|
|
7843
7843
|
});
|
|
7844
7844
|
}
|
|
7845
7845
|
else {
|
|
7846
|
-
logger$
|
|
7846
|
+
logger$17.debug('tracker_ack_wait_error', {
|
|
7847
7847
|
envelope_id: entry.envelopeId,
|
|
7848
7848
|
error: error instanceof Error ? error.message : String(error),
|
|
7849
7849
|
});
|
|
@@ -7851,13 +7851,13 @@ class DefaultDeliveryTracker extends TaskSpawner {
|
|
|
7851
7851
|
}
|
|
7852
7852
|
}
|
|
7853
7853
|
catch (error) {
|
|
7854
|
-
logger$
|
|
7854
|
+
logger$17.error('tracker_error_waiting_for_ack', {
|
|
7855
7855
|
envelope_id: entry.envelopeId,
|
|
7856
7856
|
error: error instanceof Error ? error.message : String(error),
|
|
7857
7857
|
});
|
|
7858
7858
|
}
|
|
7859
7859
|
}
|
|
7860
|
-
logger$
|
|
7860
|
+
logger$17.debug('tracker_finished_waiting_for_pending_acks');
|
|
7861
7861
|
}
|
|
7862
7862
|
async waitForPendingAckDispatches() {
|
|
7863
7863
|
while (this.pendingAckDispatches.size > 0) {
|
|
@@ -7915,7 +7915,7 @@ class DefaultDeliveryTracker extends TaskSpawner {
|
|
|
7915
7915
|
for (const handler of this.eventHandlers) {
|
|
7916
7916
|
await handler.onEnvelopeTimeout?.(currentTracked);
|
|
7917
7917
|
}
|
|
7918
|
-
logger$
|
|
7918
|
+
logger$17.debug('tracker_envelope_timed_out', {
|
|
7919
7919
|
envp_id: tracked.originalEnvelope.id,
|
|
7920
7920
|
});
|
|
7921
7921
|
return;
|
|
@@ -7928,7 +7928,7 @@ class DefaultDeliveryTracker extends TaskSpawner {
|
|
|
7928
7928
|
currentTracked.timeoutAtMs = nextTimeoutAt;
|
|
7929
7929
|
await outbox.set(tracked.originalEnvelope.id, currentTracked);
|
|
7930
7930
|
await this.scheduleTimer(currentTracked, retryPolicy, retryHandler);
|
|
7931
|
-
logger$
|
|
7931
|
+
logger$17.debug('tracker_retry_deferred_during_shutdown', {
|
|
7932
7932
|
envp_id: tracked.originalEnvelope.id,
|
|
7933
7933
|
defer_ms: shutdownDeferMs,
|
|
7934
7934
|
});
|
|
@@ -7951,7 +7951,7 @@ class DefaultDeliveryTracker extends TaskSpawner {
|
|
|
7951
7951
|
});
|
|
7952
7952
|
}
|
|
7953
7953
|
await this.scheduleTimer(currentTracked, retryPolicy, retryHandler);
|
|
7954
|
-
logger$
|
|
7954
|
+
logger$17.debug('envelope_delivery_retry_scheduled', {
|
|
7955
7955
|
envp_id: tracked.originalEnvelope.id,
|
|
7956
7956
|
attempt: currentTracked.attempt,
|
|
7957
7957
|
max_retries: retryPolicy.maxRetries,
|
|
@@ -7963,7 +7963,7 @@ class DefaultDeliveryTracker extends TaskSpawner {
|
|
|
7963
7963
|
currentTracked.timeoutAtMs = currentTracked.overallTimeoutAtMs;
|
|
7964
7964
|
await outbox.set(tracked.originalEnvelope.id, currentTracked);
|
|
7965
7965
|
await this.scheduleTimer(currentTracked, retryPolicy, retryHandler);
|
|
7966
|
-
logger$
|
|
7966
|
+
logger$17.debug('envelope_retries_exhausted_waiting_until_overall_timeout', {
|
|
7967
7967
|
envp_id: tracked.originalEnvelope.id,
|
|
7968
7968
|
attempt: currentTracked.attempt,
|
|
7969
7969
|
overall_timeout_at_ms: currentTracked.overallTimeoutAtMs,
|
|
@@ -7983,7 +7983,7 @@ class DefaultDeliveryTracker extends TaskSpawner {
|
|
|
7983
7983
|
for (const handler of this.eventHandlers) {
|
|
7984
7984
|
await handler.onEnvelopeTimeout?.(currentTracked);
|
|
7985
7985
|
}
|
|
7986
|
-
logger$
|
|
7986
|
+
logger$17.debug('tracker_envelope_timed_out', {
|
|
7987
7987
|
envp_id: tracked.originalEnvelope.id,
|
|
7988
7988
|
});
|
|
7989
7989
|
}
|
|
@@ -7991,7 +7991,7 @@ class DefaultDeliveryTracker extends TaskSpawner {
|
|
|
7991
7991
|
if (error instanceof TaskCancelledError) {
|
|
7992
7992
|
return;
|
|
7993
7993
|
}
|
|
7994
|
-
logger$
|
|
7994
|
+
logger$17.error('tracker_timer_error', {
|
|
7995
7995
|
envp_id: tracked.originalEnvelope.id,
|
|
7996
7996
|
error: error instanceof Error ? error.message : String(error),
|
|
7997
7997
|
});
|
|
@@ -8046,7 +8046,7 @@ class DefaultDeliveryTracker extends TaskSpawner {
|
|
|
8046
8046
|
if (timeoutSeconds !== null) {
|
|
8047
8047
|
return await this.awaitWithTimeout(future.promise, timeoutSeconds);
|
|
8048
8048
|
}
|
|
8049
|
-
logger$
|
|
8049
|
+
logger$17.debug('await_envelope_no_timeout_wait', {
|
|
8050
8050
|
envelope_id: envelopeId,
|
|
8051
8051
|
});
|
|
8052
8052
|
return await future.promise;
|
|
@@ -8055,7 +8055,7 @@ class DefaultDeliveryTracker extends TaskSpawner {
|
|
|
8055
8055
|
if (error instanceof Error && error.name !== 'TimeoutError') {
|
|
8056
8056
|
throw error;
|
|
8057
8057
|
}
|
|
8058
|
-
logger$
|
|
8058
|
+
logger$17.error('await_envelope_timeout_error', {
|
|
8059
8059
|
envelope_id: envelopeId,
|
|
8060
8060
|
timeout_ms: timeoutSeconds,
|
|
8061
8061
|
future_done: false,
|
|
@@ -8216,7 +8216,7 @@ class DefaultDeliveryTracker extends TaskSpawner {
|
|
|
8216
8216
|
this.replyDoneSince.delete(envId);
|
|
8217
8217
|
}
|
|
8218
8218
|
});
|
|
8219
|
-
logger$
|
|
8219
|
+
logger$17.debug('tracker_swept_completed_futures', {
|
|
8220
8220
|
ack_removed: toRemoveAck.length,
|
|
8221
8221
|
reply_removed: toRemoveReply.length,
|
|
8222
8222
|
grace_secs: this.futGcGraceSecs,
|
|
@@ -8230,7 +8230,7 @@ class DefaultDeliveryTracker extends TaskSpawner {
|
|
|
8230
8230
|
if (error instanceof Error && error.name === 'TimeoutError') {
|
|
8231
8231
|
continue;
|
|
8232
8232
|
}
|
|
8233
|
-
logger$
|
|
8233
|
+
logger$17.error('tracker_sweeper_error', {
|
|
8234
8234
|
error: error instanceof Error ? error.message : String(error),
|
|
8235
8235
|
});
|
|
8236
8236
|
}
|
|
@@ -8261,14 +8261,14 @@ class DefaultDeliveryTracker extends TaskSpawner {
|
|
|
8261
8261
|
}
|
|
8262
8262
|
const node = this.node;
|
|
8263
8263
|
if (!envelope.replyTo) {
|
|
8264
|
-
logger$
|
|
8264
|
+
logger$17.error('cannot_send_ack_no_reply_to', { envp_id: envelope.id });
|
|
8265
8265
|
return;
|
|
8266
8266
|
}
|
|
8267
8267
|
if (!envelope.corrId) {
|
|
8268
|
-
logger$
|
|
8268
|
+
logger$17.error('cannot_send_ack_no_corr_id', { envp_id: envelope.id });
|
|
8269
8269
|
return;
|
|
8270
8270
|
}
|
|
8271
|
-
logger$
|
|
8271
|
+
logger$17.debug('tracker_sending_ack', {
|
|
8272
8272
|
envp_id: envelope.id,
|
|
8273
8273
|
ref_id: envelope.id,
|
|
8274
8274
|
to: envelope.replyTo,
|
|
@@ -8288,7 +8288,7 @@ class DefaultDeliveryTracker extends TaskSpawner {
|
|
|
8288
8288
|
.send(ackEnvelope)
|
|
8289
8289
|
.then(() => undefined)
|
|
8290
8290
|
.catch((error) => {
|
|
8291
|
-
logger$
|
|
8291
|
+
logger$17.error('tracker_ack_dispatch_failed', {
|
|
8292
8292
|
envp_id: envelope.id,
|
|
8293
8293
|
error: error instanceof Error ? error.message : String(error),
|
|
8294
8294
|
});
|
|
@@ -8374,7 +8374,7 @@ class AsyncEvent {
|
|
|
8374
8374
|
}
|
|
8375
8375
|
}
|
|
8376
8376
|
|
|
8377
|
-
const logger$
|
|
8377
|
+
const logger$16 = getLogger('naylence.fame.node.root_session_manager');
|
|
8378
8378
|
function resolveOption$1(options, primary, ...aliases) {
|
|
8379
8379
|
const record = options;
|
|
8380
8380
|
const primaryKey = primary;
|
|
@@ -8455,7 +8455,7 @@ class RootSessionManager extends TaskSpawner {
|
|
|
8455
8455
|
this.onAdmissionFailed =
|
|
8456
8456
|
typeof onAdmissionFailed === 'function' ? onAdmissionFailed : undefined;
|
|
8457
8457
|
this.enableContinuousRefresh = enableContinuousRefresh ?? true;
|
|
8458
|
-
logger$
|
|
8458
|
+
logger$16.debug('created_root_session_manager');
|
|
8459
8459
|
}
|
|
8460
8460
|
get isReady() {
|
|
8461
8461
|
return this.readyEvent.isSet();
|
|
@@ -8480,7 +8480,7 @@ class RootSessionManager extends TaskSpawner {
|
|
|
8480
8480
|
if (this.admissionTask) {
|
|
8481
8481
|
return;
|
|
8482
8482
|
}
|
|
8483
|
-
logger$
|
|
8483
|
+
logger$16.debug('root_session_manager_starting');
|
|
8484
8484
|
this.stopEvent.clear();
|
|
8485
8485
|
this.readyEvent.clear();
|
|
8486
8486
|
const taskName = `root-admission-${this.admissionEpoch}`;
|
|
@@ -8500,10 +8500,10 @@ class RootSessionManager extends TaskSpawner {
|
|
|
8500
8500
|
await this.admissionTask.promise;
|
|
8501
8501
|
throw new FameConnectError('Root session manager failed to become ready');
|
|
8502
8502
|
}
|
|
8503
|
-
logger$
|
|
8503
|
+
logger$16.debug('root_session_manager_started');
|
|
8504
8504
|
}
|
|
8505
8505
|
async stop() {
|
|
8506
|
-
logger$
|
|
8506
|
+
logger$16.debug('root_session_manager_stopping');
|
|
8507
8507
|
this.stopEvent.set();
|
|
8508
8508
|
if (this.admissionTask) {
|
|
8509
8509
|
this.admissionTask.cancel();
|
|
@@ -8515,7 +8515,7 @@ class RootSessionManager extends TaskSpawner {
|
|
|
8515
8515
|
await this.consumeTask(this.expiryGuardTask);
|
|
8516
8516
|
this.expiryGuardTask = null;
|
|
8517
8517
|
}
|
|
8518
|
-
logger$
|
|
8518
|
+
logger$16.debug('root_session_manager_stopped');
|
|
8519
8519
|
}
|
|
8520
8520
|
async awaitReady(timeoutMs) {
|
|
8521
8521
|
if (this.isReady) {
|
|
@@ -8556,12 +8556,12 @@ class RootSessionManager extends TaskSpawner {
|
|
|
8556
8556
|
await this.onEpochChange(epoch);
|
|
8557
8557
|
}
|
|
8558
8558
|
else {
|
|
8559
|
-
logger$
|
|
8559
|
+
logger$16.debug('epoch_change_ignored_no_handler', { epoch });
|
|
8560
8560
|
}
|
|
8561
8561
|
}
|
|
8562
8562
|
static createForRootSentinel(node, admissionClient, requestedLogicals = [], enableContinuousRefresh = true, onEpochChange) {
|
|
8563
8563
|
const handleWelcome = async (frame) => {
|
|
8564
|
-
logger$
|
|
8564
|
+
logger$16.info('root_admission_successful', {
|
|
8565
8565
|
system_id: frame.systemId,
|
|
8566
8566
|
assigned_path: frame.assignedPath ?? null,
|
|
8567
8567
|
accepted_logicals: frame.acceptedLogicals ?? [],
|
|
@@ -8572,12 +8572,12 @@ class RootSessionManager extends TaskSpawner {
|
|
|
8572
8572
|
? grant.purpose
|
|
8573
8573
|
: undefined;
|
|
8574
8574
|
if (purpose) {
|
|
8575
|
-
logger$
|
|
8575
|
+
logger$16.debug('received_admission_grant', { purpose });
|
|
8576
8576
|
}
|
|
8577
8577
|
}
|
|
8578
8578
|
};
|
|
8579
8579
|
const handleFailure = async (error) => {
|
|
8580
|
-
logger$
|
|
8580
|
+
logger$16.error('root_admission_failed_permanently', {
|
|
8581
8581
|
error: error.message,
|
|
8582
8582
|
});
|
|
8583
8583
|
};
|
|
@@ -8606,10 +8606,10 @@ class RootSessionManager extends TaskSpawner {
|
|
|
8606
8606
|
this.readyEvent.set();
|
|
8607
8607
|
}
|
|
8608
8608
|
if (this.hadSuccessfulAdmission) {
|
|
8609
|
-
logger$
|
|
8609
|
+
logger$16.debug('root_admission_refreshed');
|
|
8610
8610
|
}
|
|
8611
8611
|
else {
|
|
8612
|
-
logger$
|
|
8612
|
+
logger$16.debug('root_admission_completed');
|
|
8613
8613
|
}
|
|
8614
8614
|
this.hadSuccessfulAdmission = true;
|
|
8615
8615
|
delay = RootSessionManager.BACKOFF_INITIAL;
|
|
@@ -8618,7 +8618,7 @@ class RootSessionManager extends TaskSpawner {
|
|
|
8618
8618
|
await this.startExpiryGuard(welcomeFrame);
|
|
8619
8619
|
const expiryTriggered = await this.waitForExpiryOrStop();
|
|
8620
8620
|
if (expiryTriggered && !this.stopEvent.isSet()) {
|
|
8621
|
-
logger$
|
|
8621
|
+
logger$16.debug('performing_scheduled_re_admission');
|
|
8622
8622
|
continue;
|
|
8623
8623
|
}
|
|
8624
8624
|
}
|
|
@@ -8630,7 +8630,7 @@ class RootSessionManager extends TaskSpawner {
|
|
|
8630
8630
|
}
|
|
8631
8631
|
const errorObject = error instanceof Error ? error : new Error(String(error));
|
|
8632
8632
|
const willRetry = attempts < RootSessionManager.RETRY_MAX_ATTEMPTS;
|
|
8633
|
-
logger$
|
|
8633
|
+
logger$16.warning('root_admission_failed', {
|
|
8634
8634
|
error: errorObject.message,
|
|
8635
8635
|
attempt: attempts,
|
|
8636
8636
|
will_retry: willRetry,
|
|
@@ -8648,7 +8648,7 @@ class RootSessionManager extends TaskSpawner {
|
|
|
8648
8648
|
}
|
|
8649
8649
|
}
|
|
8650
8650
|
if (attempts >= RootSessionManager.RETRY_MAX_ATTEMPTS) {
|
|
8651
|
-
logger$
|
|
8651
|
+
logger$16.error('root_admission_max_attempts_exceeded', {
|
|
8652
8652
|
max_attempts: RootSessionManager.RETRY_MAX_ATTEMPTS,
|
|
8653
8653
|
});
|
|
8654
8654
|
}
|
|
@@ -8725,7 +8725,7 @@ class RootSessionManager extends TaskSpawner {
|
|
|
8725
8725
|
}
|
|
8726
8726
|
async expiryGuard(welcomeFrame, signal) {
|
|
8727
8727
|
if (!welcomeFrame.expiresAt) {
|
|
8728
|
-
logger$
|
|
8728
|
+
logger$16.debug('no_admission_expiry_configured');
|
|
8729
8729
|
await Promise.race([this.stopEvent.wait(), this.waitForAbort(signal)]);
|
|
8730
8730
|
return;
|
|
8731
8731
|
}
|
|
@@ -8734,7 +8734,7 @@ class RootSessionManager extends TaskSpawner {
|
|
|
8734
8734
|
let delaySeconds = (expiresAt.getTime() - now.getTime()) / 1000 -
|
|
8735
8735
|
RootSessionManager.JWT_REFRESH_SAFETY;
|
|
8736
8736
|
delaySeconds = Math.max(delaySeconds, 0);
|
|
8737
|
-
logger$
|
|
8737
|
+
logger$16.debug('admission_expiry_guard_started', {
|
|
8738
8738
|
welcome_expires_at: expiresAt.toISOString(),
|
|
8739
8739
|
delay_seconds: delaySeconds,
|
|
8740
8740
|
refresh_safety_seconds: RootSessionManager.JWT_REFRESH_SAFETY,
|
|
@@ -8743,7 +8743,7 @@ class RootSessionManager extends TaskSpawner {
|
|
|
8743
8743
|
if (this.stopEvent.isSet() || signal?.aborted) {
|
|
8744
8744
|
return;
|
|
8745
8745
|
}
|
|
8746
|
-
logger$
|
|
8746
|
+
logger$16.debug('admission_expiry_triggered_refresh', {
|
|
8747
8747
|
expires_at: expiresAt.toISOString(),
|
|
8748
8748
|
current_time: new Date().toISOString(),
|
|
8749
8749
|
seconds_before_expiry: RootSessionManager.JWT_REFRESH_SAFETY,
|
|
@@ -8758,7 +8758,7 @@ class RootSessionManager extends TaskSpawner {
|
|
|
8758
8758
|
return;
|
|
8759
8759
|
}
|
|
8760
8760
|
const errorObject = error instanceof Error ? error : new Error(String(error));
|
|
8761
|
-
logger$
|
|
8761
|
+
logger$16.debug('background_task_error', {
|
|
8762
8762
|
task_name: task.name,
|
|
8763
8763
|
error: errorObject.message,
|
|
8764
8764
|
});
|
|
@@ -8799,7 +8799,7 @@ RootSessionManager.JWT_REFRESH_SAFETY = 60.0;
|
|
|
8799
8799
|
* Concrete implementations must define supported grant types and provide grant-to-connector
|
|
8800
8800
|
* conversion logic.
|
|
8801
8801
|
*/
|
|
8802
|
-
const logger$
|
|
8802
|
+
const logger$15 = getLogger('naylence.fame.connector.connector_factory');
|
|
8803
8803
|
const CONNECTOR_FACTORY_BASE_TYPE = 'ConnectorFactory';
|
|
8804
8804
|
/**
|
|
8805
8805
|
* Abstract base class for connector factories
|
|
@@ -8835,7 +8835,7 @@ class ConnectorFactory {
|
|
|
8835
8835
|
}
|
|
8836
8836
|
}
|
|
8837
8837
|
catch (error) {
|
|
8838
|
-
logger$
|
|
8838
|
+
logger$15.warning(`Failed to evaluate grant with factory ${factoryInfo.constructor.name}: ${error}`);
|
|
8839
8839
|
continue;
|
|
8840
8840
|
}
|
|
8841
8841
|
}
|
|
@@ -8878,7 +8878,7 @@ class ConnectorFactory {
|
|
|
8878
8878
|
}
|
|
8879
8879
|
}
|
|
8880
8880
|
catch (error) {
|
|
8881
|
-
logger$
|
|
8881
|
+
logger$15.warning(`Failed to create connector config from grant: ${error}`);
|
|
8882
8882
|
continue;
|
|
8883
8883
|
}
|
|
8884
8884
|
}
|
|
@@ -8945,20 +8945,20 @@ class ConnectorFactory {
|
|
|
8945
8945
|
return existing;
|
|
8946
8946
|
}
|
|
8947
8947
|
if (existing && !this.isGrantAware(existing)) {
|
|
8948
|
-
logger$
|
|
8948
|
+
logger$15.warning(`Factory ${factoryInfo.constructor.name} is registered under ${CONNECTOR_FACTORY_BASE_TYPE} but is missing grant conversion APIs; skipping.`);
|
|
8949
8949
|
return null;
|
|
8950
8950
|
}
|
|
8951
8951
|
try {
|
|
8952
8952
|
const instance = new factoryInfo.constructor();
|
|
8953
8953
|
if (!this.isGrantAware(instance)) {
|
|
8954
|
-
logger$
|
|
8954
|
+
logger$15.warning(`Factory ${factoryInfo.constructor.name} does not implement grant conversion APIs required by ${CONNECTOR_FACTORY_BASE_TYPE}; skipping.`);
|
|
8955
8955
|
return null;
|
|
8956
8956
|
}
|
|
8957
8957
|
factoryInfo.instance = instance;
|
|
8958
8958
|
return instance;
|
|
8959
8959
|
}
|
|
8960
8960
|
catch (error) {
|
|
8961
|
-
logger$
|
|
8961
|
+
logger$15.warning(`Failed to instantiate factory ${factoryInfo.constructor.name} while resolving grant conversion APIs: ${error}`);
|
|
8962
8962
|
return null;
|
|
8963
8963
|
}
|
|
8964
8964
|
}
|
|
@@ -9061,7 +9061,7 @@ class TaskCancellationError extends Error {
|
|
|
9061
9061
|
this.name = 'TaskCancellationError';
|
|
9062
9062
|
}
|
|
9063
9063
|
}
|
|
9064
|
-
const logger$
|
|
9064
|
+
const logger$14 = getLogger('naylence.fame.connector.base_async_connector');
|
|
9065
9065
|
// Environment variables
|
|
9066
9066
|
const ENV_VAR_FAME_FLOW_CONTROL = 'FAME_FLOW_CONTROL';
|
|
9067
9067
|
const FLOW_CONTROL_ENABLED = typeof process !== 'undefined' && process?.env
|
|
@@ -9144,7 +9144,7 @@ class BaseAsyncConnector extends TaskSpawner {
|
|
|
9144
9144
|
if (this._state !== newState) {
|
|
9145
9145
|
const oldState = this._state;
|
|
9146
9146
|
this._state = newState;
|
|
9147
|
-
logger$
|
|
9147
|
+
logger$14.debug('connector_state_transition', {
|
|
9148
9148
|
connector_id: this._connectorFlowId,
|
|
9149
9149
|
old_state: oldState,
|
|
9150
9150
|
new_state: newState,
|
|
@@ -9183,12 +9183,12 @@ class BaseAsyncConnector extends TaskSpawner {
|
|
|
9183
9183
|
* Stop the connector gracefully
|
|
9184
9184
|
*/
|
|
9185
9185
|
async stop() {
|
|
9186
|
-
logger$
|
|
9186
|
+
logger$14.debug('stopping_connector', {
|
|
9187
9187
|
current_state: this._state,
|
|
9188
9188
|
connector_id: this._connectorFlowId,
|
|
9189
9189
|
});
|
|
9190
9190
|
if (!core.ConnectorStateUtils.canStop(this._state)) {
|
|
9191
|
-
logger$
|
|
9191
|
+
logger$14.debug('connector_stop_already_stopped', {
|
|
9192
9192
|
current_state: this._state,
|
|
9193
9193
|
connector_id: this._connectorFlowId,
|
|
9194
9194
|
});
|
|
@@ -9199,7 +9199,7 @@ class BaseAsyncConnector extends TaskSpawner {
|
|
|
9199
9199
|
if (this._lastError) {
|
|
9200
9200
|
throw this._lastError;
|
|
9201
9201
|
}
|
|
9202
|
-
logger$
|
|
9202
|
+
logger$14.debug('connector_stopped', {
|
|
9203
9203
|
current_state: this._state,
|
|
9204
9204
|
connector_id: this._connectorFlowId,
|
|
9205
9205
|
});
|
|
@@ -9208,19 +9208,19 @@ class BaseAsyncConnector extends TaskSpawner {
|
|
|
9208
9208
|
* Pause the connector (suspends heartbeat and housekeeping, but keeps connection alive)
|
|
9209
9209
|
*/
|
|
9210
9210
|
async pause() {
|
|
9211
|
-
logger$
|
|
9211
|
+
logger$14.debug('pausing_connector', {
|
|
9212
9212
|
current_state: this._state,
|
|
9213
9213
|
connector_id: this._connectorFlowId,
|
|
9214
9214
|
});
|
|
9215
9215
|
if (this._state !== core.ConnectorState.STARTED) {
|
|
9216
|
-
logger$
|
|
9216
|
+
logger$14.debug('connector_pause_invalid_state', {
|
|
9217
9217
|
current_state: this._state,
|
|
9218
9218
|
connector_id: this._connectorFlowId,
|
|
9219
9219
|
});
|
|
9220
9220
|
return;
|
|
9221
9221
|
}
|
|
9222
9222
|
this._setState(core.ConnectorState.PAUSED);
|
|
9223
|
-
logger$
|
|
9223
|
+
logger$14.debug('connector_paused', {
|
|
9224
9224
|
current_state: this._state,
|
|
9225
9225
|
connector_id: this._connectorFlowId,
|
|
9226
9226
|
});
|
|
@@ -9229,19 +9229,19 @@ class BaseAsyncConnector extends TaskSpawner {
|
|
|
9229
9229
|
* Resume the connector from paused state
|
|
9230
9230
|
*/
|
|
9231
9231
|
async resume() {
|
|
9232
|
-
logger$
|
|
9232
|
+
logger$14.debug('resuming_connector', {
|
|
9233
9233
|
current_state: this._state,
|
|
9234
9234
|
connector_id: this._connectorFlowId,
|
|
9235
9235
|
});
|
|
9236
9236
|
if (this._state !== core.ConnectorState.PAUSED) {
|
|
9237
|
-
logger$
|
|
9237
|
+
logger$14.debug('connector_resume_invalid_state', {
|
|
9238
9238
|
current_state: this._state,
|
|
9239
9239
|
connector_id: this._connectorFlowId,
|
|
9240
9240
|
});
|
|
9241
9241
|
return;
|
|
9242
9242
|
}
|
|
9243
9243
|
this._setState(core.ConnectorState.STARTED);
|
|
9244
|
-
logger$
|
|
9244
|
+
logger$14.debug('connector_resumed', {
|
|
9245
9245
|
current_state: this._state,
|
|
9246
9246
|
connector_id: this._connectorFlowId,
|
|
9247
9247
|
});
|
|
@@ -9251,7 +9251,7 @@ class BaseAsyncConnector extends TaskSpawner {
|
|
|
9251
9251
|
*/
|
|
9252
9252
|
async close(code = 1000, reason = 'normal closure') {
|
|
9253
9253
|
if (!core.ConnectorStateUtils.canClose(this._state)) {
|
|
9254
|
-
logger$
|
|
9254
|
+
logger$14.warning('connector_close_invalid_state', {
|
|
9255
9255
|
current_state: this._state,
|
|
9256
9256
|
connector_id: this._connectorFlowId,
|
|
9257
9257
|
});
|
|
@@ -9332,7 +9332,7 @@ class BaseAsyncConnector extends TaskSpawner {
|
|
|
9332
9332
|
// Add to queue and notify send loop
|
|
9333
9333
|
this._sendQueue.push(raw);
|
|
9334
9334
|
// Log for debugging
|
|
9335
|
-
logger$
|
|
9335
|
+
logger$14.debug('send_envelope_queued', {
|
|
9336
9336
|
queue_length: this._sendQueue.length,
|
|
9337
9337
|
max_queue_size: this._maxQueueSize,
|
|
9338
9338
|
});
|
|
@@ -9381,14 +9381,14 @@ class BaseAsyncConnector extends TaskSpawner {
|
|
|
9381
9381
|
const item = this._sendQueue[0];
|
|
9382
9382
|
if (!item)
|
|
9383
9383
|
continue;
|
|
9384
|
-
logger$
|
|
9384
|
+
logger$14.debug('send_loop_processing_item', {
|
|
9385
9385
|
queue_length_before_send: this._sendQueue.length,
|
|
9386
9386
|
});
|
|
9387
9387
|
// Send through transport (this may block)
|
|
9388
9388
|
await this._transportSendBytes(item);
|
|
9389
9389
|
// Only remove from queue after successful send
|
|
9390
9390
|
this._sendQueue.shift();
|
|
9391
|
-
logger$
|
|
9391
|
+
logger$14.debug('send_loop_item_sent', {
|
|
9392
9392
|
queue_length_after_send: this._sendQueue.length,
|
|
9393
9393
|
});
|
|
9394
9394
|
}
|
|
@@ -9401,14 +9401,14 @@ class BaseAsyncConnector extends TaskSpawner {
|
|
|
9401
9401
|
}
|
|
9402
9402
|
else if (error instanceof TaskCancellationError) {
|
|
9403
9403
|
// Task cancellation is expected during shutdown - log as debug, not critical
|
|
9404
|
-
logger$
|
|
9404
|
+
logger$14.debug('send loop cancelled', {
|
|
9405
9405
|
connector: this.constructor.name,
|
|
9406
9406
|
reason: error.message,
|
|
9407
9407
|
});
|
|
9408
9408
|
// Don't re-throw - this is normal during shutdown
|
|
9409
9409
|
}
|
|
9410
9410
|
else {
|
|
9411
|
-
logger$
|
|
9411
|
+
logger$14.critical('unexpected exception in send loop', {
|
|
9412
9412
|
connector: this.constructor.name,
|
|
9413
9413
|
error: error instanceof Error ? error.message : String(error),
|
|
9414
9414
|
});
|
|
@@ -9449,7 +9449,7 @@ class BaseAsyncConnector extends TaskSpawner {
|
|
|
9449
9449
|
env = JSON.parse(jsonStr);
|
|
9450
9450
|
}
|
|
9451
9451
|
catch (error) {
|
|
9452
|
-
logger$
|
|
9452
|
+
logger$14.error('Invalid envelope', {
|
|
9453
9453
|
message: message.toString(),
|
|
9454
9454
|
error: error instanceof Error ? error.message : String(error),
|
|
9455
9455
|
});
|
|
@@ -9473,7 +9473,7 @@ class BaseAsyncConnector extends TaskSpawner {
|
|
|
9473
9473
|
};
|
|
9474
9474
|
await withEnvelopeContextAsync(envelopeContext, async () => {
|
|
9475
9475
|
const prettyEnvelope = prettyModel$1(env);
|
|
9476
|
-
logger$
|
|
9476
|
+
logger$14.trace('connector_received_envelope', {
|
|
9477
9477
|
envelope: env,
|
|
9478
9478
|
pretty: prettyEnvelope,
|
|
9479
9479
|
});
|
|
@@ -9502,7 +9502,7 @@ class BaseAsyncConnector extends TaskSpawner {
|
|
|
9502
9502
|
if (error instanceof TaskCancellationError) {
|
|
9503
9503
|
throw error;
|
|
9504
9504
|
}
|
|
9505
|
-
logger$
|
|
9505
|
+
logger$14.error('handler_failed', {
|
|
9506
9506
|
error: error instanceof Error ? error.message : String(error),
|
|
9507
9507
|
envelope_id: env.id ?? null,
|
|
9508
9508
|
trace_id: env.traceId ?? null,
|
|
@@ -9523,14 +9523,14 @@ class BaseAsyncConnector extends TaskSpawner {
|
|
|
9523
9523
|
}
|
|
9524
9524
|
else if (error instanceof TaskCancellationError) {
|
|
9525
9525
|
// Task cancellation is expected during shutdown - log as debug, not critical
|
|
9526
|
-
logger$
|
|
9526
|
+
logger$14.debug('receive loop cancelled', {
|
|
9527
9527
|
connector: this.constructor.name,
|
|
9528
9528
|
reason: error.message,
|
|
9529
9529
|
});
|
|
9530
9530
|
// Don't re-throw - this is normal during shutdown
|
|
9531
9531
|
}
|
|
9532
9532
|
else {
|
|
9533
|
-
logger$
|
|
9533
|
+
logger$14.critical('unexpected_error_in recv_loop', {
|
|
9534
9534
|
error: error instanceof Error ? error.message : String(error),
|
|
9535
9535
|
});
|
|
9536
9536
|
throw error;
|
|
@@ -9546,7 +9546,7 @@ class BaseAsyncConnector extends TaskSpawner {
|
|
|
9546
9546
|
async _maybeEmitCredit(flowId, traceId) {
|
|
9547
9547
|
const remainingCredits = this._flowCtrl.getCredits(flowId);
|
|
9548
9548
|
const needsRefill = this._flowCtrl.needsRefill(flowId);
|
|
9549
|
-
logger$
|
|
9549
|
+
logger$14.debug('maybe_emit_credit_check', {
|
|
9550
9550
|
connector_id: this._connectorFlowId,
|
|
9551
9551
|
flow_id: flowId,
|
|
9552
9552
|
trace_id: traceId ?? null,
|
|
@@ -9562,7 +9562,7 @@ class BaseAsyncConnector extends TaskSpawner {
|
|
|
9562
9562
|
}
|
|
9563
9563
|
const delta = this._initialWindow;
|
|
9564
9564
|
this._flowCtrl.addCredits(flowId, delta);
|
|
9565
|
-
logger$
|
|
9565
|
+
logger$14.debug('maybe_emit_credit_emit', {
|
|
9566
9566
|
connector_id: this._connectorFlowId,
|
|
9567
9567
|
flow_id: flowId,
|
|
9568
9568
|
trace_id: traceId ?? null,
|
|
@@ -9582,7 +9582,7 @@ class BaseAsyncConnector extends TaskSpawner {
|
|
|
9582
9582
|
});
|
|
9583
9583
|
try {
|
|
9584
9584
|
await this.send(ackEnv);
|
|
9585
|
-
logger$
|
|
9585
|
+
logger$14.debug('maybe_emit_credit_sent', {
|
|
9586
9586
|
connector_id: this._connectorFlowId,
|
|
9587
9587
|
flow_id: flowId,
|
|
9588
9588
|
trace_id: traceId ?? null,
|
|
@@ -9590,7 +9590,7 @@ class BaseAsyncConnector extends TaskSpawner {
|
|
|
9590
9590
|
});
|
|
9591
9591
|
}
|
|
9592
9592
|
catch (error) {
|
|
9593
|
-
logger$
|
|
9593
|
+
logger$14.error('maybe_emit_credit_send_failed', {
|
|
9594
9594
|
connector_id: this._connectorFlowId,
|
|
9595
9595
|
flow_id: flowId,
|
|
9596
9596
|
trace_id: traceId ?? null,
|
|
@@ -9615,13 +9615,13 @@ class BaseAsyncConnector extends TaskSpawner {
|
|
|
9615
9615
|
*/
|
|
9616
9616
|
async _shutdown(code, reason, gracePeriod, exc) {
|
|
9617
9617
|
if (this._closed) {
|
|
9618
|
-
logger$
|
|
9618
|
+
logger$14.debug('shutdown_already_closed', {
|
|
9619
9619
|
connector_id: this._connectorFlowId,
|
|
9620
9620
|
current_state: this._state,
|
|
9621
9621
|
});
|
|
9622
9622
|
return;
|
|
9623
9623
|
}
|
|
9624
|
-
logger$
|
|
9624
|
+
logger$14.debug('connector_shutdown_starting', {
|
|
9625
9625
|
connector_id: this._connectorFlowId,
|
|
9626
9626
|
connector_type: this.constructor.name,
|
|
9627
9627
|
code,
|
|
@@ -9651,19 +9651,19 @@ class BaseAsyncConnector extends TaskSpawner {
|
|
|
9651
9651
|
this._sendPromiseResolve = undefined;
|
|
9652
9652
|
}
|
|
9653
9653
|
// Close transport
|
|
9654
|
-
logger$
|
|
9654
|
+
logger$14.debug('connector_closing_transport', {
|
|
9655
9655
|
connector_id: this._connectorFlowId,
|
|
9656
9656
|
connector_type: this.constructor.name,
|
|
9657
9657
|
timestamp: new Date().toISOString(),
|
|
9658
9658
|
});
|
|
9659
9659
|
await this._transportClose(code, reason);
|
|
9660
|
-
logger$
|
|
9660
|
+
logger$14.debug('connector_transport_closed', {
|
|
9661
9661
|
connector_id: this._connectorFlowId,
|
|
9662
9662
|
connector_type: this.constructor.name,
|
|
9663
9663
|
timestamp: new Date().toISOString(),
|
|
9664
9664
|
});
|
|
9665
9665
|
// Shutdown spawned tasks
|
|
9666
|
-
logger$
|
|
9666
|
+
logger$14.debug('connector_shutting_down_tasks', {
|
|
9667
9667
|
connector_id: this._connectorFlowId,
|
|
9668
9668
|
connector_type: this.constructor.name,
|
|
9669
9669
|
grace_period_ms: effectiveGracePeriod * 1000,
|
|
@@ -9675,14 +9675,14 @@ class BaseAsyncConnector extends TaskSpawner {
|
|
|
9675
9675
|
gracePeriod: effectiveGracePeriod * 1000, // Convert to milliseconds
|
|
9676
9676
|
joinTimeout: this._shutdownJoinTimeout,
|
|
9677
9677
|
});
|
|
9678
|
-
logger$
|
|
9678
|
+
logger$14.debug('connector_tasks_shutdown_complete', {
|
|
9679
9679
|
connector_id: this._connectorFlowId,
|
|
9680
9680
|
connector_type: this.constructor.name,
|
|
9681
9681
|
timestamp: new Date().toISOString(),
|
|
9682
9682
|
});
|
|
9683
9683
|
}
|
|
9684
9684
|
catch (error) {
|
|
9685
|
-
logger$
|
|
9685
|
+
logger$14.warning('task_shutdown_error', {
|
|
9686
9686
|
connector_id: this._connectorFlowId,
|
|
9687
9687
|
error: error instanceof Error ? error.message : String(error),
|
|
9688
9688
|
});
|
|
@@ -9695,7 +9695,7 @@ class BaseAsyncConnector extends TaskSpawner {
|
|
|
9695
9695
|
if (this._closeResolver) {
|
|
9696
9696
|
this._closeResolver();
|
|
9697
9697
|
}
|
|
9698
|
-
logger$
|
|
9698
|
+
logger$14.debug('connector_shutdown_complete', {
|
|
9699
9699
|
connector_id: this._connectorFlowId,
|
|
9700
9700
|
connector_type: this.constructor.name,
|
|
9701
9701
|
final_state: this._state,
|
|
@@ -9771,7 +9771,7 @@ class BoundedAsyncQueue {
|
|
|
9771
9771
|
}
|
|
9772
9772
|
}
|
|
9773
9773
|
|
|
9774
|
-
const logger$
|
|
9774
|
+
const logger$13 = getLogger('naylence.fame.connector.broadcast_channel_connector');
|
|
9775
9775
|
const BROADCAST_CHANNEL_CONNECTOR_TYPE = 'broadcast-channel-connector';
|
|
9776
9776
|
const DEFAULT_CHANNEL$7 = 'naylence-fabric';
|
|
9777
9777
|
const DEFAULT_INBOX_CAPACITY$7 = 2048;
|
|
@@ -9860,7 +9860,7 @@ let BroadcastChannelConnector$2 = class BroadcastChannelConnector extends BaseAs
|
|
|
9860
9860
|
this.localNodeId = normalizedLocalNodeId;
|
|
9861
9861
|
this.targetNodeId = BroadcastChannelConnector.normalizeTargetNodeId(config.initialTargetNodeId);
|
|
9862
9862
|
this.channel = new BroadcastChannel(this.channelName);
|
|
9863
|
-
logger$
|
|
9863
|
+
logger$13.debug('broadcast_channel_connector_created', {
|
|
9864
9864
|
channel: this.channelName,
|
|
9865
9865
|
connector_id: this.connectorId,
|
|
9866
9866
|
local_node_id: this.localNodeId,
|
|
@@ -9872,7 +9872,7 @@ let BroadcastChannelConnector$2 = class BroadcastChannelConnector extends BaseAs
|
|
|
9872
9872
|
this.onMsg = (event) => {
|
|
9873
9873
|
// Guard: Don't process if listener was unregistered
|
|
9874
9874
|
if (!this.listenerRegistered) {
|
|
9875
|
-
logger$
|
|
9875
|
+
logger$13.warning('broadcast_channel_message_after_unregister', {
|
|
9876
9876
|
channel: this.channelName,
|
|
9877
9877
|
connector_id: this.connectorId,
|
|
9878
9878
|
timestamp: new Date().toISOString(),
|
|
@@ -9880,7 +9880,7 @@ let BroadcastChannelConnector$2 = class BroadcastChannelConnector extends BaseAs
|
|
|
9880
9880
|
return;
|
|
9881
9881
|
}
|
|
9882
9882
|
const message = event.data;
|
|
9883
|
-
logger$
|
|
9883
|
+
logger$13.debug('broadcast_channel_raw_event', {
|
|
9884
9884
|
channel: this.channelName,
|
|
9885
9885
|
connector_id: this.connectorId,
|
|
9886
9886
|
message_type: message && typeof message === 'object'
|
|
@@ -9896,7 +9896,7 @@ let BroadcastChannelConnector$2 = class BroadcastChannelConnector extends BaseAs
|
|
|
9896
9896
|
const busMessage = message;
|
|
9897
9897
|
const senderNodeId = BroadcastChannelConnector.normalizeNodeId(busMessage.senderNodeId);
|
|
9898
9898
|
if (!senderNodeId) {
|
|
9899
|
-
logger$
|
|
9899
|
+
logger$13.debug('broadcast_channel_message_rejected', {
|
|
9900
9900
|
channel: this.channelName,
|
|
9901
9901
|
connector_id: this.connectorId,
|
|
9902
9902
|
reason: 'missing_sender_node_id',
|
|
@@ -9904,7 +9904,7 @@ let BroadcastChannelConnector$2 = class BroadcastChannelConnector extends BaseAs
|
|
|
9904
9904
|
return;
|
|
9905
9905
|
}
|
|
9906
9906
|
if (senderNodeId === this.localNodeId) {
|
|
9907
|
-
logger$
|
|
9907
|
+
logger$13.debug('broadcast_channel_message_rejected', {
|
|
9908
9908
|
channel: this.channelName,
|
|
9909
9909
|
connector_id: this.connectorId,
|
|
9910
9910
|
reason: 'self_echo',
|
|
@@ -9918,14 +9918,14 @@ let BroadcastChannelConnector$2 = class BroadcastChannelConnector extends BaseAs
|
|
|
9918
9918
|
}
|
|
9919
9919
|
const payload = BroadcastChannelConnector.coercePayload(busMessage.payload);
|
|
9920
9920
|
if (!payload) {
|
|
9921
|
-
logger$
|
|
9921
|
+
logger$13.debug('broadcast_channel_payload_rejected', {
|
|
9922
9922
|
channel: this.channelName,
|
|
9923
9923
|
connector_id: this.connectorId,
|
|
9924
9924
|
reason: 'unrecognized_payload_type',
|
|
9925
9925
|
});
|
|
9926
9926
|
return;
|
|
9927
9927
|
}
|
|
9928
|
-
logger$
|
|
9928
|
+
logger$13.debug('broadcast_channel_message_received', {
|
|
9929
9929
|
channel: this.channelName,
|
|
9930
9930
|
sender_id: message?.senderId,
|
|
9931
9931
|
sender_node_id: senderNodeId,
|
|
@@ -9954,14 +9954,14 @@ let BroadcastChannelConnector$2 = class BroadcastChannelConnector extends BaseAs
|
|
|
9954
9954
|
}
|
|
9955
9955
|
catch (error) {
|
|
9956
9956
|
if (error instanceof QueueFullError) {
|
|
9957
|
-
logger$
|
|
9957
|
+
logger$13.warning('broadcast_channel_receive_queue_full', {
|
|
9958
9958
|
channel: this.channelName,
|
|
9959
9959
|
inbox_capacity: this.inboxCapacity,
|
|
9960
9960
|
inbox_remaining_capacity: this.inbox.remainingCapacity,
|
|
9961
9961
|
});
|
|
9962
9962
|
}
|
|
9963
9963
|
else {
|
|
9964
|
-
logger$
|
|
9964
|
+
logger$13.error('broadcast_channel_receive_error', {
|
|
9965
9965
|
channel: this.channelName,
|
|
9966
9966
|
error: error instanceof Error ? error.message : String(error),
|
|
9967
9967
|
});
|
|
@@ -9975,7 +9975,7 @@ let BroadcastChannelConnector$2 = class BroadcastChannelConnector extends BaseAs
|
|
|
9975
9975
|
// Setup visibility change monitoring
|
|
9976
9976
|
this.visibilityChangeHandler = () => {
|
|
9977
9977
|
const isHidden = document.hidden;
|
|
9978
|
-
logger$
|
|
9978
|
+
logger$13.debug('broadcast_channel_visibility_changed', {
|
|
9979
9979
|
channel: this.channelName,
|
|
9980
9980
|
connector_id: this.connectorId,
|
|
9981
9981
|
visibility: isHidden ? 'hidden' : 'visible',
|
|
@@ -9984,7 +9984,7 @@ let BroadcastChannelConnector$2 = class BroadcastChannelConnector extends BaseAs
|
|
|
9984
9984
|
// Pause/resume connector based on visibility
|
|
9985
9985
|
if (isHidden && this.state === core.ConnectorState.STARTED) {
|
|
9986
9986
|
this.pause().catch((err) => {
|
|
9987
|
-
logger$
|
|
9987
|
+
logger$13.warning('broadcast_channel_pause_failed', {
|
|
9988
9988
|
channel: this.channelName,
|
|
9989
9989
|
connector_id: this.connectorId,
|
|
9990
9990
|
error: err instanceof Error ? err.message : String(err),
|
|
@@ -9993,7 +9993,7 @@ let BroadcastChannelConnector$2 = class BroadcastChannelConnector extends BaseAs
|
|
|
9993
9993
|
}
|
|
9994
9994
|
else if (!isHidden && this.state === core.ConnectorState.PAUSED) {
|
|
9995
9995
|
this.resume().catch((err) => {
|
|
9996
|
-
logger$
|
|
9996
|
+
logger$13.warning('broadcast_channel_resume_failed', {
|
|
9997
9997
|
channel: this.channelName,
|
|
9998
9998
|
connector_id: this.connectorId,
|
|
9999
9999
|
error: err instanceof Error ? err.message : String(err),
|
|
@@ -10007,7 +10007,7 @@ let BroadcastChannelConnector$2 = class BroadcastChannelConnector extends BaseAs
|
|
|
10007
10007
|
// Track page lifecycle events to detect browser unload/discard
|
|
10008
10008
|
if (typeof window !== 'undefined') {
|
|
10009
10009
|
const lifecycleLogger = (event) => {
|
|
10010
|
-
logger$
|
|
10010
|
+
logger$13.debug('broadcast_channel_page_lifecycle', {
|
|
10011
10011
|
channel: this.channelName,
|
|
10012
10012
|
connector_id: this.connectorId,
|
|
10013
10013
|
event_type: event.type,
|
|
@@ -10023,7 +10023,7 @@ let BroadcastChannelConnector$2 = class BroadcastChannelConnector extends BaseAs
|
|
|
10023
10023
|
document.addEventListener('resume', lifecycleLogger);
|
|
10024
10024
|
}
|
|
10025
10025
|
// Log initial state with detailed visibility info
|
|
10026
|
-
logger$
|
|
10026
|
+
logger$13.debug('broadcast_channel_initial_visibility', {
|
|
10027
10027
|
channel: this.channelName,
|
|
10028
10028
|
connector_id: this.connectorId,
|
|
10029
10029
|
visibility: document.hidden ? 'hidden' : 'visible',
|
|
@@ -10055,14 +10055,14 @@ let BroadcastChannelConnector$2 = class BroadcastChannelConnector extends BaseAs
|
|
|
10055
10055
|
}
|
|
10056
10056
|
catch (error) {
|
|
10057
10057
|
if (error instanceof QueueFullError) {
|
|
10058
|
-
logger$
|
|
10058
|
+
logger$13.warning('broadcast_channel_push_queue_full', {
|
|
10059
10059
|
channel: this.channelName,
|
|
10060
10060
|
inbox_capacity: this.inboxCapacity,
|
|
10061
10061
|
inbox_remaining_capacity: this.inbox.remainingCapacity,
|
|
10062
10062
|
});
|
|
10063
10063
|
throw error;
|
|
10064
10064
|
}
|
|
10065
|
-
logger$
|
|
10065
|
+
logger$13.error('broadcast_channel_push_failed', {
|
|
10066
10066
|
channel: this.channelName,
|
|
10067
10067
|
error: error instanceof Error ? error.message : String(error),
|
|
10068
10068
|
});
|
|
@@ -10072,7 +10072,7 @@ let BroadcastChannelConnector$2 = class BroadcastChannelConnector extends BaseAs
|
|
|
10072
10072
|
async _transportSendBytes(data) {
|
|
10073
10073
|
ensureBroadcastEnvironment();
|
|
10074
10074
|
const targetNodeId = this.targetNodeId ?? '*';
|
|
10075
|
-
logger$
|
|
10075
|
+
logger$13.debug('broadcast_channel_message_sending', {
|
|
10076
10076
|
channel: this.channelName,
|
|
10077
10077
|
sender_id: this.connectorId,
|
|
10078
10078
|
sender_node_id: this.localNodeId,
|
|
@@ -10093,7 +10093,7 @@ let BroadcastChannelConnector$2 = class BroadcastChannelConnector extends BaseAs
|
|
|
10093
10093
|
return item;
|
|
10094
10094
|
}
|
|
10095
10095
|
async _transportClose(code, reason) {
|
|
10096
|
-
logger$
|
|
10096
|
+
logger$13.debug('broadcast_channel_transport_closing', {
|
|
10097
10097
|
channel: this.channelName,
|
|
10098
10098
|
connector_id: this.connectorId,
|
|
10099
10099
|
code,
|
|
@@ -10102,14 +10102,14 @@ let BroadcastChannelConnector$2 = class BroadcastChannelConnector extends BaseAs
|
|
|
10102
10102
|
timestamp: new Date().toISOString(),
|
|
10103
10103
|
});
|
|
10104
10104
|
if (this.listenerRegistered) {
|
|
10105
|
-
logger$
|
|
10105
|
+
logger$13.debug('broadcast_channel_removing_listener', {
|
|
10106
10106
|
channel: this.channelName,
|
|
10107
10107
|
connector_id: this.connectorId,
|
|
10108
10108
|
timestamp: new Date().toISOString(),
|
|
10109
10109
|
});
|
|
10110
10110
|
this.channel.removeEventListener('message', this.onMsg);
|
|
10111
10111
|
this.listenerRegistered = false;
|
|
10112
|
-
logger$
|
|
10112
|
+
logger$13.debug('broadcast_channel_listener_removed', {
|
|
10113
10113
|
channel: this.channelName,
|
|
10114
10114
|
connector_id: this.connectorId,
|
|
10115
10115
|
timestamp: new Date().toISOString(),
|
|
@@ -10122,13 +10122,13 @@ let BroadcastChannelConnector$2 = class BroadcastChannelConnector extends BaseAs
|
|
|
10122
10122
|
this.visibilityChangeListenerRegistered = false;
|
|
10123
10123
|
this.visibilityChangeHandler = undefined;
|
|
10124
10124
|
}
|
|
10125
|
-
logger$
|
|
10125
|
+
logger$13.debug('broadcast_channel_closing', {
|
|
10126
10126
|
channel: this.channelName,
|
|
10127
10127
|
connector_id: this.connectorId,
|
|
10128
10128
|
timestamp: new Date().toISOString(),
|
|
10129
10129
|
});
|
|
10130
10130
|
this.channel.close();
|
|
10131
|
-
logger$
|
|
10131
|
+
logger$13.debug('broadcast_channel_closed', {
|
|
10132
10132
|
channel: this.channelName,
|
|
10133
10133
|
connector_id: this.connectorId,
|
|
10134
10134
|
timestamp: new Date().toISOString(),
|
|
@@ -10152,7 +10152,7 @@ let BroadcastChannelConnector$2 = class BroadcastChannelConnector extends BaseAs
|
|
|
10152
10152
|
if (targetNodeId &&
|
|
10153
10153
|
targetNodeId !== '*' &&
|
|
10154
10154
|
targetNodeId !== this.localNodeId) {
|
|
10155
|
-
logger$
|
|
10155
|
+
logger$13.debug('broadcast_channel_message_rejected', {
|
|
10156
10156
|
channel: this.channelName,
|
|
10157
10157
|
connector_id: this.connectorId,
|
|
10158
10158
|
reason: 'wildcard_target_mismatch',
|
|
@@ -10168,7 +10168,7 @@ let BroadcastChannelConnector$2 = class BroadcastChannelConnector extends BaseAs
|
|
|
10168
10168
|
if (expectedSender &&
|
|
10169
10169
|
expectedSender !== '*' &&
|
|
10170
10170
|
senderNodeId !== expectedSender) {
|
|
10171
|
-
logger$
|
|
10171
|
+
logger$13.debug('broadcast_channel_message_rejected', {
|
|
10172
10172
|
channel: this.channelName,
|
|
10173
10173
|
connector_id: this.connectorId,
|
|
10174
10174
|
reason: 'unexpected_sender',
|
|
@@ -10181,7 +10181,7 @@ let BroadcastChannelConnector$2 = class BroadcastChannelConnector extends BaseAs
|
|
|
10181
10181
|
if (targetNodeId &&
|
|
10182
10182
|
targetNodeId !== '*' &&
|
|
10183
10183
|
targetNodeId !== this.localNodeId) {
|
|
10184
|
-
logger$
|
|
10184
|
+
logger$13.debug('broadcast_channel_message_rejected', {
|
|
10185
10185
|
channel: this.channelName,
|
|
10186
10186
|
connector_id: this.connectorId,
|
|
10187
10187
|
reason: 'unexpected_target',
|
|
@@ -10206,7 +10206,7 @@ let BroadcastChannelConnector$2 = class BroadcastChannelConnector extends BaseAs
|
|
|
10206
10206
|
return 'unknown';
|
|
10207
10207
|
}
|
|
10208
10208
|
logInboxSnapshot(event, extra = {}) {
|
|
10209
|
-
logger$
|
|
10209
|
+
logger$13.debug(event, {
|
|
10210
10210
|
channel: this.channelName,
|
|
10211
10211
|
connector_id: this.connectorId,
|
|
10212
10212
|
connector_state: this.state,
|
|
@@ -10222,7 +10222,7 @@ let BroadcastChannelConnector$2 = class BroadcastChannelConnector extends BaseAs
|
|
|
10222
10222
|
await super.start(inboundHandler);
|
|
10223
10223
|
// After transitioning to STARTED, check if tab is already hidden
|
|
10224
10224
|
if (typeof document !== 'undefined' && document.hidden) {
|
|
10225
|
-
logger$
|
|
10225
|
+
logger$13.debug('broadcast_channel_start_in_hidden_tab', {
|
|
10226
10226
|
channel: this.channelName,
|
|
10227
10227
|
connector_id: this.connectorId,
|
|
10228
10228
|
document_hidden: document.hidden,
|
|
@@ -10232,7 +10232,7 @@ let BroadcastChannelConnector$2 = class BroadcastChannelConnector extends BaseAs
|
|
|
10232
10232
|
});
|
|
10233
10233
|
// Immediately pause if tab is hidden at start time
|
|
10234
10234
|
await this.pause().catch((err) => {
|
|
10235
|
-
logger$
|
|
10235
|
+
logger$13.warning('broadcast_channel_initial_pause_failed', {
|
|
10236
10236
|
channel: this.channelName,
|
|
10237
10237
|
connector_id: this.connectorId,
|
|
10238
10238
|
error: err instanceof Error ? err.message : String(err),
|
|
@@ -10250,7 +10250,7 @@ let BroadcastChannelConnector$2 = class BroadcastChannelConnector extends BaseAs
|
|
|
10250
10250
|
return;
|
|
10251
10251
|
}
|
|
10252
10252
|
this.targetNodeId = normalized;
|
|
10253
|
-
logger$
|
|
10253
|
+
logger$13.debug('broadcast_channel_target_updated', {
|
|
10254
10254
|
channel: this.channelName,
|
|
10255
10255
|
connector_id: this.connectorId,
|
|
10256
10256
|
local_node_id: this.localNodeId,
|
|
@@ -10260,7 +10260,7 @@ let BroadcastChannelConnector$2 = class BroadcastChannelConnector extends BaseAs
|
|
|
10260
10260
|
}
|
|
10261
10261
|
setWildcardTarget() {
|
|
10262
10262
|
this.targetNodeId = '*';
|
|
10263
|
-
logger$
|
|
10263
|
+
logger$13.debug('broadcast_channel_target_updated', {
|
|
10264
10264
|
channel: this.channelName,
|
|
10265
10265
|
connector_id: this.connectorId,
|
|
10266
10266
|
local_node_id: this.localNodeId,
|
|
@@ -10433,7 +10433,7 @@ function broadcastChannelGrantToConnectorConfig(grant) {
|
|
|
10433
10433
|
return config;
|
|
10434
10434
|
}
|
|
10435
10435
|
|
|
10436
|
-
const logger$
|
|
10436
|
+
const logger$12 = getLogger('naylence.fame.node.upstream_session_manager');
|
|
10437
10437
|
function isPlainRecord$4(value) {
|
|
10438
10438
|
if (typeof value !== 'object' || value === null) {
|
|
10439
10439
|
return false;
|
|
@@ -10506,6 +10506,7 @@ function normalizeOptions$k(options) {
|
|
|
10506
10506
|
const onEpochChangeValue = pickOption$2(record, 'onEpochChange', 'on_epoch_change');
|
|
10507
10507
|
const onEpochChange = typeof onEpochChangeValue === 'function' ? onEpochChangeValue : undefined;
|
|
10508
10508
|
const admissionClient = pickOption$2(record, 'admissionClient', 'admission_client');
|
|
10509
|
+
const retryPolicy = pickOption$2(record, 'retryPolicy', 'retry_policy');
|
|
10509
10510
|
return {
|
|
10510
10511
|
node,
|
|
10511
10512
|
attachClient,
|
|
@@ -10517,6 +10518,7 @@ function normalizeOptions$k(options) {
|
|
|
10517
10518
|
onAttach: validatedOnAttach,
|
|
10518
10519
|
onEpochChange,
|
|
10519
10520
|
admissionClient: admissionClient ?? undefined,
|
|
10521
|
+
retryPolicy: retryPolicy ?? undefined,
|
|
10520
10522
|
};
|
|
10521
10523
|
}
|
|
10522
10524
|
class UpstreamSessionManager extends TaskSpawner {
|
|
@@ -10536,6 +10538,7 @@ class UpstreamSessionManager extends TaskSpawner {
|
|
|
10536
10538
|
this.hadSuccessfulAttach = false;
|
|
10537
10539
|
this.lastConnectorState = null;
|
|
10538
10540
|
this.connectEpoch = 0;
|
|
10541
|
+
this.initialAttempts = 0;
|
|
10539
10542
|
this._visibilityHandler = null;
|
|
10540
10543
|
const options = normalizeOptions$k(optionsInput);
|
|
10541
10544
|
this.node = options.node;
|
|
@@ -10549,31 +10552,34 @@ class UpstreamSessionManager extends TaskSpawner {
|
|
|
10549
10552
|
this.admissionClient =
|
|
10550
10553
|
options.admissionClient ?? options.node.admissionClient;
|
|
10551
10554
|
this.wrappedHandler = this.makeHeartbeatEnabledHandler(options.inboundHandler);
|
|
10552
|
-
|
|
10555
|
+
// Store the connection retry policy (can be null, in which case default behavior applies)
|
|
10556
|
+
this.connectionRetryPolicy = options.retryPolicy ?? null;
|
|
10557
|
+
logger$12.debug('created_upstream_session_manager', {
|
|
10553
10558
|
target_system_id: this.targetSystemId,
|
|
10559
|
+
has_retry_policy: this.connectionRetryPolicy !== null,
|
|
10554
10560
|
});
|
|
10555
10561
|
}
|
|
10556
10562
|
get systemId() {
|
|
10557
10563
|
return this.targetSystemId;
|
|
10558
10564
|
}
|
|
10559
10565
|
setupVisibilityListener() {
|
|
10560
|
-
logger$
|
|
10566
|
+
logger$12.debug('setup_visibility_listener_called', {
|
|
10561
10567
|
has_document: typeof document !== 'undefined',
|
|
10562
10568
|
});
|
|
10563
10569
|
if (typeof document !== 'undefined' && document.addEventListener) {
|
|
10564
10570
|
this._visibilityHandler = () => {
|
|
10565
|
-
logger$
|
|
10571
|
+
logger$12.debug('visibility_change_event_fired', {
|
|
10566
10572
|
state: document.visibilityState,
|
|
10567
10573
|
});
|
|
10568
10574
|
if (document.visibilityState === 'visible') {
|
|
10569
|
-
logger$
|
|
10575
|
+
logger$12.debug('visibility_change_detected_waking_up');
|
|
10570
10576
|
this.wakeEvent.set();
|
|
10571
10577
|
}
|
|
10572
10578
|
};
|
|
10573
10579
|
document.addEventListener('visibilitychange', this._visibilityHandler);
|
|
10574
10580
|
}
|
|
10575
10581
|
else {
|
|
10576
|
-
logger$
|
|
10582
|
+
logger$12.debug('setup_visibility_listener_skipped_no_document');
|
|
10577
10583
|
}
|
|
10578
10584
|
}
|
|
10579
10585
|
teardownVisibilityListener() {
|
|
@@ -10606,13 +10612,13 @@ class UpstreamSessionManager extends TaskSpawner {
|
|
|
10606
10612
|
}
|
|
10607
10613
|
throw new FameConnectError('Upstream session manager failed to attach');
|
|
10608
10614
|
}
|
|
10609
|
-
logger$
|
|
10615
|
+
logger$12.debug('upstream_session_manager_started');
|
|
10610
10616
|
}
|
|
10611
10617
|
getActiveConnector() {
|
|
10612
10618
|
return this.connector;
|
|
10613
10619
|
}
|
|
10614
10620
|
async stop() {
|
|
10615
|
-
logger$
|
|
10621
|
+
logger$12.debug('upstream_session_manager_stopping');
|
|
10616
10622
|
this.teardownVisibilityListener();
|
|
10617
10623
|
this.stopEvent.set();
|
|
10618
10624
|
this.currentStopSubtasks?.set();
|
|
@@ -10623,7 +10629,7 @@ class UpstreamSessionManager extends TaskSpawner {
|
|
|
10623
10629
|
}
|
|
10624
10630
|
catch (error) {
|
|
10625
10631
|
if (!(error instanceof TaskCancelledError)) {
|
|
10626
|
-
logger$
|
|
10632
|
+
logger$12.debug('fsm_task_stopped_with_error', {
|
|
10627
10633
|
error: error.message,
|
|
10628
10634
|
});
|
|
10629
10635
|
}
|
|
@@ -10632,13 +10638,13 @@ class UpstreamSessionManager extends TaskSpawner {
|
|
|
10632
10638
|
}
|
|
10633
10639
|
if (this.connector) {
|
|
10634
10640
|
await this.connector.stop().catch((error) => {
|
|
10635
|
-
logger$
|
|
10641
|
+
logger$12.debug('connector_stop_error', {
|
|
10636
10642
|
error: error.message,
|
|
10637
10643
|
});
|
|
10638
10644
|
});
|
|
10639
10645
|
this.connector = null;
|
|
10640
10646
|
}
|
|
10641
|
-
logger$
|
|
10647
|
+
logger$12.debug('upstream_session_manager_stopped');
|
|
10642
10648
|
}
|
|
10643
10649
|
async send(envelope) {
|
|
10644
10650
|
if (this.messageQueue.length >= UpstreamSessionManager.TX_QUEUE_MAX) {
|
|
@@ -10666,11 +10672,14 @@ class UpstreamSessionManager extends TaskSpawner {
|
|
|
10666
10672
|
}
|
|
10667
10673
|
async fsmLoop() {
|
|
10668
10674
|
let delay = UpstreamSessionManager.BACKOFF_INITIAL;
|
|
10675
|
+
this.initialAttempts = 0;
|
|
10669
10676
|
while (!this.stopEvent.isSet()) {
|
|
10670
10677
|
const startTime = Date.now();
|
|
10678
|
+
this.initialAttempts += 1;
|
|
10671
10679
|
try {
|
|
10672
10680
|
await this.connectCycle();
|
|
10673
10681
|
delay = UpstreamSessionManager.BACKOFF_INITIAL;
|
|
10682
|
+
this.initialAttempts = 0; // Reset on success
|
|
10674
10683
|
}
|
|
10675
10684
|
catch (error) {
|
|
10676
10685
|
// Reset backoff if the connection was alive for more than 10 seconds
|
|
@@ -10680,32 +10689,38 @@ class UpstreamSessionManager extends TaskSpawner {
|
|
|
10680
10689
|
if (error instanceof TaskCancelledError) {
|
|
10681
10690
|
throw error;
|
|
10682
10691
|
}
|
|
10692
|
+
// Determine if we should fail-fast or retry
|
|
10693
|
+
const shouldFailFast = this.shouldFailFastOnError(error);
|
|
10683
10694
|
if (error instanceof FameTransportClose ||
|
|
10684
10695
|
error instanceof FameConnectError) {
|
|
10685
|
-
logger$
|
|
10696
|
+
logger$12.warning('upstream_link_closed', {
|
|
10686
10697
|
error: error.message,
|
|
10687
|
-
will_retry:
|
|
10698
|
+
will_retry: !shouldFailFast,
|
|
10699
|
+
attempt: this.initialAttempts,
|
|
10700
|
+
has_retry_policy: this.connectionRetryPolicy !== null,
|
|
10688
10701
|
});
|
|
10689
|
-
if (
|
|
10702
|
+
if (shouldFailFast && error instanceof FameConnectError) {
|
|
10690
10703
|
throw error;
|
|
10691
10704
|
}
|
|
10692
10705
|
}
|
|
10693
10706
|
else {
|
|
10694
10707
|
const err = error;
|
|
10695
10708
|
if (err.name === 'OAuth2PkceRedirectInitiatedError') {
|
|
10696
|
-
logger$
|
|
10709
|
+
logger$12.info('upstream_link_redirecting', {
|
|
10697
10710
|
error: err.message,
|
|
10698
10711
|
will_retry: true,
|
|
10699
10712
|
});
|
|
10700
10713
|
}
|
|
10701
10714
|
else {
|
|
10702
|
-
logger$
|
|
10715
|
+
logger$12.warning('upstream_link_closed', {
|
|
10703
10716
|
error: err.message,
|
|
10704
|
-
will_retry:
|
|
10717
|
+
will_retry: !shouldFailFast,
|
|
10718
|
+
attempt: this.initialAttempts,
|
|
10719
|
+
has_retry_policy: this.connectionRetryPolicy !== null,
|
|
10705
10720
|
exc_info: true,
|
|
10706
10721
|
});
|
|
10707
10722
|
}
|
|
10708
|
-
if (
|
|
10723
|
+
if (shouldFailFast) {
|
|
10709
10724
|
throw error;
|
|
10710
10725
|
}
|
|
10711
10726
|
}
|
|
@@ -10713,52 +10728,77 @@ class UpstreamSessionManager extends TaskSpawner {
|
|
|
10713
10728
|
}
|
|
10714
10729
|
}
|
|
10715
10730
|
}
|
|
10731
|
+
/**
|
|
10732
|
+
* Determine whether to fail immediately or continue retrying.
|
|
10733
|
+
* Returns true if we should throw the error instead of retrying.
|
|
10734
|
+
*/
|
|
10735
|
+
shouldFailFastOnError(error) {
|
|
10736
|
+
// If no policy is configured, use legacy behavior (fail-fast after first attempt)
|
|
10737
|
+
if (!this.connectionRetryPolicy) {
|
|
10738
|
+
// After first successful attach, always retry (existing behavior)
|
|
10739
|
+
if (this.hadSuccessfulAttach) {
|
|
10740
|
+
return false;
|
|
10741
|
+
}
|
|
10742
|
+
// Without a policy, fail on first error
|
|
10743
|
+
return true;
|
|
10744
|
+
}
|
|
10745
|
+
// Delegate decision to the policy
|
|
10746
|
+
const shouldRetry = this.connectionRetryPolicy.shouldRetry({
|
|
10747
|
+
hadSuccessfulAttach: this.hadSuccessfulAttach,
|
|
10748
|
+
attemptNumber: this.initialAttempts,
|
|
10749
|
+
error,
|
|
10750
|
+
});
|
|
10751
|
+
return !shouldRetry;
|
|
10752
|
+
}
|
|
10716
10753
|
async applyBackoff(delay) {
|
|
10717
10754
|
const jitter = Math.random() * delay;
|
|
10718
|
-
await this.sleepWithStop(delay + jitter);
|
|
10755
|
+
const wasWoken = await this.sleepWithStop(delay + jitter);
|
|
10756
|
+
// If sleep was interrupted by visibility change (user returned to tab),
|
|
10757
|
+
// reset backoff to initial delay for immediate retry with fresh backoff
|
|
10758
|
+
if (wasWoken) {
|
|
10759
|
+
logger$12.debug('backoff_reset_on_visibility_change', {
|
|
10760
|
+
previous_delay: delay,
|
|
10761
|
+
new_delay: UpstreamSessionManager.BACKOFF_INITIAL,
|
|
10762
|
+
});
|
|
10763
|
+
return UpstreamSessionManager.BACKOFF_INITIAL;
|
|
10764
|
+
}
|
|
10719
10765
|
return Math.min(delay * 2, UpstreamSessionManager.BACKOFF_CAP);
|
|
10720
10766
|
}
|
|
10767
|
+
/**
|
|
10768
|
+
* Sleep for the specified duration, but can be interrupted by stop or wake events.
|
|
10769
|
+
* @returns true if interrupted by wake event (e.g., visibility change), false otherwise
|
|
10770
|
+
*/
|
|
10721
10771
|
async sleepWithStop(delaySeconds) {
|
|
10722
10772
|
if (delaySeconds <= 0) {
|
|
10723
|
-
return;
|
|
10724
|
-
}
|
|
10725
|
-
// If the document is visible, cap the backoff delay to improve UX
|
|
10726
|
-
// This ensures that if the user is watching, we retry quickly (e.g. 1s)
|
|
10727
|
-
// instead of waiting for the full exponential backoff (up to 30s).
|
|
10728
|
-
let effectiveDelay = delaySeconds;
|
|
10729
|
-
if (typeof document !== 'undefined' &&
|
|
10730
|
-
document.visibilityState === 'visible') {
|
|
10731
|
-
effectiveDelay = Math.min(delaySeconds, 1.0);
|
|
10732
|
-
if (effectiveDelay < delaySeconds) {
|
|
10733
|
-
logger$11.debug('sleep_reduced_document_visible', {
|
|
10734
|
-
original: delaySeconds,
|
|
10735
|
-
new: effectiveDelay,
|
|
10736
|
-
});
|
|
10737
|
-
}
|
|
10773
|
+
return false;
|
|
10738
10774
|
}
|
|
10775
|
+
// Check if wake event is already set (e.g., visibility just changed)
|
|
10739
10776
|
if (this.wakeEvent.isSet()) {
|
|
10740
10777
|
this.wakeEvent.clear();
|
|
10741
|
-
|
|
10778
|
+
logger$12.debug('sleep_skipped_wake_event_pending');
|
|
10779
|
+
return true;
|
|
10742
10780
|
}
|
|
10743
10781
|
let timeout;
|
|
10744
10782
|
const sleepPromise = new Promise((resolve) => {
|
|
10745
10783
|
timeout = setTimeout(() => {
|
|
10746
10784
|
timeout = undefined;
|
|
10747
10785
|
resolve();
|
|
10748
|
-
},
|
|
10786
|
+
}, delaySeconds * 1000);
|
|
10749
10787
|
});
|
|
10750
10788
|
await Promise.race([
|
|
10751
10789
|
sleepPromise,
|
|
10752
10790
|
this.stopEvent.wait(),
|
|
10753
10791
|
this.wakeEvent.wait(),
|
|
10754
10792
|
]);
|
|
10755
|
-
|
|
10756
|
-
|
|
10793
|
+
const wasWoken = this.wakeEvent.isSet();
|
|
10794
|
+
if (wasWoken) {
|
|
10795
|
+
logger$12.debug('sleep_interrupted_by_wake_event');
|
|
10757
10796
|
this.wakeEvent.clear();
|
|
10758
10797
|
}
|
|
10759
10798
|
if (timeout !== undefined) {
|
|
10760
10799
|
clearTimeout(timeout);
|
|
10761
10800
|
}
|
|
10801
|
+
return wasWoken;
|
|
10762
10802
|
}
|
|
10763
10803
|
getNodeAttachGrant(connectionGrants) {
|
|
10764
10804
|
if (!connectionGrants) {
|
|
@@ -10815,7 +10855,7 @@ class UpstreamSessionManager extends TaskSpawner {
|
|
|
10815
10855
|
await connector.start(this.wrappedHandler);
|
|
10816
10856
|
this.connector = connector;
|
|
10817
10857
|
const callbackGrants = this.node.gatherSupportedCallbackGrants();
|
|
10818
|
-
logger$
|
|
10858
|
+
logger$12.debug('callback_grants_before_augmentation', {
|
|
10819
10859
|
count: callbackGrants.length,
|
|
10820
10860
|
types: callbackGrants.map((g) => g.type),
|
|
10821
10861
|
});
|
|
@@ -10825,7 +10865,7 @@ class UpstreamSessionManager extends TaskSpawner {
|
|
|
10825
10865
|
const broadcastCallbackGrant = shouldAddBroadcastGrant
|
|
10826
10866
|
? this.createBroadcastCallbackGrant(grant)
|
|
10827
10867
|
: null;
|
|
10828
|
-
logger$
|
|
10868
|
+
logger$12.debug('broadcast_callback_grant_check', {
|
|
10829
10869
|
should_add: shouldAddBroadcastGrant,
|
|
10830
10870
|
grant_created: !!broadcastCallbackGrant,
|
|
10831
10871
|
});
|
|
@@ -10844,12 +10884,12 @@ class UpstreamSessionManager extends TaskSpawner {
|
|
|
10844
10884
|
const isDuplicate = callbackGrants.some((existing) => JSON.stringify(existing) === JSON.stringify(grant));
|
|
10845
10885
|
if (!isDuplicate) {
|
|
10846
10886
|
callbackGrants.push(grant);
|
|
10847
|
-
logger$
|
|
10887
|
+
logger$12.debug('added_connection_grant_as_callback', {
|
|
10848
10888
|
type: grant.type,
|
|
10849
10889
|
});
|
|
10850
10890
|
}
|
|
10851
10891
|
else {
|
|
10852
|
-
logger$
|
|
10892
|
+
logger$12.debug('skipped_duplicate_connection_grant', {
|
|
10853
10893
|
type: grant.type,
|
|
10854
10894
|
});
|
|
10855
10895
|
}
|
|
@@ -10861,12 +10901,12 @@ class UpstreamSessionManager extends TaskSpawner {
|
|
|
10861
10901
|
if (broadcastCallbackGrant &&
|
|
10862
10902
|
this.shouldAdvertiseBroadcastGrant(grant, callbackGrants)) {
|
|
10863
10903
|
callbackGrants.push(broadcastCallbackGrant);
|
|
10864
|
-
logger$
|
|
10904
|
+
logger$12.debug('added_broadcast_callback_grant');
|
|
10865
10905
|
}
|
|
10866
10906
|
else if (broadcastCallbackGrant) {
|
|
10867
|
-
logger$
|
|
10907
|
+
logger$12.debug('skipped_duplicate_broadcast_callback_grant');
|
|
10868
10908
|
}
|
|
10869
|
-
logger$
|
|
10909
|
+
logger$12.debug('callback_grants_after_augmentation', {
|
|
10870
10910
|
count: callbackGrants.length,
|
|
10871
10911
|
types: callbackGrants.map((g) => g.type),
|
|
10872
10912
|
});
|
|
@@ -10879,7 +10919,7 @@ class UpstreamSessionManager extends TaskSpawner {
|
|
|
10879
10919
|
targetAware.setTargetNodeId(this.targetSystemId);
|
|
10880
10920
|
}
|
|
10881
10921
|
catch (error) {
|
|
10882
|
-
logger$
|
|
10922
|
+
logger$12.warning('broadcast_channel_target_apply_failed', {
|
|
10883
10923
|
error: error instanceof Error ? error.message : String(error),
|
|
10884
10924
|
target_node_id: this.targetSystemId,
|
|
10885
10925
|
});
|
|
@@ -10901,14 +10941,14 @@ class UpstreamSessionManager extends TaskSpawner {
|
|
|
10901
10941
|
});
|
|
10902
10942
|
}
|
|
10903
10943
|
else {
|
|
10904
|
-
logger$
|
|
10944
|
+
logger$12.warning('parent_epoch_changed', { epoch });
|
|
10905
10945
|
}
|
|
10906
10946
|
}
|
|
10907
10947
|
if (!this.readyEvent.isSet()) {
|
|
10908
10948
|
this.readyEvent.set();
|
|
10909
10949
|
}
|
|
10910
10950
|
if (this.messageQueue.length > 0) {
|
|
10911
|
-
logger$
|
|
10951
|
+
logger$12.debug('flushing_buffered_frames', {
|
|
10912
10952
|
queue_size: this.messageQueue.length,
|
|
10913
10953
|
});
|
|
10914
10954
|
this.queueEvent.set();
|
|
@@ -10925,12 +10965,12 @@ class UpstreamSessionManager extends TaskSpawner {
|
|
|
10925
10965
|
name: `expiry-guard-${this.connectEpoch}`,
|
|
10926
10966
|
});
|
|
10927
10967
|
if (this.hadSuccessfulAttach) {
|
|
10928
|
-
logger$
|
|
10968
|
+
logger$12.debug('reconnected_to_upstream', {
|
|
10929
10969
|
attach_expires_at: attachInfo.attachExpiresAt?.toISOString?.() ?? null,
|
|
10930
10970
|
});
|
|
10931
10971
|
}
|
|
10932
10972
|
else {
|
|
10933
|
-
logger$
|
|
10973
|
+
logger$12.debug('connected_to_upstream', {
|
|
10934
10974
|
attach_expires_at: attachInfo.attachExpiresAt?.toISOString?.() ?? null,
|
|
10935
10975
|
});
|
|
10936
10976
|
}
|
|
@@ -10948,18 +10988,18 @@ class UpstreamSessionManager extends TaskSpawner {
|
|
|
10948
10988
|
this.currentStopSubtasks = null;
|
|
10949
10989
|
await Promise.allSettled(tasks.map((task) => task.promise));
|
|
10950
10990
|
if (this.connector) {
|
|
10951
|
-
logger$
|
|
10991
|
+
logger$12.debug('upstream_stopping_old_connector', {
|
|
10952
10992
|
connect_epoch: this.connectEpoch,
|
|
10953
10993
|
target_system_id: this.targetSystemId,
|
|
10954
10994
|
timestamp: new Date().toISOString(),
|
|
10955
10995
|
});
|
|
10956
10996
|
await this.connector.stop().catch((err) => {
|
|
10957
|
-
logger$
|
|
10997
|
+
logger$12.warning('upstream_connector_stop_error', {
|
|
10958
10998
|
connect_epoch: this.connectEpoch,
|
|
10959
10999
|
error: err instanceof Error ? err.message : String(err),
|
|
10960
11000
|
});
|
|
10961
11001
|
});
|
|
10962
|
-
logger$
|
|
11002
|
+
logger$12.debug('upstream_old_connector_stopped', {
|
|
10963
11003
|
connect_epoch: this.connectEpoch,
|
|
10964
11004
|
target_system_id: this.targetSystemId,
|
|
10965
11005
|
timestamp: new Date().toISOString(),
|
|
@@ -11012,7 +11052,7 @@ class UpstreamSessionManager extends TaskSpawner {
|
|
|
11012
11052
|
});
|
|
11013
11053
|
}
|
|
11014
11054
|
catch (error) {
|
|
11015
|
-
logger$
|
|
11055
|
+
logger$12.debug('broadcast_callback_grant_generation_failed', {
|
|
11016
11056
|
error: error instanceof Error ? error.message : String(error),
|
|
11017
11057
|
});
|
|
11018
11058
|
return null;
|
|
@@ -11067,7 +11107,7 @@ class UpstreamSessionManager extends TaskSpawner {
|
|
|
11067
11107
|
}
|
|
11068
11108
|
}
|
|
11069
11109
|
async heartbeatLoop(connector, stopEvt, signal) {
|
|
11070
|
-
logger$
|
|
11110
|
+
logger$12.debug('starting_heartbeat_loop');
|
|
11071
11111
|
const intervalMs = UpstreamSessionManager.HEARTBEAT_INTERVAL * 1000;
|
|
11072
11112
|
const graceMs = intervalMs * UpstreamSessionManager.HEARTBEAT_GRACE;
|
|
11073
11113
|
this.lastHeartbeatAckTime = Date.now();
|
|
@@ -11103,7 +11143,7 @@ class UpstreamSessionManager extends TaskSpawner {
|
|
|
11103
11143
|
// Skip heartbeat if connector is paused (e.g., tab is hidden)
|
|
11104
11144
|
// Keep ack time current so we don't timeout immediately after resuming
|
|
11105
11145
|
if (currentState === core.ConnectorState.PAUSED) {
|
|
11106
|
-
logger$
|
|
11146
|
+
logger$12.debug('skipping_heartbeat_connector_paused', {
|
|
11107
11147
|
connector_state: currentState,
|
|
11108
11148
|
});
|
|
11109
11149
|
this.lastHeartbeatAckTime = Date.now();
|
|
@@ -11112,14 +11152,14 @@ class UpstreamSessionManager extends TaskSpawner {
|
|
|
11112
11152
|
// Reset ack time if just resumed from pause (prevents immediate timeout)
|
|
11113
11153
|
if (previousState === core.ConnectorState.PAUSED &&
|
|
11114
11154
|
currentState === core.ConnectorState.STARTED) {
|
|
11115
|
-
logger$
|
|
11155
|
+
logger$12.debug('connector_just_resumed_resetting_ack_time', {
|
|
11116
11156
|
previous_state: previousState,
|
|
11117
11157
|
current_state: currentState,
|
|
11118
11158
|
});
|
|
11119
11159
|
this.lastHeartbeatAckTime = Date.now();
|
|
11120
11160
|
}
|
|
11121
11161
|
const envelope = await this.makeHeartbeatEnvelope();
|
|
11122
|
-
logger$
|
|
11162
|
+
logger$12.debug('sending_heartbeat', {
|
|
11123
11163
|
hb_corr_id: envelope.corrId,
|
|
11124
11164
|
hb_env_id: envelope.id,
|
|
11125
11165
|
});
|
|
@@ -11145,7 +11185,7 @@ class UpstreamSessionManager extends TaskSpawner {
|
|
|
11145
11185
|
throw new FameConnectError('missed heartbeat acknowledgement');
|
|
11146
11186
|
}
|
|
11147
11187
|
}
|
|
11148
|
-
logger$
|
|
11188
|
+
logger$12.debug('completed_heartbeat_loop');
|
|
11149
11189
|
}
|
|
11150
11190
|
async messagePumpLoop(connector, stopEvt, signal) {
|
|
11151
11191
|
while (!stopEvt.isSet() && !signal?.aborted) {
|
|
@@ -11162,19 +11202,19 @@ class UpstreamSessionManager extends TaskSpawner {
|
|
|
11162
11202
|
if (!envelope) {
|
|
11163
11203
|
continue;
|
|
11164
11204
|
}
|
|
11165
|
-
logger$
|
|
11205
|
+
logger$12.debug('upstream_pump_sending_envelope', {
|
|
11166
11206
|
envelopeId: envelope.id,
|
|
11167
11207
|
type: envelope.frame?.type,
|
|
11168
11208
|
});
|
|
11169
11209
|
try {
|
|
11170
11210
|
await connector.send(envelope);
|
|
11171
|
-
logger$
|
|
11211
|
+
logger$12.debug('upstream_pump_sent_envelope', {
|
|
11172
11212
|
envelopeId: envelope.id,
|
|
11173
11213
|
});
|
|
11174
11214
|
}
|
|
11175
11215
|
catch (error) {
|
|
11176
11216
|
if (error instanceof FameMessageTooLarge) {
|
|
11177
|
-
logger$
|
|
11217
|
+
logger$12.error('failed_to_send_message', { error: error.message });
|
|
11178
11218
|
await this.handleMessageTooLarge(envelope, error.message);
|
|
11179
11219
|
}
|
|
11180
11220
|
else if (error instanceof FameTransportClose) {
|
|
@@ -11236,7 +11276,7 @@ class UpstreamSessionManager extends TaskSpawner {
|
|
|
11236
11276
|
await fabric.send(ackEnvelope);
|
|
11237
11277
|
}
|
|
11238
11278
|
catch (error) {
|
|
11239
|
-
logger$
|
|
11279
|
+
logger$12.warning('failed_to_send_nack', {
|
|
11240
11280
|
error: error.message,
|
|
11241
11281
|
});
|
|
11242
11282
|
}
|
|
@@ -11250,7 +11290,7 @@ class UpstreamSessionManager extends TaskSpawner {
|
|
|
11250
11290
|
timestamps.push(info.attachExpiresAt);
|
|
11251
11291
|
}
|
|
11252
11292
|
if (!timestamps.length) {
|
|
11253
|
-
logger$
|
|
11293
|
+
logger$12.debug('no_ttl_expiry_configured');
|
|
11254
11294
|
await this.waitEvent(stopEvt, signal);
|
|
11255
11295
|
return;
|
|
11256
11296
|
}
|
|
@@ -11259,7 +11299,7 @@ class UpstreamSessionManager extends TaskSpawner {
|
|
|
11259
11299
|
let delaySeconds = (earliest.getTime() - now.getTime()) / 1000 -
|
|
11260
11300
|
UpstreamSessionManager.JWT_REFRESH_SAFETY;
|
|
11261
11301
|
delaySeconds = Math.max(delaySeconds, UpstreamSessionManager.JWT_REFRESH_SAFETY);
|
|
11262
|
-
logger$
|
|
11302
|
+
logger$12.debug('ttl_expiry_guard_started', {
|
|
11263
11303
|
welcome_expires_at: welcome.frame.expiresAt ?? null,
|
|
11264
11304
|
attach_expires_at: info.attachExpiresAt?.toISOString?.() ?? null,
|
|
11265
11305
|
earliest_expiry: earliest.toISOString(),
|
|
@@ -11287,7 +11327,7 @@ class UpstreamSessionManager extends TaskSpawner {
|
|
|
11287
11327
|
}
|
|
11288
11328
|
}
|
|
11289
11329
|
if (!stopEvt.isSet()) {
|
|
11290
|
-
logger$
|
|
11330
|
+
logger$12.debug('ttl_expiry_triggered_reconnect', {
|
|
11291
11331
|
expires_at: earliest.toISOString(),
|
|
11292
11332
|
current_time: new Date().toISOString(),
|
|
11293
11333
|
seconds_before_expiry: UpstreamSessionManager.JWT_REFRESH_SAFETY,
|
|
@@ -11332,7 +11372,7 @@ class UpstreamSessionManager extends TaskSpawner {
|
|
|
11332
11372
|
}
|
|
11333
11373
|
await this.node.dispatchEnvelopeEvent('onEnvelopeReceived', this.node, env, context);
|
|
11334
11374
|
if (env.frame.type === 'NodeHeartbeatAck') {
|
|
11335
|
-
logger$
|
|
11375
|
+
logger$12.debug('received_heartbeat_ack', {
|
|
11336
11376
|
hb_ack_env_id: env.id,
|
|
11337
11377
|
hb_ack_corr_id: env.corrId,
|
|
11338
11378
|
hb_routing_epoch: env.frame.routingEpoch,
|
|
@@ -11346,7 +11386,7 @@ class UpstreamSessionManager extends TaskSpawner {
|
|
|
11346
11386
|
await this.onEpochChange(epoch);
|
|
11347
11387
|
}
|
|
11348
11388
|
else {
|
|
11349
|
-
logger$
|
|
11389
|
+
logger$12.warning('parent_epoch_changed', { epoch });
|
|
11350
11390
|
}
|
|
11351
11391
|
}
|
|
11352
11392
|
return;
|
|
@@ -11365,7 +11405,7 @@ UpstreamSessionManager.TX_QUEUE_MAX = 512;
|
|
|
11365
11405
|
UpstreamSessionManager.BACKOFF_INITIAL = 1; // seconds
|
|
11366
11406
|
UpstreamSessionManager.BACKOFF_CAP = 30; // seconds
|
|
11367
11407
|
|
|
11368
|
-
const logger$
|
|
11408
|
+
const logger$11 = getLogger('naylence.fame.node.admission.noop_admission_client');
|
|
11369
11409
|
class NoopAdmissionClient {
|
|
11370
11410
|
constructor(options = {}) {
|
|
11371
11411
|
this.hasUpstream = false;
|
|
@@ -11379,7 +11419,7 @@ class NoopAdmissionClient {
|
|
|
11379
11419
|
const acceptedLogicals = this.autoAcceptLogicals
|
|
11380
11420
|
? [...(requestedLogicals ?? [])]
|
|
11381
11421
|
: [];
|
|
11382
|
-
logger$
|
|
11422
|
+
logger$11.debug('noop_admission_hello', {
|
|
11383
11423
|
systemId: effectiveSystemId,
|
|
11384
11424
|
instanceId,
|
|
11385
11425
|
requestedLogicals,
|
|
@@ -11397,7 +11437,7 @@ class NoopAdmissionClient {
|
|
|
11397
11437
|
});
|
|
11398
11438
|
}
|
|
11399
11439
|
async close() {
|
|
11400
|
-
logger$
|
|
11440
|
+
logger$11.debug('noop_admission_close');
|
|
11401
11441
|
}
|
|
11402
11442
|
}
|
|
11403
11443
|
|
|
@@ -11603,7 +11643,7 @@ class DefaultServiceManager {
|
|
|
11603
11643
|
}
|
|
11604
11644
|
|
|
11605
11645
|
const SYSTEM_INBOX$1 = '__sys__';
|
|
11606
|
-
const logger
|
|
11646
|
+
const logger$10 = getLogger('naylence.fame.node.node');
|
|
11607
11647
|
function isSnakeCase(name) {
|
|
11608
11648
|
return name.includes('_');
|
|
11609
11649
|
}
|
|
@@ -11730,6 +11770,8 @@ class FameNode extends TaskSpawner {
|
|
|
11730
11770
|
this._acceptedLogicals = new Set(acceptedLogicalsOption);
|
|
11731
11771
|
const deliveryPolicyOption = resolveOption(options, 'deliveryPolicy', 'delivery_policy');
|
|
11732
11772
|
this._deliveryPolicy = deliveryPolicyOption ?? null;
|
|
11773
|
+
const connectionRetryPolicyOption = resolveOption(options, 'connectionRetryPolicy', 'connection_retry_policy');
|
|
11774
|
+
this._connectionRetryPolicy = connectionRetryPolicyOption ?? null;
|
|
11733
11775
|
const admissionClientOption = resolveOption(options, 'admissionClient', 'admission_client');
|
|
11734
11776
|
this._admissionClient = admissionClientOption ?? null;
|
|
11735
11777
|
const attachClientOption = resolveOption(options, 'attachClient', 'attach_client');
|
|
@@ -11859,6 +11901,7 @@ class FameNode extends TaskSpawner {
|
|
|
11859
11901
|
onAttach: (info, connector) => this.handleAttach(info, connector),
|
|
11860
11902
|
onEpochChange: (epoch) => this.handleEpochChange(epoch),
|
|
11861
11903
|
admissionClient: this._admissionClient,
|
|
11904
|
+
retryPolicy: this._connectionRetryPolicy,
|
|
11862
11905
|
});
|
|
11863
11906
|
this._sessionManager = manager;
|
|
11864
11907
|
await manager.start();
|
|
@@ -11870,7 +11913,7 @@ class FameNode extends TaskSpawner {
|
|
|
11870
11913
|
confirmIdentity(systemId, source) {
|
|
11871
11914
|
if (this._confirmedId) {
|
|
11872
11915
|
if (this._confirmedId !== systemId) {
|
|
11873
|
-
logger
|
|
11916
|
+
logger$10.error('node_identity_mismatch', {
|
|
11874
11917
|
current_id: this._confirmedId,
|
|
11875
11918
|
new_id: systemId,
|
|
11876
11919
|
source,
|
|
@@ -11882,14 +11925,14 @@ class FameNode extends TaskSpawner {
|
|
|
11882
11925
|
const isReassignment = this._provisionalId !== systemId;
|
|
11883
11926
|
this._confirmedId = systemId;
|
|
11884
11927
|
if (isReassignment) {
|
|
11885
|
-
logger
|
|
11928
|
+
logger$10.debug('node_identity_reassigned', {
|
|
11886
11929
|
system_id: systemId,
|
|
11887
11930
|
previous_id: this._provisionalId,
|
|
11888
11931
|
source,
|
|
11889
11932
|
});
|
|
11890
11933
|
}
|
|
11891
11934
|
else {
|
|
11892
|
-
logger
|
|
11935
|
+
logger$10.debug('node_identity_confirmed', {
|
|
11893
11936
|
system_id: systemId,
|
|
11894
11937
|
source,
|
|
11895
11938
|
});
|
|
@@ -11957,7 +12000,7 @@ class FameNode extends TaskSpawner {
|
|
|
11957
12000
|
return;
|
|
11958
12001
|
}
|
|
11959
12002
|
if (frameType === 'NodeHeartbeat') {
|
|
11960
|
-
logger
|
|
12003
|
+
logger$10.debug('received_heartbeat_frame', {
|
|
11961
12004
|
envelopeId: envelope.id,
|
|
11962
12005
|
corrId: envelope.corrId ?? null,
|
|
11963
12006
|
});
|
|
@@ -11969,7 +12012,7 @@ class FameNode extends TaskSpawner {
|
|
|
11969
12012
|
await this.handleDeliveryAck(envelope, context);
|
|
11970
12013
|
return;
|
|
11971
12014
|
}
|
|
11972
|
-
logger
|
|
12015
|
+
logger$10.debug('unhandled_system_frame', {
|
|
11973
12016
|
envelopeId: envelope.id,
|
|
11974
12017
|
frameType,
|
|
11975
12018
|
});
|
|
@@ -11981,13 +12024,13 @@ class FameNode extends TaskSpawner {
|
|
|
11981
12024
|
}
|
|
11982
12025
|
await this._deliveryTracker.onEnvelopeDelivered(SYSTEM_INBOX$1, envelope, context);
|
|
11983
12026
|
if (frame.ok !== false) {
|
|
11984
|
-
logger
|
|
12027
|
+
logger$10.debug('delivery_ack_received', {
|
|
11985
12028
|
envelopeId: envelope.id,
|
|
11986
12029
|
corrId: envelope.corrId ?? null,
|
|
11987
12030
|
});
|
|
11988
12031
|
return;
|
|
11989
12032
|
}
|
|
11990
|
-
logger
|
|
12033
|
+
logger$10.warning('delivery_nack_received', {
|
|
11991
12034
|
envelopeId: envelope.id,
|
|
11992
12035
|
corrId: envelope.corrId ?? null,
|
|
11993
12036
|
code: frame.code ?? null,
|
|
@@ -11997,7 +12040,7 @@ class FameNode extends TaskSpawner {
|
|
|
11997
12040
|
await this.onDeliveryNack(frame, envelope, context);
|
|
11998
12041
|
}
|
|
11999
12042
|
async onDeliveryNack(frame, envelope, _context) {
|
|
12000
|
-
logger
|
|
12043
|
+
logger$10.debug('delivery_nack_processed', {
|
|
12001
12044
|
envelopeId: envelope.id,
|
|
12002
12045
|
code: frame.code ?? null,
|
|
12003
12046
|
reason: frame.reason ?? null,
|
|
@@ -12112,7 +12155,7 @@ class FameNode extends TaskSpawner {
|
|
|
12112
12155
|
await this._bindingManager.restore();
|
|
12113
12156
|
await this._envelopeListenerManager.start();
|
|
12114
12157
|
this._isStarted = true;
|
|
12115
|
-
logger
|
|
12158
|
+
logger$10.debug('node_started', {
|
|
12116
12159
|
node_id: this.id,
|
|
12117
12160
|
sid: this.sid,
|
|
12118
12161
|
path: this.physicalPath,
|
|
@@ -12144,7 +12187,7 @@ class FameNode extends TaskSpawner {
|
|
|
12144
12187
|
await this._serviceManager.stop();
|
|
12145
12188
|
await this.dispatchEvent('onNodeStopped', this);
|
|
12146
12189
|
this._isStarted = false;
|
|
12147
|
-
logger
|
|
12190
|
+
logger$10.debug('node_stopped', {
|
|
12148
12191
|
node_id: this.id,
|
|
12149
12192
|
});
|
|
12150
12193
|
}
|
|
@@ -12334,20 +12377,20 @@ class FameNode extends TaskSpawner {
|
|
|
12334
12377
|
await this.forwardUpstream(processedEnvelope, context);
|
|
12335
12378
|
}
|
|
12336
12379
|
else {
|
|
12337
|
-
logger
|
|
12380
|
+
logger$10.error('attempted_upstream_loop', {
|
|
12338
12381
|
envelopeId: processedEnvelope.id,
|
|
12339
12382
|
});
|
|
12340
12383
|
}
|
|
12341
12384
|
return;
|
|
12342
12385
|
}
|
|
12343
12386
|
if (!processedEnvelope.to) {
|
|
12344
|
-
logger
|
|
12387
|
+
logger$10.error('dropping_envelope_without_destination', {
|
|
12345
12388
|
envelopeId: processedEnvelope.id,
|
|
12346
12389
|
capabilities: processedEnvelope.capabilities ?? [],
|
|
12347
12390
|
});
|
|
12348
12391
|
return;
|
|
12349
12392
|
}
|
|
12350
|
-
logger
|
|
12393
|
+
logger$10.warning('no_local_handler_for_address', {
|
|
12351
12394
|
address: processedEnvelope.to.toString?.() ?? String(processedEnvelope.to),
|
|
12352
12395
|
originType: context?.originType ?? null,
|
|
12353
12396
|
});
|
|
@@ -12471,7 +12514,7 @@ class FameNode extends TaskSpawner {
|
|
|
12471
12514
|
}
|
|
12472
12515
|
}
|
|
12473
12516
|
catch (error) {
|
|
12474
|
-
logger
|
|
12517
|
+
logger$10.warning('callback_grant_collection_failed', {
|
|
12475
12518
|
error: error instanceof Error ? error.message : String(error),
|
|
12476
12519
|
});
|
|
12477
12520
|
}
|
|
@@ -12534,7 +12577,7 @@ class FameNode extends TaskSpawner {
|
|
|
12534
12577
|
await store.set('self', record);
|
|
12535
12578
|
}
|
|
12536
12579
|
catch (error) {
|
|
12537
|
-
logger
|
|
12580
|
+
logger$10.warning('node_meta_persist_failed', {
|
|
12538
12581
|
error: error instanceof Error ? error.message : String(error),
|
|
12539
12582
|
});
|
|
12540
12583
|
}
|
|
@@ -12565,6 +12608,7 @@ const FameNodeConfigSchemaInternal = zod.z
|
|
|
12565
12608
|
telemetry: zod.z.unknown().optional().nullable(),
|
|
12566
12609
|
requestedCapabilities: zod.z.array(zod.z.string()).optional(),
|
|
12567
12610
|
identityPolicy: zod.z.unknown().optional().nullable(),
|
|
12611
|
+
connectionRetryPolicy: zod.z.unknown().optional().nullable(),
|
|
12568
12612
|
})
|
|
12569
12613
|
.passthrough();
|
|
12570
12614
|
function normalizeFameNodeConfig(input) {
|
|
@@ -12606,6 +12650,9 @@ function normalizeFameNodeConfig(input) {
|
|
|
12606
12650
|
identityPolicy: parsed.identityPolicy === undefined
|
|
12607
12651
|
? null
|
|
12608
12652
|
: parsed.identityPolicy,
|
|
12653
|
+
connectionRetryPolicy: parsed.connectionRetryPolicy === undefined
|
|
12654
|
+
? null
|
|
12655
|
+
: parsed.connectionRetryPolicy,
|
|
12609
12656
|
};
|
|
12610
12657
|
if (parsed.requestedCapabilities) {
|
|
12611
12658
|
normalized.requestedCapabilities = coerceStringArray$1(parsed.requestedCapabilities);
|
|
@@ -12650,6 +12697,24 @@ class AdmissionClientFactory extends factory.AbstractResourceFactory {
|
|
|
12650
12697
|
}
|
|
12651
12698
|
}
|
|
12652
12699
|
|
|
12700
|
+
const CONNECTION_RETRY_POLICY_FACTORY_BASE_TYPE = 'ConnectionRetryPolicyFactory';
|
|
12701
|
+
class ConnectionRetryPolicyFactory extends factory.AbstractResourceFactory {
|
|
12702
|
+
static async createConnectionRetryPolicy(config, options = {}) {
|
|
12703
|
+
if (config) {
|
|
12704
|
+
const policy = await factory.createResource(CONNECTION_RETRY_POLICY_FACTORY_BASE_TYPE, config, options);
|
|
12705
|
+
if (!policy) {
|
|
12706
|
+
throw new Error('Failed to create connection retry policy from configuration');
|
|
12707
|
+
}
|
|
12708
|
+
return policy;
|
|
12709
|
+
}
|
|
12710
|
+
const policy = await factory.createDefaultResource(CONNECTION_RETRY_POLICY_FACTORY_BASE_TYPE, null, options);
|
|
12711
|
+
if (!policy) {
|
|
12712
|
+
throw new Error('Failed to create default connection retry policy');
|
|
12713
|
+
}
|
|
12714
|
+
return policy;
|
|
12715
|
+
}
|
|
12716
|
+
}
|
|
12717
|
+
|
|
12653
12718
|
const TOKEN_PROVIDER_FACTORY_BASE_TYPE = 'TokenProviderFactory';
|
|
12654
12719
|
class TokenProviderFactory extends factory.AbstractResourceFactory {
|
|
12655
12720
|
static async createTokenProvider(config, options = {}) {
|
|
@@ -12687,7 +12752,7 @@ function isIdentityExposingTokenProvider(candidate) {
|
|
|
12687
12752
|
'function');
|
|
12688
12753
|
}
|
|
12689
12754
|
|
|
12690
|
-
const logger
|
|
12755
|
+
const logger$$ = getLogger('naylence.fame.node.default_node_identity_policy');
|
|
12691
12756
|
class DefaultNodeIdentityPolicy {
|
|
12692
12757
|
async resolveInitialNodeId(context) {
|
|
12693
12758
|
if (context.configuredId) {
|
|
@@ -12717,7 +12782,7 @@ class DefaultNodeIdentityPolicy {
|
|
|
12717
12782
|
if (isIdentityExposingTokenProvider(provider)) {
|
|
12718
12783
|
const identity = await provider.getIdentity();
|
|
12719
12784
|
if (identity && identity.subject) {
|
|
12720
|
-
logger
|
|
12785
|
+
logger$$.debug('identity_extracted_from_grant', {
|
|
12721
12786
|
identity_id: identity.subject,
|
|
12722
12787
|
grant_type: grant.type,
|
|
12723
12788
|
});
|
|
@@ -12726,7 +12791,7 @@ class DefaultNodeIdentityPolicy {
|
|
|
12726
12791
|
}
|
|
12727
12792
|
}
|
|
12728
12793
|
catch (error) {
|
|
12729
|
-
logger
|
|
12794
|
+
logger$$.warning('identity_extraction_failed', {
|
|
12730
12795
|
error: error instanceof Error ? error.message : String(error),
|
|
12731
12796
|
grant_type: grant.type,
|
|
12732
12797
|
});
|
|
@@ -12810,7 +12875,7 @@ class AttachmentKeyValidator {
|
|
|
12810
12875
|
}
|
|
12811
12876
|
}
|
|
12812
12877
|
|
|
12813
|
-
const logger$
|
|
12878
|
+
const logger$_ = getLogger('naylence.fame.node.admission.default_node_attach_client');
|
|
12814
12879
|
const HANDSHAKE_POLL_INTERVAL_MS = 20;
|
|
12815
12880
|
class DefaultNodeAttachClient {
|
|
12816
12881
|
constructor(options = {}) {
|
|
@@ -12834,7 +12899,7 @@ class DefaultNodeAttachClient {
|
|
|
12834
12899
|
}
|
|
12835
12900
|
else {
|
|
12836
12901
|
// Silently ignore frames from other agents during concurrent handshakes
|
|
12837
|
-
logger$
|
|
12902
|
+
logger$_.debug('handshake_ignoring_frame_from_different_system', {
|
|
12838
12903
|
frame_type: envelope.frame.type,
|
|
12839
12904
|
frame_system_id: frameSystemId,
|
|
12840
12905
|
expected_system_id: this.expectedSystemId,
|
|
@@ -12877,7 +12942,7 @@ class DefaultNodeAttachClient {
|
|
|
12877
12942
|
}
|
|
12878
12943
|
}
|
|
12879
12944
|
catch (error) {
|
|
12880
|
-
logger$
|
|
12945
|
+
logger$_.debug('stickiness_offer_skipped', {
|
|
12881
12946
|
error: error instanceof Error ? error.message : String(error),
|
|
12882
12947
|
});
|
|
12883
12948
|
}
|
|
@@ -12898,7 +12963,7 @@ class DefaultNodeAttachClient {
|
|
|
12898
12963
|
if (!processedEnvelope) {
|
|
12899
12964
|
throw new Error('Envelope was blocked by onForwardUpstream event');
|
|
12900
12965
|
}
|
|
12901
|
-
logger$
|
|
12966
|
+
logger$_.debug('sending_node_attach_envelope', {
|
|
12902
12967
|
envp_id: processedEnvelope.id ?? envelope.id ?? null,
|
|
12903
12968
|
frame_type: processedEnvelope.frame?.type ?? 'unknown',
|
|
12904
12969
|
trace_id: processedEnvelope.traceId ?? envelope.traceId ?? null,
|
|
@@ -12934,7 +12999,7 @@ class DefaultNodeAttachClient {
|
|
|
12934
12999
|
try {
|
|
12935
13000
|
const keyInfos = await this.attachmentKeyValidator.validateKeys(parentKeys);
|
|
12936
13001
|
if (Array.isArray(keyInfos) && keyInfos.length > 0) {
|
|
12937
|
-
logger$
|
|
13002
|
+
logger$_.debug('parent_certificate_validation_passed', {
|
|
12938
13003
|
parent_id: parentId,
|
|
12939
13004
|
correlation_id: corrId,
|
|
12940
13005
|
validated_keys: keyInfos.length,
|
|
@@ -12943,7 +13008,7 @@ class DefaultNodeAttachClient {
|
|
|
12943
13008
|
}
|
|
12944
13009
|
catch (error) {
|
|
12945
13010
|
if (error instanceof KeyValidationError) {
|
|
12946
|
-
logger$
|
|
13011
|
+
logger$_.error('parent_certificate_validation_failed', {
|
|
12947
13012
|
parent_id: parentId,
|
|
12948
13013
|
correlation_id: corrId,
|
|
12949
13014
|
error_code: error.code,
|
|
@@ -12957,12 +13022,12 @@ class DefaultNodeAttachClient {
|
|
|
12957
13022
|
}
|
|
12958
13023
|
}
|
|
12959
13024
|
else {
|
|
12960
|
-
logger$
|
|
13025
|
+
logger$_.debug('parent_certificate_validation_skipped', {
|
|
12961
13026
|
parent_id: parentId,
|
|
12962
13027
|
reason: 'no_validator',
|
|
12963
13028
|
});
|
|
12964
13029
|
}
|
|
12965
|
-
logger$
|
|
13030
|
+
logger$_.debug('processing_node_attach_ack', {
|
|
12966
13031
|
parent_id: ackFrame.targetSystemId,
|
|
12967
13032
|
});
|
|
12968
13033
|
this.inHandshake = false;
|
|
@@ -12993,7 +13058,7 @@ class DefaultNodeAttachClient {
|
|
|
12993
13058
|
}
|
|
12994
13059
|
}
|
|
12995
13060
|
catch (error) {
|
|
12996
|
-
logger$
|
|
13061
|
+
logger$_.debug('stickiness_accept_skipped', {
|
|
12997
13062
|
error: error instanceof Error ? error.message : String(error),
|
|
12998
13063
|
});
|
|
12999
13064
|
}
|
|
@@ -13047,7 +13112,7 @@ class DefaultNodeAttachClient {
|
|
|
13047
13112
|
// NodeAttach frames during handshake are expected in multi-agent scenarios
|
|
13048
13113
|
// where multiple agents attach concurrently to the same channel
|
|
13049
13114
|
if (envelope.frame.type === 'NodeAttach') {
|
|
13050
|
-
logger$
|
|
13115
|
+
logger$_.debug('handshake_ignoring_concurrent_attach', {
|
|
13051
13116
|
frame_type: envelope.frame.type,
|
|
13052
13117
|
frame_system_id: envelope.frame?.systemId ??
|
|
13053
13118
|
'unknown',
|
|
@@ -13055,7 +13120,7 @@ class DefaultNodeAttachClient {
|
|
|
13055
13120
|
}
|
|
13056
13121
|
else {
|
|
13057
13122
|
// Other unexpected frames are still logged as errors
|
|
13058
|
-
logger$
|
|
13123
|
+
logger$_.error('unexpected_frame_during_handshake', {
|
|
13059
13124
|
frame_type: envelope.frame.type,
|
|
13060
13125
|
});
|
|
13061
13126
|
}
|
|
@@ -13190,7 +13255,7 @@ class TraceEmitterFactory extends factory.AbstractResourceFactory {
|
|
|
13190
13255
|
// void import('./trace-emitter-profile-factory.js');
|
|
13191
13256
|
|
|
13192
13257
|
const BINDING_STORE_NAMESPACE = '__binding_store';
|
|
13193
|
-
const logger$
|
|
13258
|
+
const logger$Z = getLogger('naylence.fame.node.factory_commons');
|
|
13194
13259
|
function isPlainRecord$2(value) {
|
|
13195
13260
|
return Boolean(value) && typeof value === 'object' && !Array.isArray(value);
|
|
13196
13261
|
}
|
|
@@ -13297,6 +13362,7 @@ async function makeCommonOptions(config, rawConfig) {
|
|
|
13297
13362
|
const telemetryConfig = pickOption$1(config.telemetry ?? null, aliasRecord, 'trace_emitter', 'telemetry_config');
|
|
13298
13363
|
const securityConfig = pickOption$1(config.security ?? null, aliasRecord, 'security_manager', 'security_profile');
|
|
13299
13364
|
const identityPolicyConfig = pickOption$1(config.identityPolicy ?? null, aliasRecord, 'identity_policy', 'node_identity_policy');
|
|
13365
|
+
const connectionRetryPolicyConfig = pickOption$1(config.connectionRetryPolicy ?? null, aliasRecord, 'connection_retry_policy', 'retry_policy');
|
|
13300
13366
|
const publicUrl = pickString$2(config.publicUrl ?? null, aliasRecord, 'public_url') ?? null;
|
|
13301
13367
|
const directParentUrl = pickString$2(config.directParentUrl ?? null, aliasRecord, 'direct_parent_url') ?? null;
|
|
13302
13368
|
const hasParentFlag = config.hasParent || Boolean(aliasRecord.has_parent ?? false);
|
|
@@ -13306,6 +13372,7 @@ async function makeCommonOptions(config, rawConfig) {
|
|
|
13306
13372
|
const nodeMetaStore = await storageProvider.getKeyValueStore(NodeMetaRecord, NODE_META_NAMESPACE);
|
|
13307
13373
|
const nodeMeta = await nodeMetaStore.get('self');
|
|
13308
13374
|
const identityPolicy = await resolveNodeIdentityPolicy(identityPolicyConfig ?? null, expressionOptions);
|
|
13375
|
+
const connectionRetryPolicy = await resolveConnectionRetryPolicy(connectionRetryPolicyConfig ?? null, expressionOptions);
|
|
13309
13376
|
const admissionClient = await resolveAdmissionClient(admissionConfig ?? null, expressionOptions, identityPolicy ?? undefined);
|
|
13310
13377
|
const hasParent = determineHasParent(hasParentFlag, directParentUrl, admissionClient);
|
|
13311
13378
|
const replicaStickinessManager = await resolveReplicaStickinessManager(hasParent, requestedLogicals, expressionOptions);
|
|
@@ -13374,6 +13441,7 @@ async function makeCommonOptions(config, rawConfig) {
|
|
|
13374
13441
|
transportListeners,
|
|
13375
13442
|
traceEmitter,
|
|
13376
13443
|
identityPolicy: identityPolicy ?? undefined,
|
|
13444
|
+
connectionRetryPolicy: connectionRetryPolicy ?? undefined,
|
|
13377
13445
|
};
|
|
13378
13446
|
}
|
|
13379
13447
|
async function resolveNodeIdentityPolicy(config, options) {
|
|
@@ -13381,7 +13449,18 @@ async function resolveNodeIdentityPolicy(config, options) {
|
|
|
13381
13449
|
return await NodeIdentityPolicyFactory.createNodeIdentityPolicy(config ?? undefined, cloneCreateOptions(options));
|
|
13382
13450
|
}
|
|
13383
13451
|
catch (error) {
|
|
13384
|
-
logger$
|
|
13452
|
+
logger$Z.warning('node_identity_policy_creation_failed', {
|
|
13453
|
+
error: error instanceof Error ? error.message : String(error),
|
|
13454
|
+
});
|
|
13455
|
+
return null;
|
|
13456
|
+
}
|
|
13457
|
+
}
|
|
13458
|
+
async function resolveConnectionRetryPolicy(config, options) {
|
|
13459
|
+
try {
|
|
13460
|
+
return await ConnectionRetryPolicyFactory.createConnectionRetryPolicy(config ?? undefined, cloneCreateOptions(options));
|
|
13461
|
+
}
|
|
13462
|
+
catch (error) {
|
|
13463
|
+
logger$Z.warning('connection_retry_policy_creation_failed', {
|
|
13385
13464
|
error: error instanceof Error ? error.message : String(error),
|
|
13386
13465
|
});
|
|
13387
13466
|
return null;
|
|
@@ -13393,7 +13472,7 @@ async function resolveStorageProvider(config, options) {
|
|
|
13393
13472
|
return await StorageProviderFactory.createStorageProvider(config, cloneCreateOptions(options));
|
|
13394
13473
|
}
|
|
13395
13474
|
catch (error) {
|
|
13396
|
-
logger$
|
|
13475
|
+
logger$Z.warning('storage_provider_creation_failed', {
|
|
13397
13476
|
error: error instanceof Error ? error.message : String(error),
|
|
13398
13477
|
});
|
|
13399
13478
|
}
|
|
@@ -13415,7 +13494,7 @@ async function resolveAdmissionClient(config, options, identityPolicy) {
|
|
|
13415
13494
|
return await AdmissionClientFactory.createAdmissionClient((config ?? null), createOptions);
|
|
13416
13495
|
}
|
|
13417
13496
|
catch (error) {
|
|
13418
|
-
logger$
|
|
13497
|
+
logger$Z.warning('admission_client_creation_failed', {
|
|
13419
13498
|
error: error instanceof Error ? error.message : String(error),
|
|
13420
13499
|
});
|
|
13421
13500
|
return null;
|
|
@@ -13442,7 +13521,7 @@ async function resolveReplicaStickinessManager(hasParent, requestedLogicals, opt
|
|
|
13442
13521
|
return await ReplicaStickinessManagerFactory.createReplicaStickinessManager(undefined, cloneCreateOptions(options));
|
|
13443
13522
|
}
|
|
13444
13523
|
catch (error) {
|
|
13445
|
-
logger$
|
|
13524
|
+
logger$Z.debug('replica_stickiness_manager_unavailable', { error });
|
|
13446
13525
|
return null;
|
|
13447
13526
|
}
|
|
13448
13527
|
}
|
|
@@ -13451,7 +13530,7 @@ async function resolveAttachmentKeyValidator(config, options) {
|
|
|
13451
13530
|
return await AttachmentKeyValidatorFactory.createAttachmentKeyValidator(config ?? undefined, cloneCreateOptions(options));
|
|
13452
13531
|
}
|
|
13453
13532
|
catch (error) {
|
|
13454
|
-
logger$
|
|
13533
|
+
logger$Z.warning('attachment_key_validator_creation_failed', {
|
|
13455
13534
|
error: error instanceof Error ? error.message : String(error),
|
|
13456
13535
|
});
|
|
13457
13536
|
return null;
|
|
@@ -13469,7 +13548,7 @@ async function resolveDeliveryPolicy(config, options) {
|
|
|
13469
13548
|
return await DeliveryPolicyFactory.createDeliveryPolicy(config ?? undefined, cloneCreateOptions(options));
|
|
13470
13549
|
}
|
|
13471
13550
|
catch (error) {
|
|
13472
|
-
logger$
|
|
13551
|
+
logger$Z.warning('delivery_policy_creation_failed', {
|
|
13473
13552
|
error: error instanceof Error ? error.message : String(error),
|
|
13474
13553
|
});
|
|
13475
13554
|
return null;
|
|
@@ -13483,7 +13562,7 @@ async function resolveTransportListeners(configs, eventListeners, options) {
|
|
|
13483
13562
|
return await TransportListenerFactory.createTransportListeners(configs, eventListeners, cloneCreateOptions(options));
|
|
13484
13563
|
}
|
|
13485
13564
|
catch (error) {
|
|
13486
|
-
logger$
|
|
13565
|
+
logger$Z.warning('transport_listener_creation_failed', {
|
|
13487
13566
|
error: error instanceof Error ? error.message : String(error),
|
|
13488
13567
|
});
|
|
13489
13568
|
return [];
|
|
@@ -13494,7 +13573,7 @@ async function resolveTraceEmitter(config, options) {
|
|
|
13494
13573
|
return await TraceEmitterFactory.createTraceEmitter(config ?? undefined, cloneCreateOptions(options));
|
|
13495
13574
|
}
|
|
13496
13575
|
catch (error) {
|
|
13497
|
-
logger$
|
|
13576
|
+
logger$Z.warning('trace_emitter_creation_failed', {
|
|
13498
13577
|
error: error instanceof Error ? error.message : String(error),
|
|
13499
13578
|
});
|
|
13500
13579
|
return null;
|
|
@@ -13550,7 +13629,7 @@ async function createSecurityManagerFromConfig(config, overrides, options) {
|
|
|
13550
13629
|
return manager ?? null;
|
|
13551
13630
|
}
|
|
13552
13631
|
catch (error) {
|
|
13553
|
-
logger$
|
|
13632
|
+
logger$Z.warning('security_manager_creation_failed', {
|
|
13554
13633
|
error: error instanceof Error ? error.message : String(error),
|
|
13555
13634
|
});
|
|
13556
13635
|
return null;
|
|
@@ -13579,7 +13658,7 @@ async function resolveCryptoProvider(config, options) {
|
|
|
13579
13658
|
// This happens with overlay security profiles that need envelope signing
|
|
13580
13659
|
if (requiresCryptoProvider(config)) {
|
|
13581
13660
|
try {
|
|
13582
|
-
logger$
|
|
13661
|
+
logger$Z.debug('auto_creating_crypto_provider', {
|
|
13583
13662
|
reason: 'overlay_security_requires_signing',
|
|
13584
13663
|
});
|
|
13585
13664
|
// Dynamically import to avoid circular dependencies
|
|
@@ -13599,7 +13678,7 @@ async function resolveCryptoProvider(config, options) {
|
|
|
13599
13678
|
});
|
|
13600
13679
|
}
|
|
13601
13680
|
catch (error) {
|
|
13602
|
-
logger$
|
|
13681
|
+
logger$Z.error('failed_to_auto_create_crypto_provider', {
|
|
13603
13682
|
error: error instanceof Error ? error.message : String(error),
|
|
13604
13683
|
});
|
|
13605
13684
|
throw error;
|
|
@@ -14133,6 +14212,7 @@ const MODULES = [
|
|
|
14133
14212
|
"./node/admission/direct-admission-client-factory.js",
|
|
14134
14213
|
"./node/admission/noop-admission-client-factory.js",
|
|
14135
14214
|
"./node/admission/welcome-service-client-factory.js",
|
|
14215
|
+
"./node/default-connection-retry-policy-factory.js",
|
|
14136
14216
|
"./node/default-node-identity-policy-factory.js",
|
|
14137
14217
|
"./node/node-factory.js",
|
|
14138
14218
|
"./node/node-identity-policy-profile-factory.js",
|
|
@@ -14211,6 +14291,7 @@ const MODULE_LOADERS = {
|
|
|
14211
14291
|
"./node/admission/direct-admission-client-factory.js": () => Promise.resolve().then(function () { return directAdmissionClientFactory; }),
|
|
14212
14292
|
"./node/admission/noop-admission-client-factory.js": () => Promise.resolve().then(function () { return noopAdmissionClientFactory; }),
|
|
14213
14293
|
"./node/admission/welcome-service-client-factory.js": () => Promise.resolve().then(function () { return welcomeServiceClientFactory; }),
|
|
14294
|
+
"./node/default-connection-retry-policy-factory.js": () => Promise.resolve().then(function () { return defaultConnectionRetryPolicyFactory; }),
|
|
14214
14295
|
"./node/default-node-identity-policy-factory.js": () => Promise.resolve().then(function () { return defaultNodeIdentityPolicyFactory; }),
|
|
14215
14296
|
"./node/node-factory.js": () => Promise.resolve().then(function () { return nodeFactory; }),
|
|
14216
14297
|
"./node/node-identity-policy-profile-factory.js": () => Promise.resolve().then(function () { return nodeIdentityPolicyProfileFactory; }),
|
|
@@ -14558,7 +14639,7 @@ class NodeLikeFactory extends factory.AbstractResourceFactory {
|
|
|
14558
14639
|
// registerFactory(NODE_LIKE_FACTORY_BASE_TYPE, type, factory);
|
|
14559
14640
|
// }
|
|
14560
14641
|
|
|
14561
|
-
const FACTORY_META$
|
|
14642
|
+
const FACTORY_META$18 = {
|
|
14562
14643
|
base: NODE_LIKE_FACTORY_BASE_TYPE,
|
|
14563
14644
|
key: 'Node',
|
|
14564
14645
|
};
|
|
@@ -14592,6 +14673,7 @@ class NodeFactory extends NodeLikeFactory {
|
|
|
14592
14673
|
nodeMetaStore: components.nodeMetaStore,
|
|
14593
14674
|
transportListeners: components.transportListeners,
|
|
14594
14675
|
defaultServiceConfigs: serviceConfigs,
|
|
14676
|
+
connectionRetryPolicy: components.connectionRetryPolicy,
|
|
14595
14677
|
});
|
|
14596
14678
|
return node;
|
|
14597
14679
|
}
|
|
@@ -14599,7 +14681,7 @@ class NodeFactory extends NodeLikeFactory {
|
|
|
14599
14681
|
|
|
14600
14682
|
var nodeFactory = /*#__PURE__*/Object.freeze({
|
|
14601
14683
|
__proto__: null,
|
|
14602
|
-
FACTORY_META: FACTORY_META$
|
|
14684
|
+
FACTORY_META: FACTORY_META$18,
|
|
14603
14685
|
NodeFactory: NodeFactory,
|
|
14604
14686
|
default: NodeFactory
|
|
14605
14687
|
});
|
|
@@ -15172,7 +15254,7 @@ function normalizeSecurityRequirements(value) {
|
|
|
15172
15254
|
};
|
|
15173
15255
|
}
|
|
15174
15256
|
|
|
15175
|
-
const logger$
|
|
15257
|
+
const logger$Y = getLogger('naylence.fame.node.envelope_security_handler');
|
|
15176
15258
|
const ENCRYPTION_OPTION_ALIAS_PAIRS = [
|
|
15177
15259
|
['recipKid', 'recip_kid'],
|
|
15178
15260
|
['recipientKeyId', 'recipient_key_id'],
|
|
@@ -15221,7 +15303,7 @@ class EnvelopeSecurityHandler {
|
|
|
15221
15303
|
const shouldSign = this.securityPolicy
|
|
15222
15304
|
? await this.securityPolicy.shouldSignEnvelope(envelope, context, this.node)
|
|
15223
15305
|
: false;
|
|
15224
|
-
logger$
|
|
15306
|
+
logger$Y.debug('checking_signing', {
|
|
15225
15307
|
has_signer: Boolean(this.envelopeSigner),
|
|
15226
15308
|
should_sign: shouldSign,
|
|
15227
15309
|
envp_id: envelope.id,
|
|
@@ -15243,7 +15325,7 @@ class EnvelopeSecurityHandler {
|
|
|
15243
15325
|
const shouldEncrypt = this.securityPolicy
|
|
15244
15326
|
? await this.securityPolicy.shouldEncryptEnvelope(envelope, context, this.node)
|
|
15245
15327
|
: false;
|
|
15246
|
-
logger$
|
|
15328
|
+
logger$Y.debug('checking_encryption', {
|
|
15247
15329
|
has_encryption_manager: Boolean(this.encryptionManager),
|
|
15248
15330
|
should_encrypt: shouldEncrypt,
|
|
15249
15331
|
envp_id: envelope.id,
|
|
@@ -15251,7 +15333,7 @@ class EnvelopeSecurityHandler {
|
|
|
15251
15333
|
});
|
|
15252
15334
|
if (this.encryptionManager && this.securityPolicy) {
|
|
15253
15335
|
if (envelope.sec?.enc) {
|
|
15254
|
-
logger$
|
|
15336
|
+
logger$Y.debug('skipping_encryption_already_encrypted', {
|
|
15255
15337
|
envp_id: envelope.id,
|
|
15256
15338
|
destination: envelope.to ? String(envelope.to) : undefined,
|
|
15257
15339
|
});
|
|
@@ -15264,7 +15346,7 @@ class EnvelopeSecurityHandler {
|
|
|
15264
15346
|
exports.CryptoLevel.PLAINTEXT;
|
|
15265
15347
|
desiredCryptoLevel =
|
|
15266
15348
|
await this.securityPolicy.decideResponseCryptoLevel(requestCryptoLevel, envelope, context);
|
|
15267
|
-
logger$
|
|
15349
|
+
logger$Y.debug('response_crypto_level_decided', {
|
|
15268
15350
|
envp_id: envelope.id,
|
|
15269
15351
|
crypto_level: desiredCryptoLevel,
|
|
15270
15352
|
destination: envelope.to ? String(envelope.to) : undefined,
|
|
@@ -15275,7 +15357,7 @@ class EnvelopeSecurityHandler {
|
|
|
15275
15357
|
else {
|
|
15276
15358
|
desiredCryptoLevel =
|
|
15277
15359
|
await this.securityPolicy.decideOutboundCryptoLevel(envelope, context, this.node);
|
|
15278
|
-
logger$
|
|
15360
|
+
logger$Y.debug('outbound_crypto_level_decided', {
|
|
15279
15361
|
envp_id: envelope.id,
|
|
15280
15362
|
frame_type: envelope.frame.type,
|
|
15281
15363
|
crypto_level: desiredCryptoLevel,
|
|
@@ -15283,11 +15365,11 @@ class EnvelopeSecurityHandler {
|
|
|
15283
15365
|
});
|
|
15284
15366
|
}
|
|
15285
15367
|
if (desiredCryptoLevel === exports.CryptoLevel.SEALED) {
|
|
15286
|
-
logger$
|
|
15368
|
+
logger$Y.debug('applying_sealed_encryption', { envp_id: envelope.id });
|
|
15287
15369
|
return await this.handleSealedEncryption(envelope, context);
|
|
15288
15370
|
}
|
|
15289
15371
|
if (desiredCryptoLevel === exports.CryptoLevel.CHANNEL) {
|
|
15290
|
-
logger$
|
|
15372
|
+
logger$Y.debug('applying_channel_encryption', { envp_id: envelope.id });
|
|
15291
15373
|
return await this.handleChannelEncryption(envelope, context);
|
|
15292
15374
|
}
|
|
15293
15375
|
}
|
|
@@ -15338,7 +15420,7 @@ class EnvelopeSecurityHandler {
|
|
|
15338
15420
|
frameType === 'KeyAnnounce' ||
|
|
15339
15421
|
frameType === 'SecureOpen' ||
|
|
15340
15422
|
frameType === 'SecureAccept') {
|
|
15341
|
-
logger$
|
|
15423
|
+
logger$Y.error('critical_frame_unsigned_rejected', {
|
|
15342
15424
|
envp_id: envelope.id,
|
|
15343
15425
|
frame_type: frameType,
|
|
15344
15426
|
reason: 'critical_frames_must_be_signed',
|
|
@@ -15346,7 +15428,7 @@ class EnvelopeSecurityHandler {
|
|
|
15346
15428
|
return [envelope, false];
|
|
15347
15429
|
}
|
|
15348
15430
|
const action = this.securityPolicy.getUnsignedViolationAction(envelope, context);
|
|
15349
|
-
logger$
|
|
15431
|
+
logger$Y.warning('unsigned_envelope_violation', {
|
|
15350
15432
|
envp_id: envelope.id,
|
|
15351
15433
|
frame_type: frameType,
|
|
15352
15434
|
action,
|
|
@@ -15358,26 +15440,26 @@ class EnvelopeSecurityHandler {
|
|
|
15358
15440
|
return [envelope, true];
|
|
15359
15441
|
}
|
|
15360
15442
|
async handleChannelHandshakeComplete(channelId, destination) {
|
|
15361
|
-
logger$
|
|
15443
|
+
logger$Y.debug('channel_handshake_completed', {
|
|
15362
15444
|
channel_id: channelId,
|
|
15363
15445
|
destination,
|
|
15364
15446
|
});
|
|
15365
15447
|
if (this.encryptionManager?.notifyChannelEstablished) {
|
|
15366
15448
|
await this.encryptionManager.notifyChannelEstablished(channelId);
|
|
15367
|
-
logger$
|
|
15449
|
+
logger$Y.debug('notified_encryption_manager_channel_ready', {
|
|
15368
15450
|
channel_id: channelId,
|
|
15369
15451
|
});
|
|
15370
15452
|
}
|
|
15371
15453
|
}
|
|
15372
15454
|
async handleChannelHandshakeFailed(channelId, destination, reason = 'handshake_failed') {
|
|
15373
|
-
logger$
|
|
15455
|
+
logger$Y.debug('channel_handshake_failed', {
|
|
15374
15456
|
channel_id: channelId,
|
|
15375
15457
|
destination,
|
|
15376
15458
|
reason,
|
|
15377
15459
|
});
|
|
15378
15460
|
if (this.encryptionManager?.notifyChannelFailed) {
|
|
15379
15461
|
await this.encryptionManager.notifyChannelFailed(channelId, reason);
|
|
15380
|
-
logger$
|
|
15462
|
+
logger$Y.debug('notified_encryption_manager_channel_failed', {
|
|
15381
15463
|
channel_id: channelId,
|
|
15382
15464
|
reason,
|
|
15383
15465
|
});
|
|
@@ -15424,7 +15506,7 @@ class EnvelopeSecurityHandler {
|
|
|
15424
15506
|
checkPayload: false,
|
|
15425
15507
|
});
|
|
15426
15508
|
if (verified) {
|
|
15427
|
-
logger$
|
|
15509
|
+
logger$Y.debug('envelope_verified', {
|
|
15428
15510
|
envp_id: envelope.id,
|
|
15429
15511
|
sid: envelope.sid,
|
|
15430
15512
|
kid,
|
|
@@ -15435,7 +15517,7 @@ class EnvelopeSecurityHandler {
|
|
|
15435
15517
|
}
|
|
15436
15518
|
this.keyManagementHandler.queuePendingSignedEnvelope(kid, envelope, context);
|
|
15437
15519
|
await this.keyManagementHandler.maybeRequestSigningKey(kid, context.originType, fromSystemId);
|
|
15438
|
-
logger$
|
|
15520
|
+
logger$Y.debug('queued_envelope_missing_signing_key', {
|
|
15439
15521
|
kid,
|
|
15440
15522
|
envp_id: envelope.id,
|
|
15441
15523
|
});
|
|
@@ -15443,7 +15525,7 @@ class EnvelopeSecurityHandler {
|
|
|
15443
15525
|
}
|
|
15444
15526
|
async handleSealedEncryption(envelope, context) {
|
|
15445
15527
|
if (!envelope.to) {
|
|
15446
|
-
logger$
|
|
15528
|
+
logger$Y.warning('sealed_encryption_requested_but_no_destination', {
|
|
15447
15529
|
envp_id: envelope.id,
|
|
15448
15530
|
});
|
|
15449
15531
|
return true;
|
|
@@ -15455,20 +15537,20 @@ class EnvelopeSecurityHandler {
|
|
|
15455
15537
|
: undefined;
|
|
15456
15538
|
if (options) {
|
|
15457
15539
|
if (options.encryptionType === 'channel') {
|
|
15458
|
-
logger$
|
|
15540
|
+
logger$Y.warning('policy_returned_channel_for_sealed_request', {
|
|
15459
15541
|
envp_id: envelope.id,
|
|
15460
15542
|
});
|
|
15461
15543
|
return await this.handleToBeEncryptedEnvelopeWithOptions(envelope, context, normalizeEncryptionOptions({
|
|
15462
15544
|
requestAddress: envelope.to,
|
|
15463
15545
|
}));
|
|
15464
15546
|
}
|
|
15465
|
-
logger$
|
|
15547
|
+
logger$Y.debug('using_sealed_encryption_options', {
|
|
15466
15548
|
envp_id: envelope.id,
|
|
15467
15549
|
options,
|
|
15468
15550
|
});
|
|
15469
15551
|
return await this.handleToBeEncryptedEnvelopeWithOptions(envelope, context, options);
|
|
15470
15552
|
}
|
|
15471
|
-
logger$
|
|
15553
|
+
logger$Y.debug('no_encryption_options_requesting_key', {
|
|
15472
15554
|
envp_id: envelope.id,
|
|
15473
15555
|
});
|
|
15474
15556
|
return await this.handleToBeEncryptedEnvelopeWithOptions(envelope, context, normalizeEncryptionOptions({
|
|
@@ -15476,7 +15558,7 @@ class EnvelopeSecurityHandler {
|
|
|
15476
15558
|
}));
|
|
15477
15559
|
}
|
|
15478
15560
|
catch (error) {
|
|
15479
|
-
logger$
|
|
15561
|
+
logger$Y.debug('sealed_key_lookup_failed_requesting', {
|
|
15480
15562
|
envp_id: envelope.id,
|
|
15481
15563
|
error: error instanceof Error ? error.message : String(error),
|
|
15482
15564
|
});
|
|
@@ -15487,7 +15569,7 @@ class EnvelopeSecurityHandler {
|
|
|
15487
15569
|
}
|
|
15488
15570
|
async handleChannelEncryption(envelope, context) {
|
|
15489
15571
|
if (!envelope.to) {
|
|
15490
|
-
logger$
|
|
15572
|
+
logger$Y.warning('channel_encryption_requested_but_no_destination', {
|
|
15491
15573
|
envp_id: envelope.id,
|
|
15492
15574
|
});
|
|
15493
15575
|
return true;
|
|
@@ -15502,13 +15584,13 @@ class EnvelopeSecurityHandler {
|
|
|
15502
15584
|
return true;
|
|
15503
15585
|
}
|
|
15504
15586
|
if (context.originType !== core.DeliveryOriginType.LOCAL) {
|
|
15505
|
-
logger$
|
|
15587
|
+
logger$Y.warning('envelope_encryption_rejected_non_local', {
|
|
15506
15588
|
origin: context.originType,
|
|
15507
15589
|
});
|
|
15508
15590
|
return true;
|
|
15509
15591
|
}
|
|
15510
15592
|
if (!isDataFrame$4(envelope.frame)) {
|
|
15511
|
-
logger$
|
|
15593
|
+
logger$Y.trace('skipping_encryption_non_dataframe', {
|
|
15512
15594
|
envp_id: envelope.id,
|
|
15513
15595
|
frame_type: envelope.frame.type,
|
|
15514
15596
|
});
|
|
@@ -15519,7 +15601,7 @@ class EnvelopeSecurityHandler {
|
|
|
15519
15601
|
? normalizeEncryptionOptions(rawOptions)
|
|
15520
15602
|
: undefined;
|
|
15521
15603
|
if (!options) {
|
|
15522
|
-
logger$
|
|
15604
|
+
logger$Y.warning('no_encryption_options_provided', {
|
|
15523
15605
|
envp_id: envelope.id,
|
|
15524
15606
|
});
|
|
15525
15607
|
return true;
|
|
@@ -15531,13 +15613,13 @@ class EnvelopeSecurityHandler {
|
|
|
15531
15613
|
return true;
|
|
15532
15614
|
}
|
|
15533
15615
|
if (context.originType !== core.DeliveryOriginType.LOCAL) {
|
|
15534
|
-
logger$
|
|
15616
|
+
logger$Y.warning('envelope_encryption_rejected_non_local', {
|
|
15535
15617
|
origin: context.originType,
|
|
15536
15618
|
});
|
|
15537
15619
|
return true;
|
|
15538
15620
|
}
|
|
15539
15621
|
if (!isDataFrame$4(envelope.frame)) {
|
|
15540
|
-
logger$
|
|
15622
|
+
logger$Y.trace('skipping_encryption_non_dataframe', {
|
|
15541
15623
|
envp_id: envelope.id,
|
|
15542
15624
|
frame_type: envelope.frame.type,
|
|
15543
15625
|
});
|
|
@@ -15554,7 +15636,7 @@ class EnvelopeSecurityHandler {
|
|
|
15554
15636
|
// Skip encryption if envelope is already encrypted
|
|
15555
15637
|
// This prevents re-queuing when replayed envelopes go through security again
|
|
15556
15638
|
if (envelope.sec?.enc) {
|
|
15557
|
-
logger$
|
|
15639
|
+
logger$Y.debug('skipping_encryption_already_encrypted', {
|
|
15558
15640
|
envp_id: envelope.id,
|
|
15559
15641
|
destination: envelope.to ? String(envelope.to) : undefined,
|
|
15560
15642
|
});
|
|
@@ -15563,14 +15645,14 @@ class EnvelopeSecurityHandler {
|
|
|
15563
15645
|
try {
|
|
15564
15646
|
const result = await this.encryptionManager.encryptEnvelope(envelope, normalizedOptions);
|
|
15565
15647
|
if (result.status === exports.EncryptionStatus.QUEUED) {
|
|
15566
|
-
logger$
|
|
15648
|
+
logger$Y.debug('envelope_queued_for_encryption', {
|
|
15567
15649
|
envp_id: envelope.id,
|
|
15568
15650
|
});
|
|
15569
15651
|
await this.handleEncryptionQueueing(envelope, context, normalizedOptions);
|
|
15570
15652
|
return false;
|
|
15571
15653
|
}
|
|
15572
15654
|
if (result.status === exports.EncryptionStatus.OK) {
|
|
15573
|
-
logger$
|
|
15655
|
+
logger$Y.debug('envelope_encrypted', { envp_id: envelope.id });
|
|
15574
15656
|
if (result.envelope) {
|
|
15575
15657
|
envelope.frame = result.envelope.frame;
|
|
15576
15658
|
envelope.sec = result.envelope.sec;
|
|
@@ -15578,17 +15660,17 @@ class EnvelopeSecurityHandler {
|
|
|
15578
15660
|
return true;
|
|
15579
15661
|
}
|
|
15580
15662
|
if (result.status === exports.EncryptionStatus.SKIPPED) {
|
|
15581
|
-
logger$
|
|
15663
|
+
logger$Y.debug('envelope_encryption_skipped', { envp_id: envelope.id });
|
|
15582
15664
|
return true;
|
|
15583
15665
|
}
|
|
15584
|
-
logger$
|
|
15666
|
+
logger$Y.warning('unknown_encryption_status', {
|
|
15585
15667
|
envp_id: envelope.id,
|
|
15586
15668
|
status: result.status,
|
|
15587
15669
|
});
|
|
15588
15670
|
return true;
|
|
15589
15671
|
}
|
|
15590
15672
|
catch (error) {
|
|
15591
|
-
logger$
|
|
15673
|
+
logger$Y.error('encryption_failed', {
|
|
15592
15674
|
envp_id: envelope.id,
|
|
15593
15675
|
error: error instanceof Error ? error.message : String(error),
|
|
15594
15676
|
});
|
|
@@ -15627,7 +15709,7 @@ class EnvelopeSecurityHandler {
|
|
|
15627
15709
|
return;
|
|
15628
15710
|
}
|
|
15629
15711
|
if (normalizedOptions.encryptionType === 'channel') {
|
|
15630
|
-
logger$
|
|
15712
|
+
logger$Y.debug('channel_encryption_queueing_handled_internally', {
|
|
15631
15713
|
envp_id: envelope.id,
|
|
15632
15714
|
destination: normalizedOptions.destination
|
|
15633
15715
|
? String(normalizedOptions.destination)
|
|
@@ -15635,13 +15717,13 @@ class EnvelopeSecurityHandler {
|
|
|
15635
15717
|
});
|
|
15636
15718
|
return;
|
|
15637
15719
|
}
|
|
15638
|
-
logger$
|
|
15720
|
+
logger$Y.warning('unknown_encryption_queueing_options', {
|
|
15639
15721
|
envp_id: envelope.id,
|
|
15640
15722
|
options: normalizedOptions,
|
|
15641
15723
|
});
|
|
15642
15724
|
}
|
|
15643
15725
|
async handleFailedChannelEnvelopeCleanup(destination, reason) {
|
|
15644
|
-
logger$
|
|
15726
|
+
logger$Y.debug('channel_handshake_failure_cleanup_attempted', {
|
|
15645
15727
|
destination,
|
|
15646
15728
|
reason,
|
|
15647
15729
|
note: 'envelope_cleanup_handled_by_encryption_manager',
|
|
@@ -15652,7 +15734,7 @@ class EnvelopeSecurityHandler {
|
|
|
15652
15734
|
}
|
|
15653
15735
|
}
|
|
15654
15736
|
|
|
15655
|
-
const logger$
|
|
15737
|
+
const logger$X = getLogger('naylence.fame.node.secure_channel_frame_handler');
|
|
15656
15738
|
function isPlainRecord$1(value) {
|
|
15657
15739
|
if (typeof value !== 'object' || value === null) {
|
|
15658
15740
|
return false;
|
|
@@ -15742,7 +15824,7 @@ class SecureChannelFrameHandler {
|
|
|
15742
15824
|
assertSecureChannelManager(this.secureChannelManager);
|
|
15743
15825
|
const frame = envelope.frame;
|
|
15744
15826
|
assertFrameType(frame, 'SecureOpen');
|
|
15745
|
-
logger$
|
|
15827
|
+
logger$X.debug('received_secure_open', {
|
|
15746
15828
|
cid: frame.cid,
|
|
15747
15829
|
algorithm: frame.alg,
|
|
15748
15830
|
});
|
|
@@ -15765,13 +15847,13 @@ class SecureChannelFrameHandler {
|
|
|
15765
15847
|
stickySid: envelope.sid ?? undefined,
|
|
15766
15848
|
expectedResponseType: core.FameResponseType.NONE,
|
|
15767
15849
|
};
|
|
15768
|
-
logger$
|
|
15850
|
+
logger$X.debug('stickiness_requested_for_channel_encryption', {
|
|
15769
15851
|
cid: frame.cid,
|
|
15770
15852
|
reason: 'secure_channel_established',
|
|
15771
15853
|
});
|
|
15772
15854
|
}
|
|
15773
15855
|
await this.sendCallback(responseEnvelope, responseContext);
|
|
15774
|
-
logger$
|
|
15856
|
+
logger$X.debug('sent_secure_accept', { cid: frame.cid, ok: acceptFrame.ok });
|
|
15775
15857
|
if (acceptFrame.ok && this.envelopeSecurityHandler) {
|
|
15776
15858
|
const destination = extractDestinationFromChannelId(frame.cid);
|
|
15777
15859
|
if (destination) {
|
|
@@ -15783,13 +15865,13 @@ class SecureChannelFrameHandler {
|
|
|
15783
15865
|
assertSecureChannelManager(this.secureChannelManager);
|
|
15784
15866
|
const frame = envelope.frame;
|
|
15785
15867
|
assertFrameType(frame, 'SecureAccept');
|
|
15786
|
-
logger$
|
|
15868
|
+
logger$X.debug('received_secure_accept', { cid: frame.cid, ok: frame.ok });
|
|
15787
15869
|
const success = await this.secureChannelManager.handleAcceptFrame(frame);
|
|
15788
15870
|
if (!success) {
|
|
15789
|
-
logger$
|
|
15871
|
+
logger$X.warning('failed_to_complete_channel', { cid: frame.cid });
|
|
15790
15872
|
}
|
|
15791
15873
|
else {
|
|
15792
|
-
logger$
|
|
15874
|
+
logger$X.debug('channel_established', { cid: frame.cid });
|
|
15793
15875
|
if (this.envelopeSecurityHandler) {
|
|
15794
15876
|
const destination = extractDestinationFromChannelId(frame.cid);
|
|
15795
15877
|
if (destination) {
|
|
@@ -15801,7 +15883,7 @@ class SecureChannelFrameHandler {
|
|
|
15801
15883
|
const destination = extractDestinationFromChannelId(frame.cid);
|
|
15802
15884
|
if (destination) {
|
|
15803
15885
|
await this.envelopeSecurityHandler.handleChannelHandshakeFailed(frame.cid, destination, 'negative_secure_accept');
|
|
15804
|
-
logger$
|
|
15886
|
+
logger$X.debug('notified_handshake_failure', {
|
|
15805
15887
|
cid: frame.cid,
|
|
15806
15888
|
destination,
|
|
15807
15889
|
});
|
|
@@ -15812,7 +15894,7 @@ class SecureChannelFrameHandler {
|
|
|
15812
15894
|
assertSecureChannelManager(this.secureChannelManager);
|
|
15813
15895
|
const frame = envelope.frame;
|
|
15814
15896
|
assertFrameType(frame, 'SecureClose');
|
|
15815
|
-
logger$
|
|
15897
|
+
logger$X.debug('received_secure_close', {
|
|
15816
15898
|
cid: frame.cid,
|
|
15817
15899
|
reason: frame.reason,
|
|
15818
15900
|
});
|
|
@@ -15870,7 +15952,7 @@ function createNodeDeliveryContext(options = {}) {
|
|
|
15870
15952
|
class FameEnvironmentContext {
|
|
15871
15953
|
}
|
|
15872
15954
|
|
|
15873
|
-
const FACTORY_META$
|
|
15955
|
+
const FACTORY_META$17 = {
|
|
15874
15956
|
base: NODE_IDENTITY_POLICY_FACTORY_BASE_TYPE,
|
|
15875
15957
|
key: 'DefaultNodeIdentityPolicy',
|
|
15876
15958
|
};
|
|
@@ -15888,11 +15970,11 @@ class DefaultNodeIdentityPolicyFactory extends NodeIdentityPolicyFactory {
|
|
|
15888
15970
|
var defaultNodeIdentityPolicyFactory = /*#__PURE__*/Object.freeze({
|
|
15889
15971
|
__proto__: null,
|
|
15890
15972
|
DefaultNodeIdentityPolicyFactory: DefaultNodeIdentityPolicyFactory,
|
|
15891
|
-
FACTORY_META: FACTORY_META$
|
|
15973
|
+
FACTORY_META: FACTORY_META$17,
|
|
15892
15974
|
default: DefaultNodeIdentityPolicyFactory
|
|
15893
15975
|
});
|
|
15894
15976
|
|
|
15895
|
-
const logger$
|
|
15977
|
+
const logger$W = getLogger('naylence.fame.node.token_subject_node_identity_policy');
|
|
15896
15978
|
class TokenSubjectNodeIdentityPolicy {
|
|
15897
15979
|
async resolveInitialNodeId(context) {
|
|
15898
15980
|
if (context.configuredId) {
|
|
@@ -15904,7 +15986,7 @@ class TokenSubjectNodeIdentityPolicy {
|
|
|
15904
15986
|
return core.generateIdAsync();
|
|
15905
15987
|
}
|
|
15906
15988
|
async resolveAdmissionNodeId(context) {
|
|
15907
|
-
logger$
|
|
15989
|
+
logger$W.debug('resolve_admission_node_id_start', {
|
|
15908
15990
|
grantsCount: context.grants?.length ?? 0,
|
|
15909
15991
|
currentNodeId: context.currentNodeId,
|
|
15910
15992
|
});
|
|
@@ -15913,31 +15995,31 @@ class TokenSubjectNodeIdentityPolicy {
|
|
|
15913
15995
|
try {
|
|
15914
15996
|
const auth = grant.auth;
|
|
15915
15997
|
if (!auth) {
|
|
15916
|
-
logger$
|
|
15998
|
+
logger$W.debug('skipping_grant_no_auth', { grantType: grant.type });
|
|
15917
15999
|
continue;
|
|
15918
16000
|
}
|
|
15919
16001
|
const tokenProviderConfig = (auth.tokenProvider ??
|
|
15920
16002
|
auth.token_provider);
|
|
15921
16003
|
if (!tokenProviderConfig ||
|
|
15922
16004
|
typeof tokenProviderConfig.type !== 'string') {
|
|
15923
|
-
logger$
|
|
16005
|
+
logger$W.debug('skipping_grant_invalid_token_provider_config', {
|
|
15924
16006
|
grantType: grant.type,
|
|
15925
16007
|
config: tokenProviderConfig,
|
|
15926
16008
|
});
|
|
15927
16009
|
continue;
|
|
15928
16010
|
}
|
|
15929
|
-
logger$
|
|
16011
|
+
logger$W.debug('creating_token_provider', {
|
|
15930
16012
|
type: tokenProviderConfig.type,
|
|
15931
16013
|
});
|
|
15932
16014
|
const provider = await TokenProviderFactory.createTokenProvider(tokenProviderConfig);
|
|
15933
16015
|
const isExposing = isIdentityExposingTokenProvider(provider);
|
|
15934
|
-
logger$
|
|
16016
|
+
logger$W.debug('token_provider_created', {
|
|
15935
16017
|
type: tokenProviderConfig.type,
|
|
15936
16018
|
isIdentityExposing: isExposing,
|
|
15937
16019
|
});
|
|
15938
16020
|
if (isExposing) {
|
|
15939
16021
|
const identity = await provider.getIdentity();
|
|
15940
|
-
logger$
|
|
16022
|
+
logger$W.debug('retrieved_identity', { identity });
|
|
15941
16023
|
if (identity && identity.subject) {
|
|
15942
16024
|
const hashedSubject = await core.generateIdAsync({
|
|
15943
16025
|
mode: 'fingerprint',
|
|
@@ -15945,7 +16027,7 @@ class TokenSubjectNodeIdentityPolicy {
|
|
|
15945
16027
|
length: 8,
|
|
15946
16028
|
});
|
|
15947
16029
|
const newNodeId = `${hashedSubject}-${context.currentNodeId}`;
|
|
15948
|
-
logger$
|
|
16030
|
+
logger$W.info('resolved_identity_from_token', {
|
|
15949
16031
|
subject: identity.subject,
|
|
15950
16032
|
hashedSubject,
|
|
15951
16033
|
newNodeId,
|
|
@@ -15953,17 +16035,17 @@ class TokenSubjectNodeIdentityPolicy {
|
|
|
15953
16035
|
return newNodeId;
|
|
15954
16036
|
}
|
|
15955
16037
|
else {
|
|
15956
|
-
logger$
|
|
16038
|
+
logger$W.debug('identity_missing_subject', { identity });
|
|
15957
16039
|
}
|
|
15958
16040
|
}
|
|
15959
16041
|
}
|
|
15960
16042
|
catch (err) {
|
|
15961
|
-
logger$
|
|
16043
|
+
logger$W.warning('failed_to_extract_identity_from_grant', { error: err });
|
|
15962
16044
|
}
|
|
15963
16045
|
}
|
|
15964
16046
|
}
|
|
15965
16047
|
else {
|
|
15966
|
-
logger$
|
|
16048
|
+
logger$W.debug('no_grants_available');
|
|
15967
16049
|
}
|
|
15968
16050
|
return context.currentNodeId;
|
|
15969
16051
|
}
|
|
@@ -15974,7 +16056,7 @@ var tokenSubjectNodeIdentityPolicy = /*#__PURE__*/Object.freeze({
|
|
|
15974
16056
|
TokenSubjectNodeIdentityPolicy: TokenSubjectNodeIdentityPolicy
|
|
15975
16057
|
});
|
|
15976
16058
|
|
|
15977
|
-
const FACTORY_META$
|
|
16059
|
+
const FACTORY_META$16 = {
|
|
15978
16060
|
base: NODE_IDENTITY_POLICY_FACTORY_BASE_TYPE,
|
|
15979
16061
|
key: 'TokenSubjectNodeIdentityPolicy',
|
|
15980
16062
|
};
|
|
@@ -15993,12 +16075,12 @@ class TokenSubjectNodeIdentityPolicyFactory extends NodeIdentityPolicyFactory {
|
|
|
15993
16075
|
|
|
15994
16076
|
var tokenSubjectNodeIdentityPolicyFactory = /*#__PURE__*/Object.freeze({
|
|
15995
16077
|
__proto__: null,
|
|
15996
|
-
FACTORY_META: FACTORY_META$
|
|
16078
|
+
FACTORY_META: FACTORY_META$16,
|
|
15997
16079
|
TokenSubjectNodeIdentityPolicyFactory: TokenSubjectNodeIdentityPolicyFactory,
|
|
15998
16080
|
default: TokenSubjectNodeIdentityPolicyFactory
|
|
15999
16081
|
});
|
|
16000
16082
|
|
|
16001
|
-
const logger$
|
|
16083
|
+
const logger$V = getLogger('naylence.fame.node.node_identity_policy_profile_factory');
|
|
16002
16084
|
const PROFILE_NAME_DEFAULT = 'default';
|
|
16003
16085
|
const PROFILE_NAME_TOKEN_SUBJECT = 'token-subject';
|
|
16004
16086
|
const PROFILE_NAME_TOKEN_SUBJECT_ALIAS = 'token_subject';
|
|
@@ -16013,7 +16095,7 @@ const PROFILE_MAP$5 = {
|
|
|
16013
16095
|
[PROFILE_NAME_TOKEN_SUBJECT]: TOKEN_SUBJECT_PROFILE,
|
|
16014
16096
|
[PROFILE_NAME_TOKEN_SUBJECT_ALIAS]: TOKEN_SUBJECT_PROFILE,
|
|
16015
16097
|
};
|
|
16016
|
-
const FACTORY_META$
|
|
16098
|
+
const FACTORY_META$15 = {
|
|
16017
16099
|
base: NODE_IDENTITY_POLICY_FACTORY_BASE_TYPE,
|
|
16018
16100
|
key: 'NodeIdentityPolicyProfile',
|
|
16019
16101
|
};
|
|
@@ -16025,7 +16107,7 @@ class NodeIdentityPolicyProfileFactory extends NodeIdentityPolicyFactory {
|
|
|
16025
16107
|
async create(config) {
|
|
16026
16108
|
const normalized = normalizeConfig$t(config);
|
|
16027
16109
|
const profileConfig = resolveProfileConfig$4(normalized.profile);
|
|
16028
|
-
logger$
|
|
16110
|
+
logger$V.debug('enabling_node_identity_policy_profile', {
|
|
16029
16111
|
profile: normalized.profile,
|
|
16030
16112
|
});
|
|
16031
16113
|
return NodeIdentityPolicyFactory.createNodeIdentityPolicy(profileConfig);
|
|
@@ -16061,11 +16143,95 @@ function deepClone$4(value) {
|
|
|
16061
16143
|
|
|
16062
16144
|
var nodeIdentityPolicyProfileFactory = /*#__PURE__*/Object.freeze({
|
|
16063
16145
|
__proto__: null,
|
|
16064
|
-
FACTORY_META: FACTORY_META$
|
|
16146
|
+
FACTORY_META: FACTORY_META$15,
|
|
16065
16147
|
NodeIdentityPolicyProfileFactory: NodeIdentityPolicyProfileFactory,
|
|
16066
16148
|
default: NodeIdentityPolicyProfileFactory
|
|
16067
16149
|
});
|
|
16068
16150
|
|
|
16151
|
+
/**
|
|
16152
|
+
* Environment variable for overriding max initial attempts.
|
|
16153
|
+
*/
|
|
16154
|
+
const ENV_VAR_SESSION_MAX_INITIAL_ATTEMPTS = 'FAME_SESSION_MAX_INITIAL_ATTEMPTS';
|
|
16155
|
+
/**
|
|
16156
|
+
* Default implementation of connection retry policy.
|
|
16157
|
+
*
|
|
16158
|
+
* Before first successful attach:
|
|
16159
|
+
* - Respects maxInitialAttempts configuration
|
|
16160
|
+
* - Uses exponential backoff with jitter
|
|
16161
|
+
*
|
|
16162
|
+
* After first successful attach:
|
|
16163
|
+
* - Always retries (unlimited) to maintain connection
|
|
16164
|
+
* - Resets backoff if connection was stable for >10 seconds
|
|
16165
|
+
*/
|
|
16166
|
+
class DefaultConnectionRetryPolicy {
|
|
16167
|
+
constructor(options = {}) {
|
|
16168
|
+
// Check for environment variable override
|
|
16169
|
+
const envValue = typeof process !== 'undefined'
|
|
16170
|
+
? process.env?.[ENV_VAR_SESSION_MAX_INITIAL_ATTEMPTS]
|
|
16171
|
+
: undefined;
|
|
16172
|
+
if (envValue !== undefined && envValue !== '') {
|
|
16173
|
+
const parsed = parseInt(envValue, 10);
|
|
16174
|
+
this.maxInitialAttempts = isNaN(parsed) ? (options.maxInitialAttempts ?? 1) : parsed;
|
|
16175
|
+
}
|
|
16176
|
+
else {
|
|
16177
|
+
this.maxInitialAttempts = options.maxInitialAttempts ?? 1;
|
|
16178
|
+
}
|
|
16179
|
+
}
|
|
16180
|
+
shouldRetry(context) {
|
|
16181
|
+
// After first successful attach, always retry to maintain connection
|
|
16182
|
+
if (context.hadSuccessfulAttach) {
|
|
16183
|
+
return true;
|
|
16184
|
+
}
|
|
16185
|
+
// maxInitialAttempts = 0 means unlimited retries
|
|
16186
|
+
if (this.maxInitialAttempts === 0) {
|
|
16187
|
+
return true;
|
|
16188
|
+
}
|
|
16189
|
+
// Fail if we've exceeded the configured max attempts
|
|
16190
|
+
return context.attemptNumber < this.maxInitialAttempts;
|
|
16191
|
+
}
|
|
16192
|
+
calculateRetryDelay(_context, baseDelay) {
|
|
16193
|
+
// Add jitter to prevent thundering herd
|
|
16194
|
+
const jitter = Math.random() * baseDelay;
|
|
16195
|
+
return baseDelay + jitter;
|
|
16196
|
+
}
|
|
16197
|
+
}
|
|
16198
|
+
|
|
16199
|
+
const logger$U = getLogger('naylence.fame.node.default-connection-retry-policy-factory');
|
|
16200
|
+
const FACTORY_META$14 = {
|
|
16201
|
+
base: CONNECTION_RETRY_POLICY_FACTORY_BASE_TYPE,
|
|
16202
|
+
key: 'DefaultConnectionRetryPolicy',
|
|
16203
|
+
};
|
|
16204
|
+
class DefaultConnectionRetryPolicyFactory extends ConnectionRetryPolicyFactory {
|
|
16205
|
+
constructor() {
|
|
16206
|
+
super(...arguments);
|
|
16207
|
+
this.type = 'DefaultConnectionRetryPolicy';
|
|
16208
|
+
this.isDefault = true;
|
|
16209
|
+
}
|
|
16210
|
+
async create(config) {
|
|
16211
|
+
const options = {};
|
|
16212
|
+
if (config) {
|
|
16213
|
+
const rawMax = config.maxInitialAttempts ??
|
|
16214
|
+
config.max_initial_attempts;
|
|
16215
|
+
if (rawMax !== undefined && rawMax !== null) {
|
|
16216
|
+
options.maxInitialAttempts =
|
|
16217
|
+
typeof rawMax === 'string' ? parseInt(rawMax, 10) : Number(rawMax);
|
|
16218
|
+
}
|
|
16219
|
+
}
|
|
16220
|
+
const policy = new DefaultConnectionRetryPolicy(options);
|
|
16221
|
+
logger$U.debug('connection_retry_policy_created', {
|
|
16222
|
+
maxInitialAttempts: policy.maxInitialAttempts,
|
|
16223
|
+
});
|
|
16224
|
+
return policy;
|
|
16225
|
+
}
|
|
16226
|
+
}
|
|
16227
|
+
|
|
16228
|
+
var defaultConnectionRetryPolicyFactory = /*#__PURE__*/Object.freeze({
|
|
16229
|
+
__proto__: null,
|
|
16230
|
+
DefaultConnectionRetryPolicyFactory: DefaultConnectionRetryPolicyFactory,
|
|
16231
|
+
FACTORY_META: FACTORY_META$14,
|
|
16232
|
+
default: DefaultConnectionRetryPolicyFactory
|
|
16233
|
+
});
|
|
16234
|
+
|
|
16069
16235
|
const LOAD_BALANCER_STICKINESS_MANAGER_FACTORY_BASE_TYPE = 'LoadBalancerStickinessManagerFactory';
|
|
16070
16236
|
class LoadBalancerStickinessManagerFactory extends factory.AbstractResourceFactory {
|
|
16071
16237
|
static async createLoadBalancerStickinessManager(config, options = {}) {
|
|
@@ -19137,6 +19303,7 @@ class Sentinel extends FameNode {
|
|
|
19137
19303
|
this.maxAttachTtlSec = opts.maxAttachTtlSec ?? null;
|
|
19138
19304
|
this.requestedLogicals = opts.requestedLogicals ?? [];
|
|
19139
19305
|
this.attachClient = opts.attachClient ?? null;
|
|
19306
|
+
this.connectionRetryPolicy = opts.connectionRetryPolicy ?? null;
|
|
19140
19307
|
this.nodeAttachFrameHandler = new NodeAttachFrameHandler({
|
|
19141
19308
|
routingNode: this,
|
|
19142
19309
|
routeManager: this.routeManager,
|
|
@@ -19686,6 +19853,7 @@ class Sentinel extends FameNode {
|
|
|
19686
19853
|
onAttach: (info, connector) => this.onNodeAttachToPeer(info, connector),
|
|
19687
19854
|
onEpochChange: (epoch) => this.onEpochChange(epoch),
|
|
19688
19855
|
onWelcome: async () => undefined,
|
|
19856
|
+
retryPolicy: this.connectionRetryPolicy,
|
|
19689
19857
|
});
|
|
19690
19858
|
await sessionManager.start();
|
|
19691
19859
|
const systemId = sessionManager.systemId;
|
|
@@ -41439,13 +41607,17 @@ exports.BindingStoreEntryRecord = BindingStoreEntryRecord;
|
|
|
41439
41607
|
exports.BrowserAutoKeyCredentialProvider = BrowserAutoKeyCredentialProvider;
|
|
41440
41608
|
exports.BrowserWrappedKeyCredentialProvider = BrowserWrappedKeyCredentialProvider;
|
|
41441
41609
|
exports.CERTIFICATE_MANAGER_FACTORY_BASE_TYPE = CERTIFICATE_MANAGER_FACTORY_BASE_TYPE;
|
|
41610
|
+
exports.CONNECTION_RETRY_POLICY_FACTORY_BASE_TYPE = CONNECTION_RETRY_POLICY_FACTORY_BASE_TYPE;
|
|
41442
41611
|
exports.CREDENTIAL_PROVIDER_FACTORY_BASE_TYPE = CREDENTIAL_PROVIDER_FACTORY_BASE_TYPE;
|
|
41443
41612
|
exports.CRYPTO_LEVEL_SECURITY_ORDER = CRYPTO_LEVEL_SECURITY_ORDER;
|
|
41444
41613
|
exports.CertificateManagerFactory = CertificateManagerFactory;
|
|
41614
|
+
exports.ConnectionRetryPolicyFactory = ConnectionRetryPolicyFactory;
|
|
41445
41615
|
exports.ConnectorConfigDefaults = ConnectorConfigDefaults;
|
|
41446
41616
|
exports.ConnectorFactory = ConnectorFactory;
|
|
41447
41617
|
exports.ConsoleMetricsEmitter = ConsoleMetricsEmitter;
|
|
41448
41618
|
exports.DEFAULT_WELCOME_FACTORY_META = FACTORY_META$$;
|
|
41619
|
+
exports.DefaultConnectionRetryPolicy = DefaultConnectionRetryPolicy;
|
|
41620
|
+
exports.DefaultConnectionRetryPolicyFactory = DefaultConnectionRetryPolicyFactory;
|
|
41449
41621
|
exports.DefaultCryptoProvider = DefaultCryptoProvider;
|
|
41450
41622
|
exports.DefaultKeyManager = DefaultKeyManager;
|
|
41451
41623
|
exports.DefaultNodeIdentityPolicy = DefaultNodeIdentityPolicy;
|
|
@@ -41466,6 +41638,7 @@ exports.ENV_VAR_JWT_AUDIENCE = ENV_VAR_JWT_AUDIENCE$1;
|
|
|
41466
41638
|
exports.ENV_VAR_JWT_REVERSE_AUTH_AUDIENCE = ENV_VAR_JWT_REVERSE_AUTH_AUDIENCE;
|
|
41467
41639
|
exports.ENV_VAR_JWT_REVERSE_AUTH_TRUSTED_ISSUER = ENV_VAR_JWT_REVERSE_AUTH_TRUSTED_ISSUER;
|
|
41468
41640
|
exports.ENV_VAR_JWT_TRUSTED_ISSUER = ENV_VAR_JWT_TRUSTED_ISSUER;
|
|
41641
|
+
exports.ENV_VAR_SESSION_MAX_INITIAL_ATTEMPTS = ENV_VAR_SESSION_MAX_INITIAL_ATTEMPTS;
|
|
41469
41642
|
exports.ENV_VAR_SHOW_ENVELOPES = ENV_VAR_SHOW_ENVELOPES$1;
|
|
41470
41643
|
exports.EdDSAEnvelopeSigner = EdDSAEnvelopeSigner;
|
|
41471
41644
|
exports.EncryptedKeyValueStore = EncryptedKeyValueStore;
|