@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/node.cjs
CHANGED
|
@@ -725,7 +725,7 @@ class TaskCancelledError extends Error {
|
|
|
725
725
|
* Provides functionality similar to Python's asyncio TaskSpawner with proper
|
|
726
726
|
* error handling, cancellation, and graceful shutdown capabilities.
|
|
727
727
|
*/
|
|
728
|
-
const logger$
|
|
728
|
+
const logger$1m = getLogger('naylence.fame.util.task_spawner');
|
|
729
729
|
function firstDefined(source, keys) {
|
|
730
730
|
for (const key of keys) {
|
|
731
731
|
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
@@ -886,7 +886,7 @@ class TaskSpawner {
|
|
|
886
886
|
const taskId = `task-${++this._taskCounter}`;
|
|
887
887
|
const taskName = normalizedOptions.name || `unnamed-${taskId}`;
|
|
888
888
|
const timeout = normalizedOptions.timeout ?? this._config.defaultTimeout;
|
|
889
|
-
logger$
|
|
889
|
+
logger$1m.debug('starting_background_task', {
|
|
890
890
|
task_name: taskName,
|
|
891
891
|
task_id: taskId,
|
|
892
892
|
});
|
|
@@ -903,7 +903,7 @@ class TaskSpawner {
|
|
|
903
903
|
task.promise
|
|
904
904
|
.then(() => {
|
|
905
905
|
if (!this._suppressCompletionLogging) {
|
|
906
|
-
logger$
|
|
906
|
+
logger$1m.debug('task_completed_successfully', {
|
|
907
907
|
task_name: taskName,
|
|
908
908
|
task_id: taskId,
|
|
909
909
|
duration_ms: Date.now() - task.startTime,
|
|
@@ -957,7 +957,7 @@ class TaskSpawner {
|
|
|
957
957
|
error.name === 'AbortError' ||
|
|
958
958
|
error.message === 'Task cancelled' ||
|
|
959
959
|
error.message === 'Aborted') {
|
|
960
|
-
logger$
|
|
960
|
+
logger$1m.debug('task_cancelled', {
|
|
961
961
|
task_name: taskName,
|
|
962
962
|
note: 'Task cancelled as requested',
|
|
963
963
|
});
|
|
@@ -965,7 +965,7 @@ class TaskSpawner {
|
|
|
965
965
|
}
|
|
966
966
|
// Handle timeout
|
|
967
967
|
if (error instanceof TaskTimeoutError) {
|
|
968
|
-
logger$
|
|
968
|
+
logger$1m.warning('task_timed_out', {
|
|
969
969
|
task_name: taskName,
|
|
970
970
|
error: error.message,
|
|
971
971
|
});
|
|
@@ -977,7 +977,7 @@ class TaskSpawner {
|
|
|
977
977
|
// Handle known WebSocket shutdown race condition (similar to Python version)
|
|
978
978
|
if (error.message.includes("await wasn't used with future") ||
|
|
979
979
|
error.message.includes('WebSocket closed during receive')) {
|
|
980
|
-
logger$
|
|
980
|
+
logger$1m.debug('task_shutdown_race_condition_handled', {
|
|
981
981
|
task_name: taskName,
|
|
982
982
|
note: 'Normal WebSocket close timing during shutdown - not an error',
|
|
983
983
|
});
|
|
@@ -987,7 +987,7 @@ class TaskSpawner {
|
|
|
987
987
|
if (error.name === 'FameTransportClose' ||
|
|
988
988
|
error.message.includes('normal closure') ||
|
|
989
989
|
error.message.includes('Connection closed')) {
|
|
990
|
-
logger$
|
|
990
|
+
logger$1m.debug('task_shutdown_completed_normally', {
|
|
991
991
|
task_name: taskName,
|
|
992
992
|
note: 'Task closed normally during shutdown',
|
|
993
993
|
});
|
|
@@ -995,7 +995,7 @@ class TaskSpawner {
|
|
|
995
995
|
}
|
|
996
996
|
// Handle PKCE redirect "errors" as info
|
|
997
997
|
if (error.name === 'OAuth2PkceRedirectInitiatedError') {
|
|
998
|
-
logger$
|
|
998
|
+
logger$1m.debug('background_task_redirecting', {
|
|
999
999
|
task_name: taskName,
|
|
1000
1000
|
note: 'Task interrupted for PKCE redirect',
|
|
1001
1001
|
});
|
|
@@ -1008,14 +1008,14 @@ class TaskSpawner {
|
|
|
1008
1008
|
// Log retriable errors as warnings (they'll be retried by upstream logic)
|
|
1009
1009
|
// Log non-retriable errors as errors (fatal failures)
|
|
1010
1010
|
if (isRetriableError) {
|
|
1011
|
-
logger$
|
|
1011
|
+
logger$1m.warning('background_task_failed', {
|
|
1012
1012
|
task_name: taskName,
|
|
1013
1013
|
error: error.message,
|
|
1014
1014
|
retriable: true,
|
|
1015
1015
|
});
|
|
1016
1016
|
}
|
|
1017
1017
|
else {
|
|
1018
|
-
logger$
|
|
1018
|
+
logger$1m.error('background_task_failed', {
|
|
1019
1019
|
task_name: taskName,
|
|
1020
1020
|
error: error.message,
|
|
1021
1021
|
stack: error.stack,
|
|
@@ -1034,11 +1034,11 @@ class TaskSpawner {
|
|
|
1034
1034
|
async shutdownTasks(options = {}) {
|
|
1035
1035
|
const { gracePeriod, cancelHanging, joinTimeout } = normalizeShutdownOptions(options);
|
|
1036
1036
|
if (this._tasks.size === 0) {
|
|
1037
|
-
logger$
|
|
1037
|
+
logger$1m.debug('shutdown_tasks_no_tasks_to_shutdown');
|
|
1038
1038
|
return;
|
|
1039
1039
|
}
|
|
1040
1040
|
this._suppressCompletionLogging = true;
|
|
1041
|
-
logger$
|
|
1041
|
+
logger$1m.debug('shutting_down_tasks', {
|
|
1042
1042
|
task_count: this._tasks.size,
|
|
1043
1043
|
task_names: Array.from(this._tasks.values()).map((t) => t.name),
|
|
1044
1044
|
grace_period_ms: gracePeriod,
|
|
@@ -1053,7 +1053,7 @@ class TaskSpawner {
|
|
|
1053
1053
|
if (cancelHanging) {
|
|
1054
1054
|
const stillRunning = tasks.filter((task) => task.getState() === TaskState.RUNNING && !completed.has(task));
|
|
1055
1055
|
if (stillRunning.length > 0) {
|
|
1056
|
-
logger$
|
|
1056
|
+
logger$1m.debug('tasks_did_not_complete_within_grace_period', {
|
|
1057
1057
|
hanging_count: stillRunning.length,
|
|
1058
1058
|
});
|
|
1059
1059
|
// Wait for them to finish with individual timeouts
|
|
@@ -1063,7 +1063,7 @@ class TaskSpawner {
|
|
|
1063
1063
|
}
|
|
1064
1064
|
catch (error) {
|
|
1065
1065
|
if (error instanceof TaskTimeoutError) {
|
|
1066
|
-
logger$
|
|
1066
|
+
logger$1m.warning('task_did_not_shutdown', {
|
|
1067
1067
|
task_name: task.name || task.id,
|
|
1068
1068
|
join_timeout_ms: joinTimeout,
|
|
1069
1069
|
});
|
|
@@ -1074,7 +1074,7 @@ class TaskSpawner {
|
|
|
1074
1074
|
}
|
|
1075
1075
|
else if (!(error instanceof TaskCancelledError)) {
|
|
1076
1076
|
/* istanbul ignore next - unreachable defensive branch */
|
|
1077
|
-
logger$
|
|
1077
|
+
logger$1m.error('task_raised_during_cancellation', {
|
|
1078
1078
|
task_name: task.name || task.id,
|
|
1079
1079
|
error: error instanceof Error ? error.message : String(error),
|
|
1080
1080
|
});
|
|
@@ -1193,7 +1193,7 @@ class TaskSpawner {
|
|
|
1193
1193
|
* condition/promise and ensure at most one notifier coroutine exists for a
|
|
1194
1194
|
* flow at any time.
|
|
1195
1195
|
*/
|
|
1196
|
-
const logger$
|
|
1196
|
+
const logger$1l = getLogger('naylence.fame.flow.flow_controller');
|
|
1197
1197
|
/**
|
|
1198
1198
|
* Simple condition variable implementation for TypeScript/Node.js
|
|
1199
1199
|
* Similar to Python's asyncio.Condition
|
|
@@ -1327,7 +1327,7 @@ class FlowController {
|
|
|
1327
1327
|
const newBalance = Math.max(0, Math.min(this.initialWindow, prev + delta));
|
|
1328
1328
|
this.credits.set(flowId, newBalance);
|
|
1329
1329
|
const crossedZero = prev <= 0 && newBalance > 0;
|
|
1330
|
-
logger$
|
|
1330
|
+
logger$1l.debug('flow_controller_add_credits', {
|
|
1331
1331
|
flow_id: flowId,
|
|
1332
1332
|
delta,
|
|
1333
1333
|
prev_balance: prev,
|
|
@@ -1347,12 +1347,12 @@ class FlowController {
|
|
|
1347
1347
|
async acquire(flowId) {
|
|
1348
1348
|
this.ensureFlow(flowId);
|
|
1349
1349
|
const condition = this.conditions.get(flowId);
|
|
1350
|
-
logger$
|
|
1350
|
+
logger$1l.debug('flow_controller_acquire_attempt', {
|
|
1351
1351
|
flow_id: flowId,
|
|
1352
1352
|
current_balance: this.credits.get(flowId),
|
|
1353
1353
|
});
|
|
1354
1354
|
while (this.credits.get(flowId) <= 0) {
|
|
1355
|
-
logger$
|
|
1355
|
+
logger$1l.debug('flow_controller_waiting_for_credits', {
|
|
1356
1356
|
flow_id: flowId,
|
|
1357
1357
|
current_balance: this.credits.get(flowId),
|
|
1358
1358
|
});
|
|
@@ -1360,12 +1360,12 @@ class FlowController {
|
|
|
1360
1360
|
}
|
|
1361
1361
|
const newBalance = this.credits.get(flowId) - 1;
|
|
1362
1362
|
this.credits.set(flowId, newBalance);
|
|
1363
|
-
logger$
|
|
1363
|
+
logger$1l.debug('flow_controller_acquire_success', {
|
|
1364
1364
|
flow_id: flowId,
|
|
1365
1365
|
new_balance: newBalance,
|
|
1366
1366
|
});
|
|
1367
1367
|
if (newBalance <= this.lowWatermark) {
|
|
1368
|
-
logger$
|
|
1368
|
+
logger$1l.debug('flow_controller_acquire_below_low_watermark', {
|
|
1369
1369
|
flow_id: flowId,
|
|
1370
1370
|
low_watermark: this.lowWatermark,
|
|
1371
1371
|
});
|
|
@@ -1389,7 +1389,7 @@ class FlowController {
|
|
|
1389
1389
|
const current = this.credits.get(flowId);
|
|
1390
1390
|
const remaining = Math.max(current - credits, 0);
|
|
1391
1391
|
this.credits.set(flowId, remaining);
|
|
1392
|
-
logger$
|
|
1392
|
+
logger$1l.debug('flow_controller_consume', {
|
|
1393
1393
|
flow_id: flowId,
|
|
1394
1394
|
requested: credits,
|
|
1395
1395
|
prev_balance: current,
|
|
@@ -1415,7 +1415,7 @@ class FlowController {
|
|
|
1415
1415
|
this.windowIds.delete(flowId);
|
|
1416
1416
|
this.credits.set(flowId, this.initialWindow);
|
|
1417
1417
|
this.wakeWaiters(flowId);
|
|
1418
|
-
logger$
|
|
1418
|
+
logger$1l.debug('flow_controller_flow_reset', {
|
|
1419
1419
|
flow_id: flowId,
|
|
1420
1420
|
reset_balance: this.initialWindow,
|
|
1421
1421
|
});
|
|
@@ -2047,7 +2047,7 @@ class TaskCancellationError extends Error {
|
|
|
2047
2047
|
this.name = 'TaskCancellationError';
|
|
2048
2048
|
}
|
|
2049
2049
|
}
|
|
2050
|
-
const logger$
|
|
2050
|
+
const logger$1k = getLogger('naylence.fame.connector.base_async_connector');
|
|
2051
2051
|
// Environment variables
|
|
2052
2052
|
const ENV_VAR_FAME_FLOW_CONTROL = 'FAME_FLOW_CONTROL';
|
|
2053
2053
|
const FLOW_CONTROL_ENABLED = typeof process !== 'undefined' && process?.env
|
|
@@ -2130,7 +2130,7 @@ class BaseAsyncConnector extends TaskSpawner {
|
|
|
2130
2130
|
if (this._state !== newState) {
|
|
2131
2131
|
const oldState = this._state;
|
|
2132
2132
|
this._state = newState;
|
|
2133
|
-
logger$
|
|
2133
|
+
logger$1k.debug('connector_state_transition', {
|
|
2134
2134
|
connector_id: this._connectorFlowId,
|
|
2135
2135
|
old_state: oldState,
|
|
2136
2136
|
new_state: newState,
|
|
@@ -2169,12 +2169,12 @@ class BaseAsyncConnector extends TaskSpawner {
|
|
|
2169
2169
|
* Stop the connector gracefully
|
|
2170
2170
|
*/
|
|
2171
2171
|
async stop() {
|
|
2172
|
-
logger$
|
|
2172
|
+
logger$1k.debug('stopping_connector', {
|
|
2173
2173
|
current_state: this._state,
|
|
2174
2174
|
connector_id: this._connectorFlowId,
|
|
2175
2175
|
});
|
|
2176
2176
|
if (!core.ConnectorStateUtils.canStop(this._state)) {
|
|
2177
|
-
logger$
|
|
2177
|
+
logger$1k.debug('connector_stop_already_stopped', {
|
|
2178
2178
|
current_state: this._state,
|
|
2179
2179
|
connector_id: this._connectorFlowId,
|
|
2180
2180
|
});
|
|
@@ -2185,7 +2185,7 @@ class BaseAsyncConnector extends TaskSpawner {
|
|
|
2185
2185
|
if (this._lastError) {
|
|
2186
2186
|
throw this._lastError;
|
|
2187
2187
|
}
|
|
2188
|
-
logger$
|
|
2188
|
+
logger$1k.debug('connector_stopped', {
|
|
2189
2189
|
current_state: this._state,
|
|
2190
2190
|
connector_id: this._connectorFlowId,
|
|
2191
2191
|
});
|
|
@@ -2194,19 +2194,19 @@ class BaseAsyncConnector extends TaskSpawner {
|
|
|
2194
2194
|
* Pause the connector (suspends heartbeat and housekeeping, but keeps connection alive)
|
|
2195
2195
|
*/
|
|
2196
2196
|
async pause() {
|
|
2197
|
-
logger$
|
|
2197
|
+
logger$1k.debug('pausing_connector', {
|
|
2198
2198
|
current_state: this._state,
|
|
2199
2199
|
connector_id: this._connectorFlowId,
|
|
2200
2200
|
});
|
|
2201
2201
|
if (this._state !== core.ConnectorState.STARTED) {
|
|
2202
|
-
logger$
|
|
2202
|
+
logger$1k.debug('connector_pause_invalid_state', {
|
|
2203
2203
|
current_state: this._state,
|
|
2204
2204
|
connector_id: this._connectorFlowId,
|
|
2205
2205
|
});
|
|
2206
2206
|
return;
|
|
2207
2207
|
}
|
|
2208
2208
|
this._setState(core.ConnectorState.PAUSED);
|
|
2209
|
-
logger$
|
|
2209
|
+
logger$1k.debug('connector_paused', {
|
|
2210
2210
|
current_state: this._state,
|
|
2211
2211
|
connector_id: this._connectorFlowId,
|
|
2212
2212
|
});
|
|
@@ -2215,19 +2215,19 @@ class BaseAsyncConnector extends TaskSpawner {
|
|
|
2215
2215
|
* Resume the connector from paused state
|
|
2216
2216
|
*/
|
|
2217
2217
|
async resume() {
|
|
2218
|
-
logger$
|
|
2218
|
+
logger$1k.debug('resuming_connector', {
|
|
2219
2219
|
current_state: this._state,
|
|
2220
2220
|
connector_id: this._connectorFlowId,
|
|
2221
2221
|
});
|
|
2222
2222
|
if (this._state !== core.ConnectorState.PAUSED) {
|
|
2223
|
-
logger$
|
|
2223
|
+
logger$1k.debug('connector_resume_invalid_state', {
|
|
2224
2224
|
current_state: this._state,
|
|
2225
2225
|
connector_id: this._connectorFlowId,
|
|
2226
2226
|
});
|
|
2227
2227
|
return;
|
|
2228
2228
|
}
|
|
2229
2229
|
this._setState(core.ConnectorState.STARTED);
|
|
2230
|
-
logger$
|
|
2230
|
+
logger$1k.debug('connector_resumed', {
|
|
2231
2231
|
current_state: this._state,
|
|
2232
2232
|
connector_id: this._connectorFlowId,
|
|
2233
2233
|
});
|
|
@@ -2237,7 +2237,7 @@ class BaseAsyncConnector extends TaskSpawner {
|
|
|
2237
2237
|
*/
|
|
2238
2238
|
async close(code = 1000, reason = 'normal closure') {
|
|
2239
2239
|
if (!core.ConnectorStateUtils.canClose(this._state)) {
|
|
2240
|
-
logger$
|
|
2240
|
+
logger$1k.warning('connector_close_invalid_state', {
|
|
2241
2241
|
current_state: this._state,
|
|
2242
2242
|
connector_id: this._connectorFlowId,
|
|
2243
2243
|
});
|
|
@@ -2318,7 +2318,7 @@ class BaseAsyncConnector extends TaskSpawner {
|
|
|
2318
2318
|
// Add to queue and notify send loop
|
|
2319
2319
|
this._sendQueue.push(raw);
|
|
2320
2320
|
// Log for debugging
|
|
2321
|
-
logger$
|
|
2321
|
+
logger$1k.debug('send_envelope_queued', {
|
|
2322
2322
|
queue_length: this._sendQueue.length,
|
|
2323
2323
|
max_queue_size: this._maxQueueSize,
|
|
2324
2324
|
});
|
|
@@ -2367,14 +2367,14 @@ class BaseAsyncConnector extends TaskSpawner {
|
|
|
2367
2367
|
const item = this._sendQueue[0];
|
|
2368
2368
|
if (!item)
|
|
2369
2369
|
continue;
|
|
2370
|
-
logger$
|
|
2370
|
+
logger$1k.debug('send_loop_processing_item', {
|
|
2371
2371
|
queue_length_before_send: this._sendQueue.length,
|
|
2372
2372
|
});
|
|
2373
2373
|
// Send through transport (this may block)
|
|
2374
2374
|
await this._transportSendBytes(item);
|
|
2375
2375
|
// Only remove from queue after successful send
|
|
2376
2376
|
this._sendQueue.shift();
|
|
2377
|
-
logger$
|
|
2377
|
+
logger$1k.debug('send_loop_item_sent', {
|
|
2378
2378
|
queue_length_after_send: this._sendQueue.length,
|
|
2379
2379
|
});
|
|
2380
2380
|
}
|
|
@@ -2387,14 +2387,14 @@ class BaseAsyncConnector extends TaskSpawner {
|
|
|
2387
2387
|
}
|
|
2388
2388
|
else if (error instanceof TaskCancellationError) {
|
|
2389
2389
|
// Task cancellation is expected during shutdown - log as debug, not critical
|
|
2390
|
-
logger$
|
|
2390
|
+
logger$1k.debug('send loop cancelled', {
|
|
2391
2391
|
connector: this.constructor.name,
|
|
2392
2392
|
reason: error.message,
|
|
2393
2393
|
});
|
|
2394
2394
|
// Don't re-throw - this is normal during shutdown
|
|
2395
2395
|
}
|
|
2396
2396
|
else {
|
|
2397
|
-
logger$
|
|
2397
|
+
logger$1k.critical('unexpected exception in send loop', {
|
|
2398
2398
|
connector: this.constructor.name,
|
|
2399
2399
|
error: error instanceof Error ? error.message : String(error),
|
|
2400
2400
|
});
|
|
@@ -2435,7 +2435,7 @@ class BaseAsyncConnector extends TaskSpawner {
|
|
|
2435
2435
|
env = JSON.parse(jsonStr);
|
|
2436
2436
|
}
|
|
2437
2437
|
catch (error) {
|
|
2438
|
-
logger$
|
|
2438
|
+
logger$1k.error('Invalid envelope', {
|
|
2439
2439
|
message: message.toString(),
|
|
2440
2440
|
error: error instanceof Error ? error.message : String(error),
|
|
2441
2441
|
});
|
|
@@ -2459,7 +2459,7 @@ class BaseAsyncConnector extends TaskSpawner {
|
|
|
2459
2459
|
};
|
|
2460
2460
|
await withEnvelopeContextAsync(envelopeContext, async () => {
|
|
2461
2461
|
const prettyEnvelope = prettyModel$1(env);
|
|
2462
|
-
logger$
|
|
2462
|
+
logger$1k.trace('connector_received_envelope', {
|
|
2463
2463
|
envelope: env,
|
|
2464
2464
|
pretty: prettyEnvelope,
|
|
2465
2465
|
});
|
|
@@ -2488,7 +2488,7 @@ class BaseAsyncConnector extends TaskSpawner {
|
|
|
2488
2488
|
if (error instanceof TaskCancellationError) {
|
|
2489
2489
|
throw error;
|
|
2490
2490
|
}
|
|
2491
|
-
logger$
|
|
2491
|
+
logger$1k.error('handler_failed', {
|
|
2492
2492
|
error: error instanceof Error ? error.message : String(error),
|
|
2493
2493
|
envelope_id: env.id ?? null,
|
|
2494
2494
|
trace_id: env.traceId ?? null,
|
|
@@ -2509,14 +2509,14 @@ class BaseAsyncConnector extends TaskSpawner {
|
|
|
2509
2509
|
}
|
|
2510
2510
|
else if (error instanceof TaskCancellationError) {
|
|
2511
2511
|
// Task cancellation is expected during shutdown - log as debug, not critical
|
|
2512
|
-
logger$
|
|
2512
|
+
logger$1k.debug('receive loop cancelled', {
|
|
2513
2513
|
connector: this.constructor.name,
|
|
2514
2514
|
reason: error.message,
|
|
2515
2515
|
});
|
|
2516
2516
|
// Don't re-throw - this is normal during shutdown
|
|
2517
2517
|
}
|
|
2518
2518
|
else {
|
|
2519
|
-
logger$
|
|
2519
|
+
logger$1k.critical('unexpected_error_in recv_loop', {
|
|
2520
2520
|
error: error instanceof Error ? error.message : String(error),
|
|
2521
2521
|
});
|
|
2522
2522
|
throw error;
|
|
@@ -2532,7 +2532,7 @@ class BaseAsyncConnector extends TaskSpawner {
|
|
|
2532
2532
|
async _maybeEmitCredit(flowId, traceId) {
|
|
2533
2533
|
const remainingCredits = this._flowCtrl.getCredits(flowId);
|
|
2534
2534
|
const needsRefill = this._flowCtrl.needsRefill(flowId);
|
|
2535
|
-
logger$
|
|
2535
|
+
logger$1k.debug('maybe_emit_credit_check', {
|
|
2536
2536
|
connector_id: this._connectorFlowId,
|
|
2537
2537
|
flow_id: flowId,
|
|
2538
2538
|
trace_id: traceId ?? null,
|
|
@@ -2548,7 +2548,7 @@ class BaseAsyncConnector extends TaskSpawner {
|
|
|
2548
2548
|
}
|
|
2549
2549
|
const delta = this._initialWindow;
|
|
2550
2550
|
this._flowCtrl.addCredits(flowId, delta);
|
|
2551
|
-
logger$
|
|
2551
|
+
logger$1k.debug('maybe_emit_credit_emit', {
|
|
2552
2552
|
connector_id: this._connectorFlowId,
|
|
2553
2553
|
flow_id: flowId,
|
|
2554
2554
|
trace_id: traceId ?? null,
|
|
@@ -2568,7 +2568,7 @@ class BaseAsyncConnector extends TaskSpawner {
|
|
|
2568
2568
|
});
|
|
2569
2569
|
try {
|
|
2570
2570
|
await this.send(ackEnv);
|
|
2571
|
-
logger$
|
|
2571
|
+
logger$1k.debug('maybe_emit_credit_sent', {
|
|
2572
2572
|
connector_id: this._connectorFlowId,
|
|
2573
2573
|
flow_id: flowId,
|
|
2574
2574
|
trace_id: traceId ?? null,
|
|
@@ -2576,7 +2576,7 @@ class BaseAsyncConnector extends TaskSpawner {
|
|
|
2576
2576
|
});
|
|
2577
2577
|
}
|
|
2578
2578
|
catch (error) {
|
|
2579
|
-
logger$
|
|
2579
|
+
logger$1k.error('maybe_emit_credit_send_failed', {
|
|
2580
2580
|
connector_id: this._connectorFlowId,
|
|
2581
2581
|
flow_id: flowId,
|
|
2582
2582
|
trace_id: traceId ?? null,
|
|
@@ -2601,13 +2601,13 @@ class BaseAsyncConnector extends TaskSpawner {
|
|
|
2601
2601
|
*/
|
|
2602
2602
|
async _shutdown(code, reason, gracePeriod, exc) {
|
|
2603
2603
|
if (this._closed) {
|
|
2604
|
-
logger$
|
|
2604
|
+
logger$1k.debug('shutdown_already_closed', {
|
|
2605
2605
|
connector_id: this._connectorFlowId,
|
|
2606
2606
|
current_state: this._state,
|
|
2607
2607
|
});
|
|
2608
2608
|
return;
|
|
2609
2609
|
}
|
|
2610
|
-
logger$
|
|
2610
|
+
logger$1k.debug('connector_shutdown_starting', {
|
|
2611
2611
|
connector_id: this._connectorFlowId,
|
|
2612
2612
|
connector_type: this.constructor.name,
|
|
2613
2613
|
code,
|
|
@@ -2637,19 +2637,19 @@ class BaseAsyncConnector extends TaskSpawner {
|
|
|
2637
2637
|
this._sendPromiseResolve = undefined;
|
|
2638
2638
|
}
|
|
2639
2639
|
// Close transport
|
|
2640
|
-
logger$
|
|
2640
|
+
logger$1k.debug('connector_closing_transport', {
|
|
2641
2641
|
connector_id: this._connectorFlowId,
|
|
2642
2642
|
connector_type: this.constructor.name,
|
|
2643
2643
|
timestamp: new Date().toISOString(),
|
|
2644
2644
|
});
|
|
2645
2645
|
await this._transportClose(code, reason);
|
|
2646
|
-
logger$
|
|
2646
|
+
logger$1k.debug('connector_transport_closed', {
|
|
2647
2647
|
connector_id: this._connectorFlowId,
|
|
2648
2648
|
connector_type: this.constructor.name,
|
|
2649
2649
|
timestamp: new Date().toISOString(),
|
|
2650
2650
|
});
|
|
2651
2651
|
// Shutdown spawned tasks
|
|
2652
|
-
logger$
|
|
2652
|
+
logger$1k.debug('connector_shutting_down_tasks', {
|
|
2653
2653
|
connector_id: this._connectorFlowId,
|
|
2654
2654
|
connector_type: this.constructor.name,
|
|
2655
2655
|
grace_period_ms: effectiveGracePeriod * 1000,
|
|
@@ -2661,14 +2661,14 @@ class BaseAsyncConnector extends TaskSpawner {
|
|
|
2661
2661
|
gracePeriod: effectiveGracePeriod * 1000, // Convert to milliseconds
|
|
2662
2662
|
joinTimeout: this._shutdownJoinTimeout,
|
|
2663
2663
|
});
|
|
2664
|
-
logger$
|
|
2664
|
+
logger$1k.debug('connector_tasks_shutdown_complete', {
|
|
2665
2665
|
connector_id: this._connectorFlowId,
|
|
2666
2666
|
connector_type: this.constructor.name,
|
|
2667
2667
|
timestamp: new Date().toISOString(),
|
|
2668
2668
|
});
|
|
2669
2669
|
}
|
|
2670
2670
|
catch (error) {
|
|
2671
|
-
logger$
|
|
2671
|
+
logger$1k.warning('task_shutdown_error', {
|
|
2672
2672
|
connector_id: this._connectorFlowId,
|
|
2673
2673
|
error: error instanceof Error ? error.message : String(error),
|
|
2674
2674
|
});
|
|
@@ -2681,7 +2681,7 @@ class BaseAsyncConnector extends TaskSpawner {
|
|
|
2681
2681
|
if (this._closeResolver) {
|
|
2682
2682
|
this._closeResolver();
|
|
2683
2683
|
}
|
|
2684
|
-
logger$
|
|
2684
|
+
logger$1k.debug('connector_shutdown_complete', {
|
|
2685
2685
|
connector_id: this._connectorFlowId,
|
|
2686
2686
|
connector_type: this.constructor.name,
|
|
2687
2687
|
final_state: this._state,
|
|
@@ -2702,7 +2702,7 @@ class BaseAsyncConnector extends TaskSpawner {
|
|
|
2702
2702
|
* A transport adapter that works with both Node.js and browser WebSocket APIs.
|
|
2703
2703
|
* Supports both native WebSocket clients and server-side WebSocket connections.
|
|
2704
2704
|
*/
|
|
2705
|
-
const logger$
|
|
2705
|
+
const logger$1j = getLogger('naylence.fame.connector.websocket_connector');
|
|
2706
2706
|
/**
|
|
2707
2707
|
* WebSocket state constants (mirrors standard WebSocket states)
|
|
2708
2708
|
*/
|
|
@@ -2743,7 +2743,7 @@ class WebSocketConnector extends BaseAsyncConnector {
|
|
|
2743
2743
|
websocket.send_bytes &&
|
|
2744
2744
|
typeof websocket.receive_bytes === 'function' &&
|
|
2745
2745
|
typeof websocket.send_bytes === 'function');
|
|
2746
|
-
logger$
|
|
2746
|
+
logger$1j.debug('websocket_connector_created', {
|
|
2747
2747
|
is_fastapi_like: this._isFastApiLike,
|
|
2748
2748
|
ready_state: websocket.readyState,
|
|
2749
2749
|
url: websocket.url,
|
|
@@ -2758,7 +2758,7 @@ class WebSocketConnector extends BaseAsyncConnector {
|
|
|
2758
2758
|
socketAny.binaryType = 'arraybuffer';
|
|
2759
2759
|
}
|
|
2760
2760
|
catch (error) {
|
|
2761
|
-
logger$
|
|
2761
|
+
logger$1j.debug('websocket_set_binary_type_failed', {
|
|
2762
2762
|
error: error instanceof Error ? error.message : String(error),
|
|
2763
2763
|
current_type: socketAny.binaryType,
|
|
2764
2764
|
});
|
|
@@ -2814,7 +2814,7 @@ class WebSocketConnector extends BaseAsyncConnector {
|
|
|
2814
2814
|
else {
|
|
2815
2815
|
this._receiveQueue.push(data);
|
|
2816
2816
|
}
|
|
2817
|
-
logger$
|
|
2817
|
+
logger$1j.debug('websocket_message_pushed_to_queue', {
|
|
2818
2818
|
queueLength: this._receiveQueue.length,
|
|
2819
2819
|
waitersLength: this._receiveWaiters.length,
|
|
2820
2820
|
});
|
|
@@ -2867,7 +2867,7 @@ class WebSocketConnector extends BaseAsyncConnector {
|
|
|
2867
2867
|
const result = receiveMethod.call(this._websocket);
|
|
2868
2868
|
// Ensure we have a Promise
|
|
2869
2869
|
if (!result || typeof result.then !== 'function') {
|
|
2870
|
-
logger$
|
|
2870
|
+
logger$1j.error('fastapi_receive_not_awaitable', {
|
|
2871
2871
|
result_type: typeof result,
|
|
2872
2872
|
result_str: String(result).substring(0, 100),
|
|
2873
2873
|
});
|
|
@@ -2883,7 +2883,7 @@ class WebSocketConnector extends BaseAsyncConnector {
|
|
|
2883
2883
|
}
|
|
2884
2884
|
// Handle known WebSocket shutdown race condition
|
|
2885
2885
|
if (this._isAwaitFutureError(error)) {
|
|
2886
|
-
logger$
|
|
2886
|
+
logger$1j.debug('websocket_shutdown_race_condition_handled', {
|
|
2887
2887
|
note: 'Normal WebSocket close timing - converting to cancellation',
|
|
2888
2888
|
websocket_state: this._websocket.client_state || 'unknown',
|
|
2889
2889
|
});
|
|
@@ -2926,7 +2926,7 @@ class WebSocketConnector extends BaseAsyncConnector {
|
|
|
2926
2926
|
}
|
|
2927
2927
|
catch (error) {
|
|
2928
2928
|
if (this._isAwaitFutureError(error)) {
|
|
2929
|
-
logger$
|
|
2929
|
+
logger$1j.debug('websocket_shutdown_race_condition_detected', {
|
|
2930
2930
|
websocket_type: this._websocket.constructor.name,
|
|
2931
2931
|
is_fastapi: this._isFastApiLike,
|
|
2932
2932
|
note: 'Normal WebSocket close timing during shutdown',
|
|
@@ -2972,12 +2972,12 @@ class WebSocketConnector extends BaseAsyncConnector {
|
|
|
2972
2972
|
if (socketAny.readyState !== WebSocketState.CLOSED) {
|
|
2973
2973
|
try {
|
|
2974
2974
|
socketAny.terminate();
|
|
2975
|
-
logger$
|
|
2975
|
+
logger$1j.debug('websocket_force_terminated', {
|
|
2976
2976
|
ready_state: socketAny.readyState,
|
|
2977
2977
|
});
|
|
2978
2978
|
}
|
|
2979
2979
|
catch (error) {
|
|
2980
|
-
logger$
|
|
2980
|
+
logger$1j.debug('websocket_force_terminate_failed', {
|
|
2981
2981
|
error: error instanceof Error ? error.message : String(error),
|
|
2982
2982
|
});
|
|
2983
2983
|
}
|
|
@@ -2988,7 +2988,7 @@ class WebSocketConnector extends BaseAsyncConnector {
|
|
|
2988
2988
|
}
|
|
2989
2989
|
}
|
|
2990
2990
|
catch (error) {
|
|
2991
|
-
logger$
|
|
2991
|
+
logger$1j.error('websocket_close_failed', {
|
|
2992
2992
|
error: error instanceof Error ? error.message : String(error),
|
|
2993
2993
|
});
|
|
2994
2994
|
// Don't re-throw - close errors are not critical during shutdown
|
|
@@ -3209,7 +3209,7 @@ class WebSocketConnector extends BaseAsyncConnector {
|
|
|
3209
3209
|
this._removeReceiveHandlers();
|
|
3210
3210
|
}
|
|
3211
3211
|
catch (error) {
|
|
3212
|
-
logger$
|
|
3212
|
+
logger$1j.debug('websocket_remove_handlers_failed', {
|
|
3213
3213
|
error: error instanceof Error ? error.message : String(error),
|
|
3214
3214
|
});
|
|
3215
3215
|
}
|
|
@@ -3263,7 +3263,7 @@ class WebSocketConnector extends BaseAsyncConnector {
|
|
|
3263
3263
|
* Concrete implementations must define supported grant types and provide grant-to-connector
|
|
3264
3264
|
* conversion logic.
|
|
3265
3265
|
*/
|
|
3266
|
-
const logger$
|
|
3266
|
+
const logger$1i = getLogger('naylence.fame.connector.connector_factory');
|
|
3267
3267
|
const CONNECTOR_FACTORY_BASE_TYPE = 'ConnectorFactory';
|
|
3268
3268
|
/**
|
|
3269
3269
|
* Abstract base class for connector factories
|
|
@@ -3299,7 +3299,7 @@ class ConnectorFactory {
|
|
|
3299
3299
|
}
|
|
3300
3300
|
}
|
|
3301
3301
|
catch (error) {
|
|
3302
|
-
logger$
|
|
3302
|
+
logger$1i.warning(`Failed to evaluate grant with factory ${factoryInfo.constructor.name}: ${error}`);
|
|
3303
3303
|
continue;
|
|
3304
3304
|
}
|
|
3305
3305
|
}
|
|
@@ -3342,7 +3342,7 @@ class ConnectorFactory {
|
|
|
3342
3342
|
}
|
|
3343
3343
|
}
|
|
3344
3344
|
catch (error) {
|
|
3345
|
-
logger$
|
|
3345
|
+
logger$1i.warning(`Failed to create connector config from grant: ${error}`);
|
|
3346
3346
|
continue;
|
|
3347
3347
|
}
|
|
3348
3348
|
}
|
|
@@ -3409,20 +3409,20 @@ class ConnectorFactory {
|
|
|
3409
3409
|
return existing;
|
|
3410
3410
|
}
|
|
3411
3411
|
if (existing && !this.isGrantAware(existing)) {
|
|
3412
|
-
logger$
|
|
3412
|
+
logger$1i.warning(`Factory ${factoryInfo.constructor.name} is registered under ${CONNECTOR_FACTORY_BASE_TYPE} but is missing grant conversion APIs; skipping.`);
|
|
3413
3413
|
return null;
|
|
3414
3414
|
}
|
|
3415
3415
|
try {
|
|
3416
3416
|
const instance = new factoryInfo.constructor();
|
|
3417
3417
|
if (!this.isGrantAware(instance)) {
|
|
3418
|
-
logger$
|
|
3418
|
+
logger$1i.warning(`Factory ${factoryInfo.constructor.name} does not implement grant conversion APIs required by ${CONNECTOR_FACTORY_BASE_TYPE}; skipping.`);
|
|
3419
3419
|
return null;
|
|
3420
3420
|
}
|
|
3421
3421
|
factoryInfo.instance = instance;
|
|
3422
3422
|
return instance;
|
|
3423
3423
|
}
|
|
3424
3424
|
catch (error) {
|
|
3425
|
-
logger$
|
|
3425
|
+
logger$1i.warning(`Failed to instantiate factory ${factoryInfo.constructor.name} while resolving grant conversion APIs: ${error}`);
|
|
3426
3426
|
return null;
|
|
3427
3427
|
}
|
|
3428
3428
|
}
|
|
@@ -3581,7 +3581,7 @@ class AuthInjectionStrategyFactory extends factory.AbstractResourceFactory {
|
|
|
3581
3581
|
}
|
|
3582
3582
|
}
|
|
3583
3583
|
|
|
3584
|
-
const logger$
|
|
3584
|
+
const logger$1h = getLogger('naylence.fame.connector.websocket_connector_factory');
|
|
3585
3585
|
let sslLoader = null;
|
|
3586
3586
|
function setWebSocketConnectorSslLoader(loader) {
|
|
3587
3587
|
sslLoader = loader;
|
|
@@ -3592,7 +3592,7 @@ class WebSocketConnectionGrantImpl {
|
|
|
3592
3592
|
this.purpose = 'connection';
|
|
3593
3593
|
}
|
|
3594
3594
|
}
|
|
3595
|
-
const FACTORY_META$
|
|
3595
|
+
const FACTORY_META$1c = {
|
|
3596
3596
|
base: CONNECTOR_FACTORY_BASE_TYPE,
|
|
3597
3597
|
key: 'WebSocketConnector',
|
|
3598
3598
|
};
|
|
@@ -3865,7 +3865,7 @@ class WebSocketConnectorFactory extends ConnectorFactory {
|
|
|
3865
3865
|
}
|
|
3866
3866
|
async _defaultWebSocketClient(url, subprotocols, headers) {
|
|
3867
3867
|
try {
|
|
3868
|
-
logger$
|
|
3868
|
+
logger$1h.debug('websocket_connector_connecting', { url, subprotocols });
|
|
3869
3869
|
if (typeof window !== 'undefined' &&
|
|
3870
3870
|
typeof window.WebSocket !== 'undefined') {
|
|
3871
3871
|
return await this._createBrowserWebSocket(url, subprotocols);
|
|
@@ -3948,7 +3948,7 @@ class WebSocketConnectorFactory extends ConnectorFactory {
|
|
|
3948
3948
|
await Promise.resolve().then(function () { return websocketConnectorNodeSsl; });
|
|
3949
3949
|
}
|
|
3950
3950
|
catch (error) {
|
|
3951
|
-
logger$
|
|
3951
|
+
logger$1h.debug('ssl_certificate_loader_import_failed', {
|
|
3952
3952
|
error: error instanceof Error ? error.message : String(error),
|
|
3953
3953
|
});
|
|
3954
3954
|
}
|
|
@@ -3957,13 +3957,13 @@ class WebSocketConnectorFactory extends ConnectorFactory {
|
|
|
3957
3957
|
if (!loader) {
|
|
3958
3958
|
return undefined;
|
|
3959
3959
|
}
|
|
3960
|
-
return await loader(logger$
|
|
3960
|
+
return await loader(logger$1h);
|
|
3961
3961
|
}
|
|
3962
3962
|
}
|
|
3963
3963
|
|
|
3964
3964
|
var websocketConnectorFactory = /*#__PURE__*/Object.freeze({
|
|
3965
3965
|
__proto__: null,
|
|
3966
|
-
FACTORY_META: FACTORY_META$
|
|
3966
|
+
FACTORY_META: FACTORY_META$1c,
|
|
3967
3967
|
WebSocketConnectorFactory: WebSocketConnectorFactory,
|
|
3968
3968
|
default: WebSocketConnectorFactory,
|
|
3969
3969
|
setWebSocketConnectorSslLoader: setWebSocketConnectorSslLoader
|
|
@@ -4033,6 +4033,7 @@ const MODULES = [
|
|
|
4033
4033
|
"./node/admission/direct-admission-client-factory.js",
|
|
4034
4034
|
"./node/admission/noop-admission-client-factory.js",
|
|
4035
4035
|
"./node/admission/welcome-service-client-factory.js",
|
|
4036
|
+
"./node/default-connection-retry-policy-factory.js",
|
|
4036
4037
|
"./node/default-node-identity-policy-factory.js",
|
|
4037
4038
|
"./node/node-factory.js",
|
|
4038
4039
|
"./node/node-identity-policy-profile-factory.js",
|
|
@@ -4111,6 +4112,7 @@ const MODULE_LOADERS = {
|
|
|
4111
4112
|
"./node/admission/direct-admission-client-factory.js": () => Promise.resolve().then(function () { return directAdmissionClientFactory; }),
|
|
4112
4113
|
"./node/admission/noop-admission-client-factory.js": () => Promise.resolve().then(function () { return noopAdmissionClientFactory; }),
|
|
4113
4114
|
"./node/admission/welcome-service-client-factory.js": () => Promise.resolve().then(function () { return welcomeServiceClientFactory; }),
|
|
4115
|
+
"./node/default-connection-retry-policy-factory.js": () => Promise.resolve().then(function () { return defaultConnectionRetryPolicyFactory; }),
|
|
4114
4116
|
"./node/default-node-identity-policy-factory.js": () => Promise.resolve().then(function () { return defaultNodeIdentityPolicyFactory; }),
|
|
4115
4117
|
"./node/node-factory.js": () => Promise.resolve().then(function () { return nodeFactory; }),
|
|
4116
4118
|
"./node/node-identity-policy-profile-factory.js": () => Promise.resolve().then(function () { return nodeIdentityPolicyProfileFactory; }),
|
|
@@ -4424,12 +4426,12 @@ async function ensureRuntimeFactoriesRegistered(registry = factory.Registry) {
|
|
|
4424
4426
|
}
|
|
4425
4427
|
|
|
4426
4428
|
// This file is auto-generated during build - do not edit manually
|
|
4427
|
-
// Generated from package.json version: 0.3.
|
|
4429
|
+
// Generated from package.json version: 0.3.16
|
|
4428
4430
|
/**
|
|
4429
4431
|
* The package version, injected at build time.
|
|
4430
4432
|
* @internal
|
|
4431
4433
|
*/
|
|
4432
|
-
const VERSION = '0.3.
|
|
4434
|
+
const VERSION = '0.3.16';
|
|
4433
4435
|
|
|
4434
4436
|
let initialized = false;
|
|
4435
4437
|
const runtimePlugin = {
|
|
@@ -4544,7 +4546,7 @@ class EnvCredentialProviderFactory extends CredentialProviderFactory {
|
|
|
4544
4546
|
return new EnvCredentialProvider(resolved.varName);
|
|
4545
4547
|
}
|
|
4546
4548
|
}
|
|
4547
|
-
const FACTORY_META$
|
|
4549
|
+
const FACTORY_META$1b = {
|
|
4548
4550
|
base: CREDENTIAL_PROVIDER_FACTORY_BASE_TYPE,
|
|
4549
4551
|
key: 'EnvCredentialProvider',
|
|
4550
4552
|
};
|
|
@@ -4552,7 +4554,7 @@ const FACTORY_META$1a = {
|
|
|
4552
4554
|
var envCredentialProviderFactory = /*#__PURE__*/Object.freeze({
|
|
4553
4555
|
__proto__: null,
|
|
4554
4556
|
EnvCredentialProviderFactory: EnvCredentialProviderFactory,
|
|
4555
|
-
FACTORY_META: FACTORY_META$
|
|
4557
|
+
FACTORY_META: FACTORY_META$1b,
|
|
4556
4558
|
default: EnvCredentialProviderFactory,
|
|
4557
4559
|
normalizeEnvConfig: normalizeEnvConfig
|
|
4558
4560
|
});
|
|
@@ -4650,14 +4652,14 @@ class PromptCredentialProviderFactory extends CredentialProviderFactory {
|
|
|
4650
4652
|
return new PromptCredentialProvider(resolved.credentialName);
|
|
4651
4653
|
}
|
|
4652
4654
|
}
|
|
4653
|
-
const FACTORY_META$
|
|
4655
|
+
const FACTORY_META$1a = {
|
|
4654
4656
|
base: CREDENTIAL_PROVIDER_FACTORY_BASE_TYPE,
|
|
4655
4657
|
key: 'PromptCredentialProvider',
|
|
4656
4658
|
};
|
|
4657
4659
|
|
|
4658
4660
|
var promptCredentialProviderFactory = /*#__PURE__*/Object.freeze({
|
|
4659
4661
|
__proto__: null,
|
|
4660
|
-
FACTORY_META: FACTORY_META$
|
|
4662
|
+
FACTORY_META: FACTORY_META$1a,
|
|
4661
4663
|
PromptCredentialProviderFactory: PromptCredentialProviderFactory,
|
|
4662
4664
|
default: PromptCredentialProviderFactory,
|
|
4663
4665
|
normalizePromptConfig: normalizePromptConfig
|
|
@@ -4711,14 +4713,14 @@ class SecretStoreCredentialProviderFactory extends CredentialProviderFactory {
|
|
|
4711
4713
|
return new SecretStoreCredentialProvider(resolved.secretName);
|
|
4712
4714
|
}
|
|
4713
4715
|
}
|
|
4714
|
-
const FACTORY_META$
|
|
4716
|
+
const FACTORY_META$19 = {
|
|
4715
4717
|
base: CREDENTIAL_PROVIDER_FACTORY_BASE_TYPE,
|
|
4716
4718
|
key: 'SecretStoreCredentialProvider',
|
|
4717
4719
|
};
|
|
4718
4720
|
|
|
4719
4721
|
var secretStoreCredentialProviderFactory = /*#__PURE__*/Object.freeze({
|
|
4720
4722
|
__proto__: null,
|
|
4721
|
-
FACTORY_META: FACTORY_META$
|
|
4723
|
+
FACTORY_META: FACTORY_META$19,
|
|
4722
4724
|
SecretStoreCredentialProviderFactory: SecretStoreCredentialProviderFactory,
|
|
4723
4725
|
default: SecretStoreCredentialProviderFactory,
|
|
4724
4726
|
normalizeSecretStoreConfig: normalizeSecretStoreConfig
|
|
@@ -4767,14 +4769,14 @@ class StaticCredentialProviderFactory extends CredentialProviderFactory {
|
|
|
4767
4769
|
return new StaticCredentialProvider(resolved.credentialValue);
|
|
4768
4770
|
}
|
|
4769
4771
|
}
|
|
4770
|
-
const FACTORY_META$
|
|
4772
|
+
const FACTORY_META$18 = {
|
|
4771
4773
|
base: CREDENTIAL_PROVIDER_FACTORY_BASE_TYPE,
|
|
4772
4774
|
key: 'StaticCredentialProvider',
|
|
4773
4775
|
};
|
|
4774
4776
|
|
|
4775
4777
|
var staticCredentialProviderFactory = /*#__PURE__*/Object.freeze({
|
|
4776
4778
|
__proto__: null,
|
|
4777
|
-
FACTORY_META: FACTORY_META$
|
|
4779
|
+
FACTORY_META: FACTORY_META$18,
|
|
4778
4780
|
StaticCredentialProviderFactory: StaticCredentialProviderFactory,
|
|
4779
4781
|
default: StaticCredentialProviderFactory,
|
|
4780
4782
|
normalizeStaticConfig: normalizeStaticConfig
|
|
@@ -5636,7 +5638,7 @@ async function withLock(lock, operation) {
|
|
|
5636
5638
|
return await lock.runExclusive(operation);
|
|
5637
5639
|
}
|
|
5638
5640
|
|
|
5639
|
-
const logger$
|
|
5641
|
+
const logger$1g = getLogger('naylence.fame.storage.sqlite_storage_provider');
|
|
5640
5642
|
let cachedSqliteCtor;
|
|
5641
5643
|
async function loadSqliteConstructor() {
|
|
5642
5644
|
if (cachedSqliteCtor !== undefined) {
|
|
@@ -5660,7 +5662,7 @@ async function loadSqliteConstructor() {
|
|
|
5660
5662
|
}
|
|
5661
5663
|
catch (error) {
|
|
5662
5664
|
cachedSqliteCtor = null;
|
|
5663
|
-
logger$
|
|
5665
|
+
logger$1g.error('failed-to-load-better-sqlite3', {
|
|
5664
5666
|
error: error instanceof Error ? error.message : String(error),
|
|
5665
5667
|
});
|
|
5666
5668
|
throw new Error('Failed to load better-sqlite3. Install it to enable SQLite storage support.');
|
|
@@ -5695,7 +5697,7 @@ class SQLiteKeyValueStore {
|
|
|
5695
5697
|
}
|
|
5696
5698
|
catch (error) {
|
|
5697
5699
|
if (this.autoRecover && this.isCorruptionError(error)) {
|
|
5698
|
-
logger$
|
|
5700
|
+
logger$1g.warning('detected-corrupted-db', { path: this.dbPath });
|
|
5699
5701
|
await this.recoverCorruptedDb();
|
|
5700
5702
|
if (!this.db) {
|
|
5701
5703
|
throw new Error('Failed to recover SQLite database');
|
|
@@ -5750,7 +5752,7 @@ class SQLiteKeyValueStore {
|
|
|
5750
5752
|
await this.closeDatabase();
|
|
5751
5753
|
await this.quarantineCorruptedFiles();
|
|
5752
5754
|
await this.openDatabase();
|
|
5753
|
-
logger$
|
|
5755
|
+
logger$1g.warning('quarantined-corrupted-db', { path: this.dbPath });
|
|
5754
5756
|
}
|
|
5755
5757
|
async closeDatabase() {
|
|
5756
5758
|
if (this.db) {
|
|
@@ -5758,7 +5760,7 @@ class SQLiteKeyValueStore {
|
|
|
5758
5760
|
this.db.close();
|
|
5759
5761
|
}
|
|
5760
5762
|
catch (error) {
|
|
5761
|
-
logger$
|
|
5763
|
+
logger$1g.warning('failed-to-close-sqlite-db', {
|
|
5762
5764
|
path: this.dbPath,
|
|
5763
5765
|
error: error instanceof Error ? error.message : String(error),
|
|
5764
5766
|
});
|
|
@@ -5781,7 +5783,7 @@ class SQLiteKeyValueStore {
|
|
|
5781
5783
|
await fsPromises.rename(candidate, quarantinedName);
|
|
5782
5784
|
}
|
|
5783
5785
|
catch (error) {
|
|
5784
|
-
logger$
|
|
5786
|
+
logger$1g.error('failed-to-quarantine-sqlite-file', {
|
|
5785
5787
|
file: candidate,
|
|
5786
5788
|
error: error instanceof Error ? error.message : String(error),
|
|
5787
5789
|
});
|
|
@@ -5882,7 +5884,7 @@ class SQLiteKeyValueStore {
|
|
|
5882
5884
|
result[row.key] = this.deserialize(row.value);
|
|
5883
5885
|
}
|
|
5884
5886
|
catch (error) {
|
|
5885
|
-
logger$
|
|
5887
|
+
logger$1g.warning('skipping-corrupted-sqlite-entry', {
|
|
5886
5888
|
key: row.key,
|
|
5887
5889
|
error: error instanceof Error ? error.message : String(error),
|
|
5888
5890
|
});
|
|
@@ -6877,7 +6879,7 @@ class InMemoryBinding {
|
|
|
6877
6879
|
* TypeScript port of Python's InMemoryFanoutBroker that extends TaskSpawner
|
|
6878
6880
|
* to manage multiple WriteChannel subscribers with concurrent message distribution.
|
|
6879
6881
|
*/
|
|
6880
|
-
const logger$
|
|
6882
|
+
const logger$1f = getLogger('naylence.fame.channel.in_memory.in_memory_fanout_broker');
|
|
6881
6883
|
// Sentinel object for shutdown signaling
|
|
6882
6884
|
const SENTINEL = Symbol('fanout-broker-sentinel');
|
|
6883
6885
|
function isCloseable(obj) {
|
|
@@ -6930,7 +6932,7 @@ class InMemoryFanoutBroker extends TaskSpawner {
|
|
|
6930
6932
|
}
|
|
6931
6933
|
catch (error) {
|
|
6932
6934
|
// Ignore errors when sending sentinel (sink might be closed)
|
|
6933
|
-
logger$
|
|
6935
|
+
logger$1f.debug('error_sending_sentinel', {
|
|
6934
6936
|
error: error.message,
|
|
6935
6937
|
});
|
|
6936
6938
|
}
|
|
@@ -6944,7 +6946,7 @@ class InMemoryFanoutBroker extends TaskSpawner {
|
|
|
6944
6946
|
await sub.close();
|
|
6945
6947
|
}
|
|
6946
6948
|
catch (error) {
|
|
6947
|
-
logger$
|
|
6949
|
+
logger$1f.error('error_closing_subscriber', {
|
|
6948
6950
|
subscriber: sub.toString(),
|
|
6949
6951
|
error: error.message,
|
|
6950
6952
|
});
|
|
@@ -6984,7 +6986,7 @@ class InMemoryFanoutBroker extends TaskSpawner {
|
|
|
6984
6986
|
[envelope, context] = core.extractEnvelopeAndContext(msg);
|
|
6985
6987
|
}
|
|
6986
6988
|
catch (error) {
|
|
6987
|
-
logger$
|
|
6989
|
+
logger$1f.debug('failed_to_extract_envelope', {
|
|
6988
6990
|
error: error.message,
|
|
6989
6991
|
});
|
|
6990
6992
|
continue;
|
|
@@ -7006,7 +7008,7 @@ class InMemoryFanoutBroker extends TaskSpawner {
|
|
|
7006
7008
|
await sub.send(messageToSend);
|
|
7007
7009
|
}
|
|
7008
7010
|
catch (error) {
|
|
7009
|
-
logger$
|
|
7011
|
+
logger$1f.error('error_sending_to_subscriber', {
|
|
7010
7012
|
subscriber: sub.toString(),
|
|
7011
7013
|
error: error.message,
|
|
7012
7014
|
action: 'unsubscribing',
|
|
@@ -7022,7 +7024,7 @@ class InMemoryFanoutBroker extends TaskSpawner {
|
|
|
7022
7024
|
}
|
|
7023
7025
|
catch (error) {
|
|
7024
7026
|
// Critical broker-level error: log and back off, but keep the loop running
|
|
7025
|
-
logger$
|
|
7027
|
+
logger$1f.critical('receive_loop_failed_unexpectedly', {
|
|
7026
7028
|
error: error.message,
|
|
7027
7029
|
stack: error.stack,
|
|
7028
7030
|
});
|
|
@@ -7731,7 +7733,7 @@ function normalizeResponseType(value) {
|
|
|
7731
7733
|
return value;
|
|
7732
7734
|
}
|
|
7733
7735
|
|
|
7734
|
-
const logger$
|
|
7736
|
+
const logger$1e = getLogger('naylence.fame.node.binding_manager');
|
|
7735
7737
|
const SYSTEM_INBOX$3 = '__sys__';
|
|
7736
7738
|
const DEFAULT_ACK_TIMEOUT_MS = 20000;
|
|
7737
7739
|
class BindingStoreEntryRecord {
|
|
@@ -7817,7 +7819,7 @@ class BindingManager {
|
|
|
7817
7819
|
if (!this.bindings.has(key)) {
|
|
7818
7820
|
const binding = this.bindingFactory(new core.FameAddress(key));
|
|
7819
7821
|
this.bindings.set(key, binding);
|
|
7820
|
-
logger$
|
|
7822
|
+
logger$1e.debug('restored_binding', { address: key });
|
|
7821
7823
|
}
|
|
7822
7824
|
}
|
|
7823
7825
|
if (!this.hasUpstream) {
|
|
@@ -7827,13 +7829,13 @@ class BindingManager {
|
|
|
7827
7829
|
await this.readvertiseCapabilitiesUpstream();
|
|
7828
7830
|
}
|
|
7829
7831
|
async bind(participant, capabilities) {
|
|
7830
|
-
logger$
|
|
7832
|
+
logger$1e.debug('binding_participant', { participant });
|
|
7831
7833
|
const { prefixAddress, addresses, propagateAddress, capabilityAddress } = this.computeBindingAddresses(participant);
|
|
7832
7834
|
for (const address of addresses) {
|
|
7833
7835
|
if (!this.bindings.has(address)) {
|
|
7834
7836
|
const binding = this.bindingFactory(new core.FameAddress(address));
|
|
7835
7837
|
this.bindings.set(address, binding);
|
|
7836
|
-
logger$
|
|
7838
|
+
logger$1e.debug('bound_address', { address, participant });
|
|
7837
7839
|
}
|
|
7838
7840
|
}
|
|
7839
7841
|
let propagatedAddress = null;
|
|
@@ -7862,7 +7864,7 @@ class BindingManager {
|
|
|
7862
7864
|
await this.unbindAddressUpstream(propagatedAddress);
|
|
7863
7865
|
}
|
|
7864
7866
|
catch (rollbackError) {
|
|
7865
|
-
logger$
|
|
7867
|
+
logger$1e.error('bind_rollback_failed', {
|
|
7866
7868
|
address: propagatedAddress.toString(),
|
|
7867
7869
|
error: rollbackError.message,
|
|
7868
7870
|
});
|
|
@@ -7881,7 +7883,7 @@ class BindingManager {
|
|
|
7881
7883
|
physicalPath: null,
|
|
7882
7884
|
});
|
|
7883
7885
|
}
|
|
7884
|
-
logger$
|
|
7886
|
+
logger$1e.debug('bind_success', {
|
|
7885
7887
|
participant,
|
|
7886
7888
|
address: prefixAddress.toString(),
|
|
7887
7889
|
capabilities,
|
|
@@ -7917,7 +7919,7 @@ class BindingManager {
|
|
|
7917
7919
|
await this.bindingStore.delete(address);
|
|
7918
7920
|
}
|
|
7919
7921
|
}
|
|
7920
|
-
logger$
|
|
7922
|
+
logger$1e.debug('unbind_success', {
|
|
7921
7923
|
participant,
|
|
7922
7924
|
address: prefixAddress.toString(),
|
|
7923
7925
|
totalBindings: this.bindings.size,
|
|
@@ -7947,7 +7949,7 @@ class BindingManager {
|
|
|
7947
7949
|
await this.bindAddressUpstream(new core.FameAddress(address));
|
|
7948
7950
|
}
|
|
7949
7951
|
catch (error) {
|
|
7950
|
-
logger$
|
|
7952
|
+
logger$1e.error('rebind_failed', {
|
|
7951
7953
|
address,
|
|
7952
7954
|
error: error.message,
|
|
7953
7955
|
});
|
|
@@ -7966,7 +7968,7 @@ class BindingManager {
|
|
|
7966
7968
|
await this.advertiseCapabilities(new core.FameAddress(address), Array.from(capabilities));
|
|
7967
7969
|
}
|
|
7968
7970
|
catch (error) {
|
|
7969
|
-
logger$
|
|
7971
|
+
logger$1e.error('capability_replay_failed', {
|
|
7970
7972
|
address,
|
|
7971
7973
|
error: error.message,
|
|
7972
7974
|
});
|
|
@@ -8233,7 +8235,7 @@ class BindingManager {
|
|
|
8233
8235
|
}
|
|
8234
8236
|
}
|
|
8235
8237
|
|
|
8236
|
-
const logger$
|
|
8238
|
+
const logger$1d = getLogger('naylence.fame.node.response_context_manager');
|
|
8237
8239
|
function cloneSecurityContext(source) {
|
|
8238
8240
|
if (!source) {
|
|
8239
8241
|
return undefined;
|
|
@@ -8261,7 +8263,7 @@ class ResponseContextManager {
|
|
|
8261
8263
|
security: responseSecurity,
|
|
8262
8264
|
expectedResponseType: core.FameResponseType.NONE,
|
|
8263
8265
|
};
|
|
8264
|
-
logger$
|
|
8266
|
+
logger$1d.debug('created_response_context', {
|
|
8265
8267
|
request_id: requestEnvelope.id,
|
|
8266
8268
|
inherited_crypto_level: responseSecurity?.inboundCryptoLevel ?? null,
|
|
8267
8269
|
channel_id: responseSecurity?.cryptoChannelId ?? null,
|
|
@@ -8281,14 +8283,14 @@ class ResponseContextManager {
|
|
|
8281
8283
|
responseContext.fromSystemId = this.getId();
|
|
8282
8284
|
}
|
|
8283
8285
|
// Envelope-level metadata is intentionally omitted to defer to context usage.
|
|
8284
|
-
logger$
|
|
8286
|
+
logger$1d.debug('ensured_response_metadata', {
|
|
8285
8287
|
response_id: responseEnvelope.id,
|
|
8286
8288
|
request_id: requestEnvelope.id,
|
|
8287
8289
|
});
|
|
8288
8290
|
}
|
|
8289
8291
|
}
|
|
8290
8292
|
|
|
8291
|
-
const logger$
|
|
8293
|
+
const logger$1c = getLogger('naylence.fame.node.streaming_response_handler');
|
|
8292
8294
|
function isObject(value) {
|
|
8293
8295
|
return typeof value === 'object' && value !== null;
|
|
8294
8296
|
}
|
|
@@ -8407,12 +8409,12 @@ class StreamingResponseHandler {
|
|
|
8407
8409
|
}
|
|
8408
8410
|
async handleStreamingFameMessageResponses(responses, requestEnvelope, requestContext) {
|
|
8409
8411
|
const asyncResponses = toAsyncIterable(responses);
|
|
8410
|
-
logger$
|
|
8412
|
+
logger$1c.debug('handling_streaming_fame_message_responses', {
|
|
8411
8413
|
request_id: requestEnvelope.id,
|
|
8412
8414
|
});
|
|
8413
8415
|
for await (const response of asyncResponses) {
|
|
8414
8416
|
if (!response?.envelope) {
|
|
8415
|
-
logger$
|
|
8417
|
+
logger$1c.warning('invalid_streaming_response_type', {
|
|
8416
8418
|
request_id: requestEnvelope.id,
|
|
8417
8419
|
actual_type: typeof response,
|
|
8418
8420
|
});
|
|
@@ -8426,7 +8428,7 @@ class StreamingResponseHandler {
|
|
|
8426
8428
|
}
|
|
8427
8429
|
async handleStreamingResponse(result, requestEnvelope, requestContext, replyTo, requestId) {
|
|
8428
8430
|
const iterable = toAsyncIterable(result);
|
|
8429
|
-
logger$
|
|
8431
|
+
logger$1c.debug('handling_streaming_response', {
|
|
8430
8432
|
request_id: requestId,
|
|
8431
8433
|
reply_to: replyTo,
|
|
8432
8434
|
});
|
|
@@ -8437,7 +8439,7 @@ class StreamingResponseHandler {
|
|
|
8437
8439
|
await this.sendRpcResponse(null, requestEnvelope, requestContext, replyTo, requestId);
|
|
8438
8440
|
}
|
|
8439
8441
|
catch (error) {
|
|
8440
|
-
logger$
|
|
8442
|
+
logger$1c.error('streaming_response_handler_error', {
|
|
8441
8443
|
request_id: requestId,
|
|
8442
8444
|
error: error instanceof Error ? error.message : String(error),
|
|
8443
8445
|
});
|
|
@@ -8464,7 +8466,7 @@ class StreamingResponseHandler {
|
|
|
8464
8466
|
});
|
|
8465
8467
|
const responseContext = this.responseContextManager.createResponseContext(requestEnvelope, requestContext);
|
|
8466
8468
|
this.responseContextManager.ensureResponseMetadata(responseEnvelope, requestEnvelope, responseContext);
|
|
8467
|
-
logger$
|
|
8469
|
+
logger$1c.debug('sending_streaming_rpc_response', {
|
|
8468
8470
|
request_id: requestId,
|
|
8469
8471
|
response_envelope_id: responseEnvelope.id,
|
|
8470
8472
|
reply_to: replyTo,
|
|
@@ -8477,7 +8479,7 @@ class StreamingResponseHandler {
|
|
|
8477
8479
|
}
|
|
8478
8480
|
}
|
|
8479
8481
|
|
|
8480
|
-
const logger$
|
|
8482
|
+
const logger$1b = getLogger('naylence.fame.node.channel_polling_manager');
|
|
8481
8483
|
class ChannelPollingManager {
|
|
8482
8484
|
constructor(deliverWrapper, responseContextManager, streamingResponseHandler) {
|
|
8483
8485
|
this.deliverWrapper = deliverWrapper;
|
|
@@ -8485,7 +8487,7 @@ class ChannelPollingManager {
|
|
|
8485
8487
|
this.streamingResponseHandler = streamingResponseHandler;
|
|
8486
8488
|
}
|
|
8487
8489
|
async startPollingLoop(serviceName, channel, handler, stopState, pollTimeoutMs = core.DEFAULT_POLLING_TIMEOUT_MS) {
|
|
8488
|
-
logger$
|
|
8490
|
+
logger$1b.debug('poll_loop_started', {
|
|
8489
8491
|
recipient: serviceName,
|
|
8490
8492
|
});
|
|
8491
8493
|
try {
|
|
@@ -8493,7 +8495,7 @@ class ChannelPollingManager {
|
|
|
8493
8495
|
while (true) {
|
|
8494
8496
|
if (this.isStopRequested(stopState) && !draining) {
|
|
8495
8497
|
draining = true;
|
|
8496
|
-
logger$
|
|
8498
|
+
logger$1b.debug('poll_loop_draining_pending_messages', {
|
|
8497
8499
|
recipient: serviceName,
|
|
8498
8500
|
});
|
|
8499
8501
|
}
|
|
@@ -8503,7 +8505,7 @@ class ChannelPollingManager {
|
|
|
8503
8505
|
}
|
|
8504
8506
|
catch (error) {
|
|
8505
8507
|
if (error instanceof FameTransportClose) {
|
|
8506
|
-
logger$
|
|
8508
|
+
logger$1b.debug('channel_closed', {
|
|
8507
8509
|
recipient: serviceName,
|
|
8508
8510
|
message: error.message,
|
|
8509
8511
|
});
|
|
@@ -8516,7 +8518,7 @@ class ChannelPollingManager {
|
|
|
8516
8518
|
continue;
|
|
8517
8519
|
}
|
|
8518
8520
|
if (error instanceof Error && error.name === 'AbortError') {
|
|
8519
|
-
logger$
|
|
8521
|
+
logger$1b.debug('listener_cancelled', {
|
|
8520
8522
|
recipient: serviceName,
|
|
8521
8523
|
});
|
|
8522
8524
|
throw error;
|
|
@@ -8528,13 +8530,13 @@ class ChannelPollingManager {
|
|
|
8528
8530
|
continue;
|
|
8529
8531
|
}
|
|
8530
8532
|
if (error instanceof Error && error.message === 'Channel is closed') {
|
|
8531
|
-
logger$
|
|
8533
|
+
logger$1b.debug('channel_closed', {
|
|
8532
8534
|
recipient: serviceName,
|
|
8533
8535
|
});
|
|
8534
8536
|
break;
|
|
8535
8537
|
}
|
|
8536
8538
|
if (error instanceof Error && error.name === 'TaskCancelledError') {
|
|
8537
|
-
logger$
|
|
8539
|
+
logger$1b.debug('listener_cancelled', {
|
|
8538
8540
|
recipient: serviceName,
|
|
8539
8541
|
});
|
|
8540
8542
|
throw error;
|
|
@@ -8546,12 +8548,12 @@ class ChannelPollingManager {
|
|
|
8546
8548
|
continue;
|
|
8547
8549
|
}
|
|
8548
8550
|
if (error instanceof Error && error.message.includes('closed')) {
|
|
8549
|
-
logger$
|
|
8551
|
+
logger$1b.debug('channel_closed', {
|
|
8550
8552
|
recipient: serviceName,
|
|
8551
8553
|
});
|
|
8552
8554
|
break;
|
|
8553
8555
|
}
|
|
8554
|
-
logger$
|
|
8556
|
+
logger$1b.error('transport_error', {
|
|
8555
8557
|
recipient: serviceName,
|
|
8556
8558
|
error: error instanceof Error ? error.message : String(error),
|
|
8557
8559
|
});
|
|
@@ -8567,7 +8569,7 @@ class ChannelPollingManager {
|
|
|
8567
8569
|
}
|
|
8568
8570
|
}
|
|
8569
8571
|
finally {
|
|
8570
|
-
logger$
|
|
8572
|
+
logger$1b.debug('poll_loop_exiting', {
|
|
8571
8573
|
recipient: serviceName,
|
|
8572
8574
|
});
|
|
8573
8575
|
}
|
|
@@ -8580,7 +8582,7 @@ class ChannelPollingManager {
|
|
|
8580
8582
|
await this.processHandlerResult(result, envelope, deliveryContext, serviceName);
|
|
8581
8583
|
}
|
|
8582
8584
|
catch (error) {
|
|
8583
|
-
logger$
|
|
8585
|
+
logger$1b.error('handler_crashed', {
|
|
8584
8586
|
recipient: serviceName,
|
|
8585
8587
|
error: error instanceof Error ? error.message : String(error),
|
|
8586
8588
|
});
|
|
@@ -8594,7 +8596,7 @@ class ChannelPollingManager {
|
|
|
8594
8596
|
return;
|
|
8595
8597
|
}
|
|
8596
8598
|
if (this.streamingResponseHandler.isStreamingFameMessageResponse(result)) {
|
|
8597
|
-
logger$
|
|
8599
|
+
logger$1b.debug('handling_streaming_fame_message_responses', {
|
|
8598
8600
|
service_name: serviceName,
|
|
8599
8601
|
envelope_id: envelope.id,
|
|
8600
8602
|
});
|
|
@@ -8602,7 +8604,7 @@ class ChannelPollingManager {
|
|
|
8602
8604
|
}
|
|
8603
8605
|
}
|
|
8604
8606
|
async handleMessageResponse(response, requestEnvelope, requestContext, serviceName) {
|
|
8605
|
-
logger$
|
|
8607
|
+
logger$1b.debug('delivering_envelope_response_message', {
|
|
8606
8608
|
service_name: serviceName,
|
|
8607
8609
|
response_envelope_id: response.envelope.id,
|
|
8608
8610
|
});
|
|
@@ -8622,7 +8624,7 @@ class ChannelPollingManager {
|
|
|
8622
8624
|
}
|
|
8623
8625
|
}
|
|
8624
8626
|
|
|
8625
|
-
const logger$
|
|
8627
|
+
const logger$1a = getLogger('naylence.fame.node.rpc_server_handler');
|
|
8626
8628
|
function isPlainRecord$6(value) {
|
|
8627
8629
|
if (typeof value !== 'object' || value === null) {
|
|
8628
8630
|
return false;
|
|
@@ -8666,13 +8668,13 @@ class RPCServerHandler {
|
|
|
8666
8668
|
}
|
|
8667
8669
|
async handleRpcRequest(envelope, handlerContext, handler, serviceName) {
|
|
8668
8670
|
if (!this.isDataFrame(envelope.frame)) {
|
|
8669
|
-
logger$
|
|
8671
|
+
logger$1a.warning('rpc_request_missing_data_frame', {
|
|
8670
8672
|
service_name: serviceName,
|
|
8671
8673
|
envelope_id: envelope.id,
|
|
8672
8674
|
});
|
|
8673
8675
|
return;
|
|
8674
8676
|
}
|
|
8675
|
-
logger$
|
|
8677
|
+
logger$1a.debug('rpc_request_received', {
|
|
8676
8678
|
service_name: serviceName,
|
|
8677
8679
|
envelope_id: envelope.id,
|
|
8678
8680
|
trace_id: envelope.traceId,
|
|
@@ -8684,7 +8686,7 @@ class RPCServerHandler {
|
|
|
8684
8686
|
request = core.parseRequest(envelope.frame.payload);
|
|
8685
8687
|
params = cloneParams(request.params);
|
|
8686
8688
|
const paramKeys = Object.keys(params);
|
|
8687
|
-
logger$
|
|
8689
|
+
logger$1a.debug('parsed_rpc_request', {
|
|
8688
8690
|
service_name: serviceName,
|
|
8689
8691
|
method: request.method,
|
|
8690
8692
|
request_id: request.id,
|
|
@@ -8693,7 +8695,7 @@ class RPCServerHandler {
|
|
|
8693
8695
|
});
|
|
8694
8696
|
}
|
|
8695
8697
|
catch (error) {
|
|
8696
|
-
logger$
|
|
8698
|
+
logger$1a.warning('request_decode_error', {
|
|
8697
8699
|
service_name: serviceName,
|
|
8698
8700
|
envelope_id: envelope.id,
|
|
8699
8701
|
error: error instanceof Error ? error.message : String(error),
|
|
@@ -8701,7 +8703,7 @@ class RPCServerHandler {
|
|
|
8701
8703
|
return;
|
|
8702
8704
|
}
|
|
8703
8705
|
if (request.id == null) {
|
|
8704
|
-
logger$
|
|
8706
|
+
logger$1a.warning('request_missing_id', {
|
|
8705
8707
|
service_name: serviceName,
|
|
8706
8708
|
envelope_id: envelope.id,
|
|
8707
8709
|
});
|
|
@@ -8709,7 +8711,7 @@ class RPCServerHandler {
|
|
|
8709
8711
|
}
|
|
8710
8712
|
const replyTo = this.resolveReplyTo(envelope, params);
|
|
8711
8713
|
if (!replyTo) {
|
|
8712
|
-
logger$
|
|
8714
|
+
logger$1a.warning('missing_reply_to', {
|
|
8713
8715
|
service_name: serviceName,
|
|
8714
8716
|
envelope_id: envelope.id,
|
|
8715
8717
|
request_id: request.id,
|
|
@@ -8718,13 +8720,13 @@ class RPCServerHandler {
|
|
|
8718
8720
|
}
|
|
8719
8721
|
let handlerResult;
|
|
8720
8722
|
try {
|
|
8721
|
-
logger$
|
|
8723
|
+
logger$1a.debug('calling_rpc_handler', {
|
|
8722
8724
|
service_name: serviceName,
|
|
8723
8725
|
method: request.method,
|
|
8724
8726
|
request_id: request.id,
|
|
8725
8727
|
});
|
|
8726
8728
|
handlerResult = await handler(request.method, params);
|
|
8727
|
-
logger$
|
|
8729
|
+
logger$1a.debug('rpc_handler_returned', {
|
|
8728
8730
|
service_name: serviceName,
|
|
8729
8731
|
method: request.method,
|
|
8730
8732
|
request_id: request.id,
|
|
@@ -8733,7 +8735,7 @@ class RPCServerHandler {
|
|
|
8733
8735
|
});
|
|
8734
8736
|
}
|
|
8735
8737
|
catch (error) {
|
|
8736
|
-
logger$
|
|
8738
|
+
logger$1a.error('rpc_handler_error', {
|
|
8737
8739
|
service_name: serviceName,
|
|
8738
8740
|
request_id: request.id,
|
|
8739
8741
|
envelope_id: envelope.id,
|
|
@@ -8743,7 +8745,7 @@ class RPCServerHandler {
|
|
|
8743
8745
|
return this.createTraditionalResponse(response, request.id, envelope, replyTo, handlerContext, serviceName);
|
|
8744
8746
|
}
|
|
8745
8747
|
if (core.isFameMessageResponse(handlerResult)) {
|
|
8746
|
-
logger$
|
|
8748
|
+
logger$1a.debug('returning_response_message', {
|
|
8747
8749
|
service_name: serviceName,
|
|
8748
8750
|
request_id: request.id,
|
|
8749
8751
|
response_envelope_id: handlerResult.envelope.id,
|
|
@@ -8751,7 +8753,7 @@ class RPCServerHandler {
|
|
|
8751
8753
|
return handlerResult;
|
|
8752
8754
|
}
|
|
8753
8755
|
if (this.streamingResponseHandler.isStreamingResult(handlerResult)) {
|
|
8754
|
-
logger$
|
|
8756
|
+
logger$1a.debug('handling_streaming_response', {
|
|
8755
8757
|
service_name: serviceName,
|
|
8756
8758
|
request_id: request.id,
|
|
8757
8759
|
envelope_id: envelope.id,
|
|
@@ -8780,7 +8782,7 @@ class RPCServerHandler {
|
|
|
8780
8782
|
return null;
|
|
8781
8783
|
}
|
|
8782
8784
|
async createTraditionalResponse(payload, requestId, requestEnvelope, replyTo, handlerContext, serviceName) {
|
|
8783
|
-
logger$
|
|
8785
|
+
logger$1a.debug('creating_traditional_response_envelope', {
|
|
8784
8786
|
service_name: serviceName,
|
|
8785
8787
|
request_id: requestId,
|
|
8786
8788
|
envelope_id: requestEnvelope.id,
|
|
@@ -8804,7 +8806,7 @@ class RPCServerHandler {
|
|
|
8804
8806
|
if (requestEnvelope.id) {
|
|
8805
8807
|
responseContext.meta['response-to-id'] = requestEnvelope.id;
|
|
8806
8808
|
}
|
|
8807
|
-
logger$
|
|
8809
|
+
logger$1a.debug('returning_traditional_response', {
|
|
8808
8810
|
service_name: serviceName,
|
|
8809
8811
|
request_id: requestId,
|
|
8810
8812
|
envelope_id: requestEnvelope.id,
|
|
@@ -8869,7 +8871,7 @@ function normalizeErrorCode(code) {
|
|
|
8869
8871
|
return code;
|
|
8870
8872
|
}
|
|
8871
8873
|
|
|
8872
|
-
const logger$
|
|
8874
|
+
const logger$19 = getLogger('naylence.fame.node.rpc_client_manager');
|
|
8873
8875
|
function isPlainRecord$5(value) {
|
|
8874
8876
|
if (typeof value !== 'object' || value === null) {
|
|
8875
8877
|
return false;
|
|
@@ -9086,7 +9088,7 @@ class RPCClientManager {
|
|
|
9086
9088
|
const metaReason = tracked.meta?.['nack_reason'];
|
|
9087
9089
|
const formattedMessage = formatDeliveryErrorMessage(typeof metaCode === 'string' ? metaCode : 'DELIVERY_ERROR', reason ??
|
|
9088
9090
|
(typeof metaReason === 'string' ? metaReason : undefined));
|
|
9089
|
-
logger$
|
|
9091
|
+
logger$19.debug('pending_request_rejected_by_delivery_nack', {
|
|
9090
9092
|
envelope_id: envelopeId,
|
|
9091
9093
|
request_id: requestId,
|
|
9092
9094
|
code: typeof metaCode === 'string' ? metaCode : 'DELIVERY_ERROR',
|
|
@@ -9109,7 +9111,7 @@ class RPCClientManager {
|
|
|
9109
9111
|
this.trackerWithEvents.removeEventHandler?.(this.trackerEventHandler);
|
|
9110
9112
|
}
|
|
9111
9113
|
catch (error) {
|
|
9112
|
-
logger$
|
|
9114
|
+
logger$19.debug('rpc_tracker_handler_remove_failed', {
|
|
9113
9115
|
error: error instanceof Error ? error.message : String(error),
|
|
9114
9116
|
});
|
|
9115
9117
|
}
|
|
@@ -9152,7 +9154,7 @@ class RPCClientManager {
|
|
|
9152
9154
|
this.rpcListenerAddress = await this.listenCallback(recipient, handler);
|
|
9153
9155
|
this.rpcBound = true;
|
|
9154
9156
|
this.boundPhysicalPath = currentPhysicalPath;
|
|
9155
|
-
logger$
|
|
9157
|
+
logger$19.debug('rpc_reply_listener_bound', {
|
|
9156
9158
|
reply_recipient: recipient,
|
|
9157
9159
|
reply_address: this.rpcReplyAddress?.toString(),
|
|
9158
9160
|
listener_address: this.rpcListenerAddress?.toString(),
|
|
@@ -9246,7 +9248,7 @@ class RPCClientManager {
|
|
|
9246
9248
|
const finalizePromise = this.notifyStreamClosed(envelopeId);
|
|
9247
9249
|
if (finalizePromise) {
|
|
9248
9250
|
finalizePromise.catch((notifyError) => {
|
|
9249
|
-
logger$
|
|
9251
|
+
logger$19.debug('stream_tracker_finalize_failed', {
|
|
9250
9252
|
request_id: requestId,
|
|
9251
9253
|
envelope_id: envelopeId,
|
|
9252
9254
|
error: notifyError instanceof Error
|
|
@@ -9307,7 +9309,7 @@ class RPCClientManager {
|
|
|
9307
9309
|
return iterator;
|
|
9308
9310
|
}
|
|
9309
9311
|
async sendRpcRequest(requestId, envelope, expectedResponseType, timeoutMs) {
|
|
9310
|
-
logger$
|
|
9312
|
+
logger$19.debug('sending_rpc_request', {
|
|
9311
9313
|
envp_id: envelope.id,
|
|
9312
9314
|
corr_id: envelope.corrId,
|
|
9313
9315
|
request_id: requestId,
|
|
@@ -9323,7 +9325,7 @@ class RPCClientManager {
|
|
|
9323
9325
|
}
|
|
9324
9326
|
}
|
|
9325
9327
|
catch (error) {
|
|
9326
|
-
logger$
|
|
9328
|
+
logger$19.warning('delivery_tracker_track_failed', {
|
|
9327
9329
|
request_id: requestId,
|
|
9328
9330
|
error: error instanceof Error ? error.message : String(error),
|
|
9329
9331
|
});
|
|
@@ -9336,14 +9338,14 @@ class RPCClientManager {
|
|
|
9336
9338
|
await this.deliverWrapper()(envelope, context);
|
|
9337
9339
|
}
|
|
9338
9340
|
async handleReplyEnvelope(envelope) {
|
|
9339
|
-
logger$
|
|
9341
|
+
logger$19.debug('handle_reply_envelope_received', {
|
|
9340
9342
|
envelope_id: envelope.id,
|
|
9341
9343
|
corr_id: envelope.corrId,
|
|
9342
9344
|
frame_type: envelope.frame?.['type'],
|
|
9343
9345
|
});
|
|
9344
9346
|
let requestId = envelope.corrId ?? envelope.id;
|
|
9345
9347
|
if (!requestId) {
|
|
9346
|
-
logger$
|
|
9348
|
+
logger$19.warning('reply_envelope_missing_corr_id', {
|
|
9347
9349
|
envelope_id: envelope.id,
|
|
9348
9350
|
});
|
|
9349
9351
|
return;
|
|
@@ -9361,12 +9363,12 @@ class RPCClientManager {
|
|
|
9361
9363
|
}
|
|
9362
9364
|
}
|
|
9363
9365
|
if (!entry) {
|
|
9364
|
-
logger$
|
|
9366
|
+
logger$19.debug('no_pending_request_for_reply', {
|
|
9365
9367
|
request_id: requestId,
|
|
9366
9368
|
});
|
|
9367
9369
|
return;
|
|
9368
9370
|
}
|
|
9369
|
-
logger$
|
|
9371
|
+
logger$19.debug('handle_reply_envelope', {
|
|
9370
9372
|
envelope_id: envelope.id,
|
|
9371
9373
|
request_id: requestId,
|
|
9372
9374
|
corr_id: envelope.corrId,
|
|
@@ -9379,7 +9381,7 @@ class RPCClientManager {
|
|
|
9379
9381
|
const ackIndicatesSuccess = frame.ok === true ||
|
|
9380
9382
|
(frame.ok === undefined && !frame.code && !frame.reason);
|
|
9381
9383
|
if (ackIndicatesSuccess) {
|
|
9382
|
-
logger$
|
|
9384
|
+
logger$19.debug('pending_request_delivery_acknowledged', {
|
|
9383
9385
|
request_id: requestId,
|
|
9384
9386
|
envelope_id: envelope.id,
|
|
9385
9387
|
ref_id: frame.refId ?? null,
|
|
@@ -9407,7 +9409,7 @@ class RPCClientManager {
|
|
|
9407
9409
|
entry.timer = null;
|
|
9408
9410
|
}
|
|
9409
9411
|
if (!this.isDataFrame(envelope.frame)) {
|
|
9410
|
-
logger$
|
|
9412
|
+
logger$19.warning('unexpected_reply_frame_type', {
|
|
9411
9413
|
request_id: requestId,
|
|
9412
9414
|
frame_type: envelope.frame?.['type'],
|
|
9413
9415
|
});
|
|
@@ -9473,7 +9475,7 @@ class RPCClientManager {
|
|
|
9473
9475
|
return;
|
|
9474
9476
|
}
|
|
9475
9477
|
Promise.resolve(this.deliveryTracker.onStreamItem(envelopeId, envelope)).catch((error) => {
|
|
9476
|
-
logger$
|
|
9478
|
+
logger$19.debug('stream_tracker_push_failed', {
|
|
9477
9479
|
envelope_id: envelopeId,
|
|
9478
9480
|
error: error instanceof Error ? error.message : String(error),
|
|
9479
9481
|
});
|
|
@@ -9588,7 +9590,7 @@ function normalizeMailbox(mailbox) {
|
|
|
9588
9590
|
return mailbox;
|
|
9589
9591
|
}
|
|
9590
9592
|
|
|
9591
|
-
const logger$
|
|
9593
|
+
const logger$18 = getLogger('naylence.fame.node.envelope_listener_manager');
|
|
9592
9594
|
const SYSTEM_INBOX$2 = '__sys__';
|
|
9593
9595
|
class EnvelopeListener {
|
|
9594
9596
|
constructor(stopFn, task) {
|
|
@@ -9596,7 +9598,7 @@ class EnvelopeListener {
|
|
|
9596
9598
|
this.task = task;
|
|
9597
9599
|
}
|
|
9598
9600
|
stop() {
|
|
9599
|
-
logger$
|
|
9601
|
+
logger$18.debug('stopping_listener', {
|
|
9600
9602
|
task_name: this.task.name,
|
|
9601
9603
|
});
|
|
9602
9604
|
try {
|
|
@@ -9604,7 +9606,7 @@ class EnvelopeListener {
|
|
|
9604
9606
|
if (maybeCleanup &&
|
|
9605
9607
|
typeof maybeCleanup.then === 'function') {
|
|
9606
9608
|
void maybeCleanup.catch((error) => {
|
|
9607
|
-
logger$
|
|
9609
|
+
logger$18.debug('listener_stop_cleanup_failed', {
|
|
9608
9610
|
task_name: this.task.name,
|
|
9609
9611
|
error: error instanceof Error ? error.message : String(error),
|
|
9610
9612
|
});
|
|
@@ -9612,7 +9614,7 @@ class EnvelopeListener {
|
|
|
9612
9614
|
}
|
|
9613
9615
|
}
|
|
9614
9616
|
catch (error) {
|
|
9615
|
-
logger$
|
|
9617
|
+
logger$18.debug('listener_stop_cleanup_failed', {
|
|
9616
9618
|
task_name: this.task.name,
|
|
9617
9619
|
error: error instanceof Error ? error.message : String(error),
|
|
9618
9620
|
});
|
|
@@ -9642,7 +9644,7 @@ class EnvelopeListenerManager extends TaskSpawner {
|
|
|
9642
9644
|
envelope.replyTo = core.formatAddress(SYSTEM_INBOX$2, this.nodeLike.physicalPath);
|
|
9643
9645
|
}
|
|
9644
9646
|
catch (error) {
|
|
9645
|
-
logger$
|
|
9647
|
+
logger$18.warning('default_reply_to_assignment_failed', {
|
|
9646
9648
|
envelope_id: envelope.id,
|
|
9647
9649
|
service_name: envelope.capabilities?.[0] ?? null,
|
|
9648
9650
|
error: error instanceof Error ? error.message : String(error),
|
|
@@ -9667,7 +9669,7 @@ class EnvelopeListenerManager extends TaskSpawner {
|
|
|
9667
9669
|
if (serviceName === SYSTEM_INBOX$2) {
|
|
9668
9670
|
continue;
|
|
9669
9671
|
}
|
|
9670
|
-
logger$
|
|
9672
|
+
logger$18.debug('stopping_listener_for_service', {
|
|
9671
9673
|
service_name: serviceName,
|
|
9672
9674
|
});
|
|
9673
9675
|
entry.listener.stop();
|
|
@@ -9677,7 +9679,7 @@ class EnvelopeListenerManager extends TaskSpawner {
|
|
|
9677
9679
|
catch (error) {
|
|
9678
9680
|
if (!(error instanceof Error) ||
|
|
9679
9681
|
error.name !== 'TaskCancelledError') {
|
|
9680
|
-
logger$
|
|
9682
|
+
logger$18.debug('listener_task_stopped', {
|
|
9681
9683
|
service_name: serviceName,
|
|
9682
9684
|
error: error instanceof Error ? error.message : String(error),
|
|
9683
9685
|
});
|
|
@@ -9685,7 +9687,7 @@ class EnvelopeListenerManager extends TaskSpawner {
|
|
|
9685
9687
|
}
|
|
9686
9688
|
}
|
|
9687
9689
|
if (systemEntry) {
|
|
9688
|
-
logger$
|
|
9690
|
+
logger$18.debug('stopping_listener_for_service', {
|
|
9689
9691
|
service_name: SYSTEM_INBOX$2,
|
|
9690
9692
|
});
|
|
9691
9693
|
systemEntry.listener.stop();
|
|
@@ -9695,7 +9697,7 @@ class EnvelopeListenerManager extends TaskSpawner {
|
|
|
9695
9697
|
catch (error) {
|
|
9696
9698
|
if (!(error instanceof Error) ||
|
|
9697
9699
|
error.name !== 'TaskCancelledError') {
|
|
9698
|
-
logger$
|
|
9700
|
+
logger$18.debug('listener_task_stopped', {
|
|
9699
9701
|
service_name: SYSTEM_INBOX$2,
|
|
9700
9702
|
error: error instanceof Error ? error.message : String(error),
|
|
9701
9703
|
});
|
|
@@ -9712,13 +9714,13 @@ class EnvelopeListenerManager extends TaskSpawner {
|
|
|
9712
9714
|
}
|
|
9713
9715
|
async recoverUnhandledInboundEnvelopes() {
|
|
9714
9716
|
if (typeof this.deliveryTracker.listInbound !== 'function') {
|
|
9715
|
-
logger$
|
|
9717
|
+
logger$18.debug('delivery_tracker_missing_inbound_listing');
|
|
9716
9718
|
return;
|
|
9717
9719
|
}
|
|
9718
9720
|
const failedInbound = await this.deliveryTracker.listInbound((env) => env.status === EnvelopeStatus.RECEIVED ||
|
|
9719
9721
|
env.status === EnvelopeStatus.FAILED_TO_HANDLE);
|
|
9720
9722
|
if (!failedInbound.length) {
|
|
9721
|
-
logger$
|
|
9723
|
+
logger$18.debug('no_failed_inbound_envelopes_to_recover');
|
|
9722
9724
|
return;
|
|
9723
9725
|
}
|
|
9724
9726
|
const grouped = new Map();
|
|
@@ -9735,7 +9737,7 @@ class EnvelopeListenerManager extends TaskSpawner {
|
|
|
9735
9737
|
this.pendingRecoveryEnvelopes.set(serviceName, envelopes);
|
|
9736
9738
|
}
|
|
9737
9739
|
});
|
|
9738
|
-
logger$
|
|
9740
|
+
logger$18.debug('discovered_failed_inbound_envelopes', {
|
|
9739
9741
|
total: failedInbound.length,
|
|
9740
9742
|
services: Array.from(grouped.keys()),
|
|
9741
9743
|
});
|
|
@@ -9745,7 +9747,7 @@ class EnvelopeListenerManager extends TaskSpawner {
|
|
|
9745
9747
|
const pollTimeoutMs = options.pollTimeoutMs ??
|
|
9746
9748
|
options.poll_timeout_ms ??
|
|
9747
9749
|
core.DEFAULT_POLLING_TIMEOUT_MS;
|
|
9748
|
-
logger$
|
|
9750
|
+
logger$18.debug('listen_start', {
|
|
9749
9751
|
recipient: serviceName,
|
|
9750
9752
|
poll_timeout_ms: pollTimeoutMs ?? core.DEFAULT_POLLING_TIMEOUT_MS,
|
|
9751
9753
|
});
|
|
@@ -9776,7 +9778,7 @@ class EnvelopeListenerManager extends TaskSpawner {
|
|
|
9776
9778
|
tracked?.mailboxType === MailboxType.OUTBOX ||
|
|
9777
9779
|
envelope.frame?.['type'] === 'DeliveryAck';
|
|
9778
9780
|
if (!shouldInvoke) {
|
|
9779
|
-
logger$
|
|
9781
|
+
logger$18.debug('skipping_listener_handler', {
|
|
9780
9782
|
recipient: serviceName,
|
|
9781
9783
|
envelope_id: envelope.id,
|
|
9782
9784
|
tracked_status: tracked?.status,
|
|
@@ -9790,13 +9792,13 @@ class EnvelopeListenerManager extends TaskSpawner {
|
|
|
9790
9792
|
? undefined
|
|
9791
9793
|
: (tracked ?? undefined);
|
|
9792
9794
|
if (trackedForHandler && trackedForHandler.attempt > 0) {
|
|
9793
|
-
logger$
|
|
9795
|
+
logger$18.info('resuming_handler_retry_after_restart', {
|
|
9794
9796
|
envelope_id: envelope.id,
|
|
9795
9797
|
current_attempts: trackedForHandler.attempt,
|
|
9796
9798
|
service_name: serviceName,
|
|
9797
9799
|
});
|
|
9798
9800
|
}
|
|
9799
|
-
logger$
|
|
9801
|
+
logger$18.debug('forwarding_to_listener_handler', {
|
|
9800
9802
|
recipient: serviceName,
|
|
9801
9803
|
envelope_id: envelope.id,
|
|
9802
9804
|
frame_type: envelope.frame?.['type'],
|
|
@@ -9815,7 +9817,7 @@ class EnvelopeListenerManager extends TaskSpawner {
|
|
|
9815
9817
|
await channel.send(null);
|
|
9816
9818
|
}
|
|
9817
9819
|
catch (error) {
|
|
9818
|
-
logger$
|
|
9820
|
+
logger$18.debug('listener_stop_signal_failed', {
|
|
9819
9821
|
service_name: serviceName,
|
|
9820
9822
|
error: error instanceof Error ? error.message : String(error),
|
|
9821
9823
|
});
|
|
@@ -9824,7 +9826,7 @@ class EnvelopeListenerManager extends TaskSpawner {
|
|
|
9824
9826
|
await this.listenersLock.runExclusive(async () => {
|
|
9825
9827
|
const existing = this.listeners.get(serviceName);
|
|
9826
9828
|
if (existing) {
|
|
9827
|
-
logger$
|
|
9829
|
+
logger$18.debug('replacing_envelope_listener', { recipient: serviceName });
|
|
9828
9830
|
existing.listener.stop();
|
|
9829
9831
|
try {
|
|
9830
9832
|
await existing.listener.task.promise;
|
|
@@ -9842,13 +9844,13 @@ class EnvelopeListenerManager extends TaskSpawner {
|
|
|
9842
9844
|
return binding.address;
|
|
9843
9845
|
}
|
|
9844
9846
|
async listenRpc(serviceName, handler, options = {}) {
|
|
9845
|
-
logger$
|
|
9847
|
+
logger$18.debug('rpc_listen_start', { service_name: serviceName });
|
|
9846
9848
|
const rpcHandler = async (envelope, context) => {
|
|
9847
9849
|
const result = await this.rpcServerHandler.handleRpcRequest(envelope, context, handler, serviceName);
|
|
9848
9850
|
return result ?? null;
|
|
9849
9851
|
};
|
|
9850
9852
|
const address = await this.listen(serviceName, rpcHandler, options);
|
|
9851
|
-
logger$
|
|
9853
|
+
logger$18.debug('rpc_listen_bound', {
|
|
9852
9854
|
service_name: serviceName,
|
|
9853
9855
|
address: address.toString(),
|
|
9854
9856
|
});
|
|
@@ -9917,12 +9919,12 @@ class EnvelopeListenerManager extends TaskSpawner {
|
|
|
9917
9919
|
return cached;
|
|
9918
9920
|
});
|
|
9919
9921
|
if (!envelopes.length) {
|
|
9920
|
-
logger$
|
|
9922
|
+
logger$18.debug('no_cached_recovery_for_service', {
|
|
9921
9923
|
service_name: serviceName,
|
|
9922
9924
|
});
|
|
9923
9925
|
return;
|
|
9924
9926
|
}
|
|
9925
|
-
logger$
|
|
9927
|
+
logger$18.debug('recovering_unhandled_envelopes_on_listen', {
|
|
9926
9928
|
service_name: serviceName,
|
|
9927
9929
|
count: envelopes.length,
|
|
9928
9930
|
envelope_ids: envelopes.map((trackedEnvelope) => trackedEnvelope.envelopeId),
|
|
@@ -9933,7 +9935,7 @@ class EnvelopeListenerManager extends TaskSpawner {
|
|
|
9933
9935
|
async recoverServiceEnvelopes(serviceName, envelopes, handler) {
|
|
9934
9936
|
for (const tracked of envelopes) {
|
|
9935
9937
|
try {
|
|
9936
|
-
logger$
|
|
9938
|
+
logger$18.warning('recovering_unhandled_envelope', {
|
|
9937
9939
|
envelope_id: tracked.envelopeId,
|
|
9938
9940
|
service_name: serviceName,
|
|
9939
9941
|
current_attempts: tracked.attempt,
|
|
@@ -9942,13 +9944,13 @@ class EnvelopeListenerManager extends TaskSpawner {
|
|
|
9942
9944
|
const originalEnvelope = tracked.originalEnvelope;
|
|
9943
9945
|
const receiverPolicy = this.nodeLike.deliveryPolicy?.receiverRetryPolicy ?? undefined;
|
|
9944
9946
|
await this.executeHandlerWithRetries(handler, originalEnvelope, undefined, receiverPolicy, tracked, serviceName);
|
|
9945
|
-
logger$
|
|
9947
|
+
logger$18.debug('envelope_recovery_completed', {
|
|
9946
9948
|
envelope_id: tracked.envelopeId,
|
|
9947
9949
|
service_name: serviceName,
|
|
9948
9950
|
});
|
|
9949
9951
|
}
|
|
9950
9952
|
catch (error) {
|
|
9951
|
-
logger$
|
|
9953
|
+
logger$18.error('envelope_recovery_failed', {
|
|
9952
9954
|
envelope_id: tracked.envelopeId,
|
|
9953
9955
|
service_name: serviceName,
|
|
9954
9956
|
error: error instanceof Error ? error.message : String(error),
|
|
@@ -9994,7 +9996,7 @@ class EnvelopeListenerManager extends TaskSpawner {
|
|
|
9994
9996
|
await this.deliveryTracker.onEnvelopeHandled(trackedEnvelope);
|
|
9995
9997
|
}
|
|
9996
9998
|
if (currentAttempt > 0) {
|
|
9997
|
-
logger$
|
|
9999
|
+
logger$18.info('handler_retry_succeeded', {
|
|
9998
10000
|
envelope_id: envelope.id,
|
|
9999
10001
|
attempt: currentAttempt + 1,
|
|
10000
10002
|
total_attempts: currentAttempt + 1,
|
|
@@ -10010,7 +10012,7 @@ class EnvelopeListenerManager extends TaskSpawner {
|
|
|
10010
10012
|
await this.deliveryTracker.onEnvelopeHandleFailed(inboxName, trackedEnvelope, context, error instanceof Error ? error : new Error(String(error)), isFinalAttempt);
|
|
10011
10013
|
}
|
|
10012
10014
|
if (isFinalAttempt) {
|
|
10013
|
-
logger$
|
|
10015
|
+
logger$18.error('handler_execution_failed_exhausted_retries', {
|
|
10014
10016
|
envelope_id: envelope.id,
|
|
10015
10017
|
total_attempts: attemptNumber,
|
|
10016
10018
|
max_retries: retryPolicy?.maxRetries ?? 0,
|
|
@@ -10019,7 +10021,7 @@ class EnvelopeListenerManager extends TaskSpawner {
|
|
|
10019
10021
|
break;
|
|
10020
10022
|
}
|
|
10021
10023
|
const delayMs = retryPolicy?.nextDelayMs(attemptNumber) ?? 0;
|
|
10022
|
-
logger$
|
|
10024
|
+
logger$18.warning('handler_execution_failed_will_retry', {
|
|
10023
10025
|
envelope_id: envelope.id,
|
|
10024
10026
|
attempt: attemptNumber,
|
|
10025
10027
|
max_retries: retryPolicy?.maxRetries ?? 0,
|
|
@@ -10049,7 +10051,7 @@ class EnvelopeListenerManager extends TaskSpawner {
|
|
|
10049
10051
|
}
|
|
10050
10052
|
}
|
|
10051
10053
|
|
|
10052
|
-
const logger$
|
|
10054
|
+
const logger$17 = getLogger('naylence.fame.delivery.default_delivery_tracker');
|
|
10053
10055
|
const STREAM_END = Symbol('stream-end');
|
|
10054
10056
|
const SWEEPER_TICK = Symbol('tracker-sweeper-tick');
|
|
10055
10057
|
function createDeferred$2() {
|
|
@@ -10281,7 +10283,7 @@ class DefaultDeliveryTracker extends TaskSpawner {
|
|
|
10281
10283
|
const expectedResponseType = options.expectedResponseType;
|
|
10282
10284
|
const tracked = await this.lock.runExclusive(async () => {
|
|
10283
10285
|
if (this.ackFutures.has(envelope.id)) {
|
|
10284
|
-
logger$
|
|
10286
|
+
logger$17.debug('tracker_envelope_already_tracked', {
|
|
10285
10287
|
envp_id: envelope.id,
|
|
10286
10288
|
});
|
|
10287
10289
|
return null;
|
|
@@ -10291,7 +10293,7 @@ class DefaultDeliveryTracker extends TaskSpawner {
|
|
|
10291
10293
|
if (expectedResponseType & core.FameResponseType.REPLY ||
|
|
10292
10294
|
expectedResponseType & core.FameResponseType.STREAM) {
|
|
10293
10295
|
if (existingEnvId && existingEnvId !== envelope.id) {
|
|
10294
|
-
logger$
|
|
10296
|
+
logger$17.debug('envelope_already_tracked_for_replies', {
|
|
10295
10297
|
envp_id: envelope.id,
|
|
10296
10298
|
corr_id: corrId,
|
|
10297
10299
|
expected_response_type: expectedResponseType,
|
|
@@ -10340,7 +10342,7 @@ class DefaultDeliveryTracker extends TaskSpawner {
|
|
|
10340
10342
|
return null;
|
|
10341
10343
|
}
|
|
10342
10344
|
await this.scheduleTimer(tracked, options.retryPolicy ?? null, options.retryHandler ?? null);
|
|
10343
|
-
logger$
|
|
10345
|
+
logger$17.debug('tracker_registered_envelope', {
|
|
10344
10346
|
envp_id: envelope.id,
|
|
10345
10347
|
corr_id: tracked.originalEnvelope.corrId,
|
|
10346
10348
|
expected_response: tracked.expectedResponseType,
|
|
@@ -10364,21 +10366,21 @@ class DefaultDeliveryTracker extends TaskSpawner {
|
|
|
10364
10366
|
return this.awaitEnvelopeFuture(envelopeId, core.FameResponseType.REPLY | core.FameResponseType.STREAM, future, timeoutMs);
|
|
10365
10367
|
}
|
|
10366
10368
|
async onEnvelopeDelivered(inboxName, envelope, context) {
|
|
10367
|
-
logger$
|
|
10369
|
+
logger$17.debug('envelope_delivered', {
|
|
10368
10370
|
envp_id: envelope.id,
|
|
10369
10371
|
corr_id: envelope.corrId,
|
|
10370
10372
|
rtype: envelope.rtype ?? core.FameResponseType.NONE,
|
|
10371
10373
|
frame_type: envelope.frame?.type ?? 'unknown',
|
|
10372
10374
|
});
|
|
10373
10375
|
if (!envelope.corrId) {
|
|
10374
|
-
logger$
|
|
10376
|
+
logger$17.debug('envelope_delivered_no_corr_id', {
|
|
10375
10377
|
envelope_id: envelope.id,
|
|
10376
10378
|
});
|
|
10377
10379
|
return null;
|
|
10378
10380
|
}
|
|
10379
10381
|
if (this.isDeliveryAckFrame(envelope.frame)) {
|
|
10380
10382
|
if (!envelope.frame.refId) {
|
|
10381
|
-
logger$
|
|
10383
|
+
logger$17.debug('envelope_delivered_no_ref_id', {
|
|
10382
10384
|
envelope_id: envelope.id,
|
|
10383
10385
|
});
|
|
10384
10386
|
return null;
|
|
@@ -10416,7 +10418,7 @@ class DefaultDeliveryTracker extends TaskSpawner {
|
|
|
10416
10418
|
await inbox.set(envelope.id, tracked);
|
|
10417
10419
|
}
|
|
10418
10420
|
else {
|
|
10419
|
-
logger$
|
|
10421
|
+
logger$17.debug('tracker_duplicate_envelope_already_handled', {
|
|
10420
10422
|
envp_id: envelope.id,
|
|
10421
10423
|
status: tracked.status,
|
|
10422
10424
|
});
|
|
@@ -10459,7 +10461,7 @@ class DefaultDeliveryTracker extends TaskSpawner {
|
|
|
10459
10461
|
}
|
|
10460
10462
|
if (isFinalFailure) {
|
|
10461
10463
|
envelope.status = EnvelopeStatus.FAILED_TO_HANDLE;
|
|
10462
|
-
logger$
|
|
10464
|
+
logger$17.error('envelope_handle_failed_final', {
|
|
10463
10465
|
inbox_name: inboxName,
|
|
10464
10466
|
envp_id: envelope.originalEnvelope.id,
|
|
10465
10467
|
error: error?.message ?? 'unknown',
|
|
@@ -10470,7 +10472,7 @@ class DefaultDeliveryTracker extends TaskSpawner {
|
|
|
10470
10472
|
await inbox.delete(envelope.originalEnvelope.id);
|
|
10471
10473
|
return;
|
|
10472
10474
|
}
|
|
10473
|
-
logger$
|
|
10475
|
+
logger$17.warning('envelope_handle_failed_retry', {
|
|
10474
10476
|
inbox_name: inboxName,
|
|
10475
10477
|
envp_id: envelope.originalEnvelope.id,
|
|
10476
10478
|
error: error?.message ?? 'unknown',
|
|
@@ -10516,14 +10518,14 @@ class DefaultDeliveryTracker extends TaskSpawner {
|
|
|
10516
10518
|
if (handledViaFuture) {
|
|
10517
10519
|
await this.markDoneSince(this.ackFutures, refId, this.ackDoneSince);
|
|
10518
10520
|
await this.clearTimer(refId);
|
|
10519
|
-
logger$
|
|
10521
|
+
logger$17.debug('tracker_ack_resolved_without_tracked_envelope', {
|
|
10520
10522
|
envp_id: envelope.id,
|
|
10521
10523
|
ref_id: refId,
|
|
10522
10524
|
corr_id: envelope.corrId,
|
|
10523
10525
|
});
|
|
10524
10526
|
return;
|
|
10525
10527
|
}
|
|
10526
|
-
logger$
|
|
10528
|
+
logger$17.debug('tracker_ack_for_unknown_envelope', {
|
|
10527
10529
|
envp_id: envelope.id,
|
|
10528
10530
|
ref_id: refId,
|
|
10529
10531
|
corr_id: envelope.corrId,
|
|
@@ -10531,7 +10533,7 @@ class DefaultDeliveryTracker extends TaskSpawner {
|
|
|
10531
10533
|
return;
|
|
10532
10534
|
}
|
|
10533
10535
|
if (tracked.originalEnvelope.corrId !== envelope.corrId) {
|
|
10534
|
-
logger$
|
|
10536
|
+
logger$17.debug('tracker_ack_corr_id_mismatch', {
|
|
10535
10537
|
envp_id: envelope.id,
|
|
10536
10538
|
expected_corr_id: tracked.originalEnvelope.corrId,
|
|
10537
10539
|
actual_corr_id: envelope.corrId,
|
|
@@ -10556,7 +10558,7 @@ class DefaultDeliveryTracker extends TaskSpawner {
|
|
|
10556
10558
|
for (const handler of this.eventHandlers) {
|
|
10557
10559
|
await handler.onEnvelopeAcked?.(tracked);
|
|
10558
10560
|
}
|
|
10559
|
-
logger$
|
|
10561
|
+
logger$17.debug('tracker_envelope_acked', {
|
|
10560
10562
|
envp_id: tracked.originalEnvelope.id,
|
|
10561
10563
|
});
|
|
10562
10564
|
}
|
|
@@ -10574,13 +10576,13 @@ class DefaultDeliveryTracker extends TaskSpawner {
|
|
|
10574
10576
|
const outbox = this.ensureOutbox();
|
|
10575
10577
|
const tracked = await outbox.get(envelope.frame.refId);
|
|
10576
10578
|
if (!tracked) {
|
|
10577
|
-
logger$
|
|
10579
|
+
logger$17.debug('tracker_nack_for_unknown_envelope', {
|
|
10578
10580
|
envp_id: envelope.id,
|
|
10579
10581
|
});
|
|
10580
10582
|
return;
|
|
10581
10583
|
}
|
|
10582
10584
|
if (tracked.originalEnvelope.corrId !== envelope.corrId) {
|
|
10583
|
-
logger$
|
|
10585
|
+
logger$17.debug('tracker_nack_corr_id_mismatch', {
|
|
10584
10586
|
envp_id: envelope.id,
|
|
10585
10587
|
expected_corr_id: tracked.originalEnvelope.corrId,
|
|
10586
10588
|
actual_corr_id: envelope.corrId,
|
|
@@ -10622,7 +10624,7 @@ class DefaultDeliveryTracker extends TaskSpawner {
|
|
|
10622
10624
|
for (const handler of this.eventHandlers) {
|
|
10623
10625
|
await handler.onEnvelopeNacked?.(tracked, ackFrame.reason ?? null);
|
|
10624
10626
|
}
|
|
10625
|
-
logger$
|
|
10627
|
+
logger$17.debug('tracker_envelope_nacked', {
|
|
10626
10628
|
envp_id: tracked.originalEnvelope.id,
|
|
10627
10629
|
reason: ackFrame.reason,
|
|
10628
10630
|
});
|
|
@@ -10670,7 +10672,7 @@ class DefaultDeliveryTracker extends TaskSpawner {
|
|
|
10670
10672
|
for (const handler of this.eventHandlers) {
|
|
10671
10673
|
await handler.onEnvelopeReplied?.(trackedEnvelope, envelope);
|
|
10672
10674
|
}
|
|
10673
|
-
logger$
|
|
10675
|
+
logger$17.debug('tracked_envelope_replied', {
|
|
10674
10676
|
envp_id: trackedEnvelope.originalEnvelope.id,
|
|
10675
10677
|
corr_id: envelope.corrId,
|
|
10676
10678
|
});
|
|
@@ -10744,7 +10746,7 @@ class DefaultDeliveryTracker extends TaskSpawner {
|
|
|
10744
10746
|
async addToInboxDlq(trackedEnvelope, reason = null) {
|
|
10745
10747
|
const dlq = this.inboxDlq;
|
|
10746
10748
|
if (!dlq) {
|
|
10747
|
-
logger$
|
|
10749
|
+
logger$17.error('dlq_not_initialized', {
|
|
10748
10750
|
envp_id: trackedEnvelope.originalEnvelope.id,
|
|
10749
10751
|
});
|
|
10750
10752
|
return;
|
|
@@ -10759,7 +10761,7 @@ class DefaultDeliveryTracker extends TaskSpawner {
|
|
|
10759
10761
|
const deadLetteredAt = Date.now();
|
|
10760
10762
|
setMetaWithLegacy(trackedEnvelope.meta, 'deadLetteredAtMs', 'dead_lettered_at_ms', deadLetteredAt);
|
|
10761
10763
|
await dlq.set(trackedEnvelope.originalEnvelope.id, trackedEnvelope);
|
|
10762
|
-
logger$
|
|
10764
|
+
logger$17.warning('envelope_moved_to_dlq', {
|
|
10763
10765
|
envp_id: trackedEnvelope.originalEnvelope.id,
|
|
10764
10766
|
service_name: trackedEnvelope.serviceName,
|
|
10765
10767
|
});
|
|
@@ -10788,7 +10790,7 @@ class DefaultDeliveryTracker extends TaskSpawner {
|
|
|
10788
10790
|
const toDelete = Object.entries(items).filter(([, value]) => predicate ? predicate(value) : true);
|
|
10789
10791
|
await Promise.all(toDelete.map(([key]) => dlq.delete(key)));
|
|
10790
10792
|
if (toDelete.length) {
|
|
10791
|
-
logger$
|
|
10793
|
+
logger$17.debug('dlq_purged', { count: toDelete.length });
|
|
10792
10794
|
}
|
|
10793
10795
|
return toDelete.length;
|
|
10794
10796
|
}
|
|
@@ -10841,11 +10843,11 @@ class DefaultDeliveryTracker extends TaskSpawner {
|
|
|
10841
10843
|
}
|
|
10842
10844
|
this.futuresSweeper = null;
|
|
10843
10845
|
}
|
|
10844
|
-
logger$
|
|
10846
|
+
logger$17.debug('tracker_cleanup_completed');
|
|
10845
10847
|
}
|
|
10846
10848
|
async recoverPending() {
|
|
10847
10849
|
const pending = await this.listPending();
|
|
10848
|
-
logger$
|
|
10850
|
+
logger$17.debug('tracker_recovering_pending', { count: pending.length });
|
|
10849
10851
|
await this.lock.runExclusive(async () => {
|
|
10850
10852
|
for (const tracked of pending) {
|
|
10851
10853
|
if (tracked.expectedResponseType & core.FameResponseType.ACK) {
|
|
@@ -10871,7 +10873,7 @@ class DefaultDeliveryTracker extends TaskSpawner {
|
|
|
10871
10873
|
for (const tracked of pending) {
|
|
10872
10874
|
await this.scheduleTimer(tracked, null, null);
|
|
10873
10875
|
}
|
|
10874
|
-
logger$
|
|
10876
|
+
logger$17.debug('tracker_recovery_completed', { count: pending.length });
|
|
10875
10877
|
}
|
|
10876
10878
|
ensureOutbox() {
|
|
10877
10879
|
if (!this.outbox) {
|
|
@@ -10886,7 +10888,7 @@ class DefaultDeliveryTracker extends TaskSpawner {
|
|
|
10886
10888
|
return this.inbox;
|
|
10887
10889
|
}
|
|
10888
10890
|
async waitForPendingAcks() {
|
|
10889
|
-
logger$
|
|
10891
|
+
logger$17.debug('tracker_node_preparing_to_stop_waiting_for_pending_acks');
|
|
10890
10892
|
const outbox = this.outbox;
|
|
10891
10893
|
if (!outbox) {
|
|
10892
10894
|
return;
|
|
@@ -10898,7 +10900,7 @@ class DefaultDeliveryTracker extends TaskSpawner {
|
|
|
10898
10900
|
continue;
|
|
10899
10901
|
}
|
|
10900
10902
|
if (!future.done) {
|
|
10901
|
-
logger$
|
|
10903
|
+
logger$17.debug('tracker_pending_ack_future_detected', {
|
|
10902
10904
|
envelope_id: envelopeId,
|
|
10903
10905
|
});
|
|
10904
10906
|
pending.push({ envelopeId, future });
|
|
@@ -10906,10 +10908,10 @@ class DefaultDeliveryTracker extends TaskSpawner {
|
|
|
10906
10908
|
}
|
|
10907
10909
|
});
|
|
10908
10910
|
if (!pending.length) {
|
|
10909
|
-
logger$
|
|
10911
|
+
logger$17.debug('tracker_no_pending_acks_to_wait_for');
|
|
10910
10912
|
return;
|
|
10911
10913
|
}
|
|
10912
|
-
logger$
|
|
10914
|
+
logger$17.debug('tracker_waiting_for_pending_acks', { count: pending.length });
|
|
10913
10915
|
for (const entry of pending) {
|
|
10914
10916
|
if (!entry) {
|
|
10915
10917
|
continue;
|
|
@@ -10926,19 +10928,19 @@ class DefaultDeliveryTracker extends TaskSpawner {
|
|
|
10926
10928
|
}
|
|
10927
10929
|
try {
|
|
10928
10930
|
await this.awaitWithTimeout(entry.future.promise, remainingMs);
|
|
10929
|
-
logger$
|
|
10931
|
+
logger$17.debug('tracker_received_ack', {
|
|
10930
10932
|
envelope_id: entry.envelopeId,
|
|
10931
10933
|
});
|
|
10932
10934
|
await outbox.delete(entry.envelopeId);
|
|
10933
10935
|
}
|
|
10934
10936
|
catch (error) {
|
|
10935
10937
|
if (error instanceof Error && error.name === 'TimeoutError') {
|
|
10936
|
-
logger$
|
|
10938
|
+
logger$17.debug('tracker_ack_timeout_expired', {
|
|
10937
10939
|
envelope_id: entry.envelopeId,
|
|
10938
10940
|
});
|
|
10939
10941
|
}
|
|
10940
10942
|
else {
|
|
10941
|
-
logger$
|
|
10943
|
+
logger$17.debug('tracker_ack_wait_error', {
|
|
10942
10944
|
envelope_id: entry.envelopeId,
|
|
10943
10945
|
error: error instanceof Error ? error.message : String(error),
|
|
10944
10946
|
});
|
|
@@ -10946,13 +10948,13 @@ class DefaultDeliveryTracker extends TaskSpawner {
|
|
|
10946
10948
|
}
|
|
10947
10949
|
}
|
|
10948
10950
|
catch (error) {
|
|
10949
|
-
logger$
|
|
10951
|
+
logger$17.error('tracker_error_waiting_for_ack', {
|
|
10950
10952
|
envelope_id: entry.envelopeId,
|
|
10951
10953
|
error: error instanceof Error ? error.message : String(error),
|
|
10952
10954
|
});
|
|
10953
10955
|
}
|
|
10954
10956
|
}
|
|
10955
|
-
logger$
|
|
10957
|
+
logger$17.debug('tracker_finished_waiting_for_pending_acks');
|
|
10956
10958
|
}
|
|
10957
10959
|
async waitForPendingAckDispatches() {
|
|
10958
10960
|
while (this.pendingAckDispatches.size > 0) {
|
|
@@ -11010,7 +11012,7 @@ class DefaultDeliveryTracker extends TaskSpawner {
|
|
|
11010
11012
|
for (const handler of this.eventHandlers) {
|
|
11011
11013
|
await handler.onEnvelopeTimeout?.(currentTracked);
|
|
11012
11014
|
}
|
|
11013
|
-
logger$
|
|
11015
|
+
logger$17.debug('tracker_envelope_timed_out', {
|
|
11014
11016
|
envp_id: tracked.originalEnvelope.id,
|
|
11015
11017
|
});
|
|
11016
11018
|
return;
|
|
@@ -11023,7 +11025,7 @@ class DefaultDeliveryTracker extends TaskSpawner {
|
|
|
11023
11025
|
currentTracked.timeoutAtMs = nextTimeoutAt;
|
|
11024
11026
|
await outbox.set(tracked.originalEnvelope.id, currentTracked);
|
|
11025
11027
|
await this.scheduleTimer(currentTracked, retryPolicy, retryHandler);
|
|
11026
|
-
logger$
|
|
11028
|
+
logger$17.debug('tracker_retry_deferred_during_shutdown', {
|
|
11027
11029
|
envp_id: tracked.originalEnvelope.id,
|
|
11028
11030
|
defer_ms: shutdownDeferMs,
|
|
11029
11031
|
});
|
|
@@ -11046,7 +11048,7 @@ class DefaultDeliveryTracker extends TaskSpawner {
|
|
|
11046
11048
|
});
|
|
11047
11049
|
}
|
|
11048
11050
|
await this.scheduleTimer(currentTracked, retryPolicy, retryHandler);
|
|
11049
|
-
logger$
|
|
11051
|
+
logger$17.debug('envelope_delivery_retry_scheduled', {
|
|
11050
11052
|
envp_id: tracked.originalEnvelope.id,
|
|
11051
11053
|
attempt: currentTracked.attempt,
|
|
11052
11054
|
max_retries: retryPolicy.maxRetries,
|
|
@@ -11058,7 +11060,7 @@ class DefaultDeliveryTracker extends TaskSpawner {
|
|
|
11058
11060
|
currentTracked.timeoutAtMs = currentTracked.overallTimeoutAtMs;
|
|
11059
11061
|
await outbox.set(tracked.originalEnvelope.id, currentTracked);
|
|
11060
11062
|
await this.scheduleTimer(currentTracked, retryPolicy, retryHandler);
|
|
11061
|
-
logger$
|
|
11063
|
+
logger$17.debug('envelope_retries_exhausted_waiting_until_overall_timeout', {
|
|
11062
11064
|
envp_id: tracked.originalEnvelope.id,
|
|
11063
11065
|
attempt: currentTracked.attempt,
|
|
11064
11066
|
overall_timeout_at_ms: currentTracked.overallTimeoutAtMs,
|
|
@@ -11078,7 +11080,7 @@ class DefaultDeliveryTracker extends TaskSpawner {
|
|
|
11078
11080
|
for (const handler of this.eventHandlers) {
|
|
11079
11081
|
await handler.onEnvelopeTimeout?.(currentTracked);
|
|
11080
11082
|
}
|
|
11081
|
-
logger$
|
|
11083
|
+
logger$17.debug('tracker_envelope_timed_out', {
|
|
11082
11084
|
envp_id: tracked.originalEnvelope.id,
|
|
11083
11085
|
});
|
|
11084
11086
|
}
|
|
@@ -11086,7 +11088,7 @@ class DefaultDeliveryTracker extends TaskSpawner {
|
|
|
11086
11088
|
if (error instanceof TaskCancelledError) {
|
|
11087
11089
|
return;
|
|
11088
11090
|
}
|
|
11089
|
-
logger$
|
|
11091
|
+
logger$17.error('tracker_timer_error', {
|
|
11090
11092
|
envp_id: tracked.originalEnvelope.id,
|
|
11091
11093
|
error: error instanceof Error ? error.message : String(error),
|
|
11092
11094
|
});
|
|
@@ -11141,7 +11143,7 @@ class DefaultDeliveryTracker extends TaskSpawner {
|
|
|
11141
11143
|
if (timeoutSeconds !== null) {
|
|
11142
11144
|
return await this.awaitWithTimeout(future.promise, timeoutSeconds);
|
|
11143
11145
|
}
|
|
11144
|
-
logger$
|
|
11146
|
+
logger$17.debug('await_envelope_no_timeout_wait', {
|
|
11145
11147
|
envelope_id: envelopeId,
|
|
11146
11148
|
});
|
|
11147
11149
|
return await future.promise;
|
|
@@ -11150,7 +11152,7 @@ class DefaultDeliveryTracker extends TaskSpawner {
|
|
|
11150
11152
|
if (error instanceof Error && error.name !== 'TimeoutError') {
|
|
11151
11153
|
throw error;
|
|
11152
11154
|
}
|
|
11153
|
-
logger$
|
|
11155
|
+
logger$17.error('await_envelope_timeout_error', {
|
|
11154
11156
|
envelope_id: envelopeId,
|
|
11155
11157
|
timeout_ms: timeoutSeconds,
|
|
11156
11158
|
future_done: false,
|
|
@@ -11311,7 +11313,7 @@ class DefaultDeliveryTracker extends TaskSpawner {
|
|
|
11311
11313
|
this.replyDoneSince.delete(envId);
|
|
11312
11314
|
}
|
|
11313
11315
|
});
|
|
11314
|
-
logger$
|
|
11316
|
+
logger$17.debug('tracker_swept_completed_futures', {
|
|
11315
11317
|
ack_removed: toRemoveAck.length,
|
|
11316
11318
|
reply_removed: toRemoveReply.length,
|
|
11317
11319
|
grace_secs: this.futGcGraceSecs,
|
|
@@ -11325,7 +11327,7 @@ class DefaultDeliveryTracker extends TaskSpawner {
|
|
|
11325
11327
|
if (error instanceof Error && error.name === 'TimeoutError') {
|
|
11326
11328
|
continue;
|
|
11327
11329
|
}
|
|
11328
|
-
logger$
|
|
11330
|
+
logger$17.error('tracker_sweeper_error', {
|
|
11329
11331
|
error: error instanceof Error ? error.message : String(error),
|
|
11330
11332
|
});
|
|
11331
11333
|
}
|
|
@@ -11356,14 +11358,14 @@ class DefaultDeliveryTracker extends TaskSpawner {
|
|
|
11356
11358
|
}
|
|
11357
11359
|
const node = this.node;
|
|
11358
11360
|
if (!envelope.replyTo) {
|
|
11359
|
-
logger$
|
|
11361
|
+
logger$17.error('cannot_send_ack_no_reply_to', { envp_id: envelope.id });
|
|
11360
11362
|
return;
|
|
11361
11363
|
}
|
|
11362
11364
|
if (!envelope.corrId) {
|
|
11363
|
-
logger$
|
|
11365
|
+
logger$17.error('cannot_send_ack_no_corr_id', { envp_id: envelope.id });
|
|
11364
11366
|
return;
|
|
11365
11367
|
}
|
|
11366
|
-
logger$
|
|
11368
|
+
logger$17.debug('tracker_sending_ack', {
|
|
11367
11369
|
envp_id: envelope.id,
|
|
11368
11370
|
ref_id: envelope.id,
|
|
11369
11371
|
to: envelope.replyTo,
|
|
@@ -11383,7 +11385,7 @@ class DefaultDeliveryTracker extends TaskSpawner {
|
|
|
11383
11385
|
.send(ackEnvelope)
|
|
11384
11386
|
.then(() => undefined)
|
|
11385
11387
|
.catch((error) => {
|
|
11386
|
-
logger$
|
|
11388
|
+
logger$17.error('tracker_ack_dispatch_failed', {
|
|
11387
11389
|
envp_id: envelope.id,
|
|
11388
11390
|
error: error instanceof Error ? error.message : String(error),
|
|
11389
11391
|
});
|
|
@@ -11469,7 +11471,7 @@ class AsyncEvent {
|
|
|
11469
11471
|
}
|
|
11470
11472
|
}
|
|
11471
11473
|
|
|
11472
|
-
const logger$
|
|
11474
|
+
const logger$16 = getLogger('naylence.fame.node.root_session_manager');
|
|
11473
11475
|
function resolveOption$1(options, primary, ...aliases) {
|
|
11474
11476
|
const record = options;
|
|
11475
11477
|
const primaryKey = primary;
|
|
@@ -11550,7 +11552,7 @@ class RootSessionManager extends TaskSpawner {
|
|
|
11550
11552
|
this.onAdmissionFailed =
|
|
11551
11553
|
typeof onAdmissionFailed === 'function' ? onAdmissionFailed : undefined;
|
|
11552
11554
|
this.enableContinuousRefresh = enableContinuousRefresh ?? true;
|
|
11553
|
-
logger$
|
|
11555
|
+
logger$16.debug('created_root_session_manager');
|
|
11554
11556
|
}
|
|
11555
11557
|
get isReady() {
|
|
11556
11558
|
return this.readyEvent.isSet();
|
|
@@ -11575,7 +11577,7 @@ class RootSessionManager extends TaskSpawner {
|
|
|
11575
11577
|
if (this.admissionTask) {
|
|
11576
11578
|
return;
|
|
11577
11579
|
}
|
|
11578
|
-
logger$
|
|
11580
|
+
logger$16.debug('root_session_manager_starting');
|
|
11579
11581
|
this.stopEvent.clear();
|
|
11580
11582
|
this.readyEvent.clear();
|
|
11581
11583
|
const taskName = `root-admission-${this.admissionEpoch}`;
|
|
@@ -11595,10 +11597,10 @@ class RootSessionManager extends TaskSpawner {
|
|
|
11595
11597
|
await this.admissionTask.promise;
|
|
11596
11598
|
throw new FameConnectError('Root session manager failed to become ready');
|
|
11597
11599
|
}
|
|
11598
|
-
logger$
|
|
11600
|
+
logger$16.debug('root_session_manager_started');
|
|
11599
11601
|
}
|
|
11600
11602
|
async stop() {
|
|
11601
|
-
logger$
|
|
11603
|
+
logger$16.debug('root_session_manager_stopping');
|
|
11602
11604
|
this.stopEvent.set();
|
|
11603
11605
|
if (this.admissionTask) {
|
|
11604
11606
|
this.admissionTask.cancel();
|
|
@@ -11610,7 +11612,7 @@ class RootSessionManager extends TaskSpawner {
|
|
|
11610
11612
|
await this.consumeTask(this.expiryGuardTask);
|
|
11611
11613
|
this.expiryGuardTask = null;
|
|
11612
11614
|
}
|
|
11613
|
-
logger$
|
|
11615
|
+
logger$16.debug('root_session_manager_stopped');
|
|
11614
11616
|
}
|
|
11615
11617
|
async awaitReady(timeoutMs) {
|
|
11616
11618
|
if (this.isReady) {
|
|
@@ -11651,12 +11653,12 @@ class RootSessionManager extends TaskSpawner {
|
|
|
11651
11653
|
await this.onEpochChange(epoch);
|
|
11652
11654
|
}
|
|
11653
11655
|
else {
|
|
11654
|
-
logger$
|
|
11656
|
+
logger$16.debug('epoch_change_ignored_no_handler', { epoch });
|
|
11655
11657
|
}
|
|
11656
11658
|
}
|
|
11657
11659
|
static createForRootSentinel(node, admissionClient, requestedLogicals = [], enableContinuousRefresh = true, onEpochChange) {
|
|
11658
11660
|
const handleWelcome = async (frame) => {
|
|
11659
|
-
logger$
|
|
11661
|
+
logger$16.info('root_admission_successful', {
|
|
11660
11662
|
system_id: frame.systemId,
|
|
11661
11663
|
assigned_path: frame.assignedPath ?? null,
|
|
11662
11664
|
accepted_logicals: frame.acceptedLogicals ?? [],
|
|
@@ -11667,12 +11669,12 @@ class RootSessionManager extends TaskSpawner {
|
|
|
11667
11669
|
? grant.purpose
|
|
11668
11670
|
: undefined;
|
|
11669
11671
|
if (purpose) {
|
|
11670
|
-
logger$
|
|
11672
|
+
logger$16.debug('received_admission_grant', { purpose });
|
|
11671
11673
|
}
|
|
11672
11674
|
}
|
|
11673
11675
|
};
|
|
11674
11676
|
const handleFailure = async (error) => {
|
|
11675
|
-
logger$
|
|
11677
|
+
logger$16.error('root_admission_failed_permanently', {
|
|
11676
11678
|
error: error.message,
|
|
11677
11679
|
});
|
|
11678
11680
|
};
|
|
@@ -11701,10 +11703,10 @@ class RootSessionManager extends TaskSpawner {
|
|
|
11701
11703
|
this.readyEvent.set();
|
|
11702
11704
|
}
|
|
11703
11705
|
if (this.hadSuccessfulAdmission) {
|
|
11704
|
-
logger$
|
|
11706
|
+
logger$16.debug('root_admission_refreshed');
|
|
11705
11707
|
}
|
|
11706
11708
|
else {
|
|
11707
|
-
logger$
|
|
11709
|
+
logger$16.debug('root_admission_completed');
|
|
11708
11710
|
}
|
|
11709
11711
|
this.hadSuccessfulAdmission = true;
|
|
11710
11712
|
delay = RootSessionManager.BACKOFF_INITIAL;
|
|
@@ -11713,7 +11715,7 @@ class RootSessionManager extends TaskSpawner {
|
|
|
11713
11715
|
await this.startExpiryGuard(welcomeFrame);
|
|
11714
11716
|
const expiryTriggered = await this.waitForExpiryOrStop();
|
|
11715
11717
|
if (expiryTriggered && !this.stopEvent.isSet()) {
|
|
11716
|
-
logger$
|
|
11718
|
+
logger$16.debug('performing_scheduled_re_admission');
|
|
11717
11719
|
continue;
|
|
11718
11720
|
}
|
|
11719
11721
|
}
|
|
@@ -11725,7 +11727,7 @@ class RootSessionManager extends TaskSpawner {
|
|
|
11725
11727
|
}
|
|
11726
11728
|
const errorObject = error instanceof Error ? error : new Error(String(error));
|
|
11727
11729
|
const willRetry = attempts < RootSessionManager.RETRY_MAX_ATTEMPTS;
|
|
11728
|
-
logger$
|
|
11730
|
+
logger$16.warning('root_admission_failed', {
|
|
11729
11731
|
error: errorObject.message,
|
|
11730
11732
|
attempt: attempts,
|
|
11731
11733
|
will_retry: willRetry,
|
|
@@ -11743,7 +11745,7 @@ class RootSessionManager extends TaskSpawner {
|
|
|
11743
11745
|
}
|
|
11744
11746
|
}
|
|
11745
11747
|
if (attempts >= RootSessionManager.RETRY_MAX_ATTEMPTS) {
|
|
11746
|
-
logger$
|
|
11748
|
+
logger$16.error('root_admission_max_attempts_exceeded', {
|
|
11747
11749
|
max_attempts: RootSessionManager.RETRY_MAX_ATTEMPTS,
|
|
11748
11750
|
});
|
|
11749
11751
|
}
|
|
@@ -11820,7 +11822,7 @@ class RootSessionManager extends TaskSpawner {
|
|
|
11820
11822
|
}
|
|
11821
11823
|
async expiryGuard(welcomeFrame, signal) {
|
|
11822
11824
|
if (!welcomeFrame.expiresAt) {
|
|
11823
|
-
logger$
|
|
11825
|
+
logger$16.debug('no_admission_expiry_configured');
|
|
11824
11826
|
await Promise.race([this.stopEvent.wait(), this.waitForAbort(signal)]);
|
|
11825
11827
|
return;
|
|
11826
11828
|
}
|
|
@@ -11829,7 +11831,7 @@ class RootSessionManager extends TaskSpawner {
|
|
|
11829
11831
|
let delaySeconds = (expiresAt.getTime() - now.getTime()) / 1000 -
|
|
11830
11832
|
RootSessionManager.JWT_REFRESH_SAFETY;
|
|
11831
11833
|
delaySeconds = Math.max(delaySeconds, 0);
|
|
11832
|
-
logger$
|
|
11834
|
+
logger$16.debug('admission_expiry_guard_started', {
|
|
11833
11835
|
welcome_expires_at: expiresAt.toISOString(),
|
|
11834
11836
|
delay_seconds: delaySeconds,
|
|
11835
11837
|
refresh_safety_seconds: RootSessionManager.JWT_REFRESH_SAFETY,
|
|
@@ -11838,7 +11840,7 @@ class RootSessionManager extends TaskSpawner {
|
|
|
11838
11840
|
if (this.stopEvent.isSet() || signal?.aborted) {
|
|
11839
11841
|
return;
|
|
11840
11842
|
}
|
|
11841
|
-
logger$
|
|
11843
|
+
logger$16.debug('admission_expiry_triggered_refresh', {
|
|
11842
11844
|
expires_at: expiresAt.toISOString(),
|
|
11843
11845
|
current_time: new Date().toISOString(),
|
|
11844
11846
|
seconds_before_expiry: RootSessionManager.JWT_REFRESH_SAFETY,
|
|
@@ -11853,7 +11855,7 @@ class RootSessionManager extends TaskSpawner {
|
|
|
11853
11855
|
return;
|
|
11854
11856
|
}
|
|
11855
11857
|
const errorObject = error instanceof Error ? error : new Error(String(error));
|
|
11856
|
-
logger$
|
|
11858
|
+
logger$16.debug('background_task_error', {
|
|
11857
11859
|
task_name: task.name,
|
|
11858
11860
|
error: errorObject.message,
|
|
11859
11861
|
});
|
|
@@ -11949,7 +11951,7 @@ class BoundedAsyncQueue {
|
|
|
11949
11951
|
}
|
|
11950
11952
|
}
|
|
11951
11953
|
|
|
11952
|
-
const logger$
|
|
11954
|
+
const logger$15 = getLogger('naylence.fame.connector.broadcast_channel_connector');
|
|
11953
11955
|
const BROADCAST_CHANNEL_CONNECTOR_TYPE$1 = 'broadcast-channel-connector';
|
|
11954
11956
|
const DEFAULT_CHANNEL$7 = 'naylence-fabric';
|
|
11955
11957
|
const DEFAULT_INBOX_CAPACITY$7 = 2048;
|
|
@@ -12038,7 +12040,7 @@ let BroadcastChannelConnector$2 = class BroadcastChannelConnector extends BaseAs
|
|
|
12038
12040
|
this.localNodeId = normalizedLocalNodeId;
|
|
12039
12041
|
this.targetNodeId = BroadcastChannelConnector.normalizeTargetNodeId(config.initialTargetNodeId);
|
|
12040
12042
|
this.channel = new BroadcastChannel(this.channelName);
|
|
12041
|
-
logger$
|
|
12043
|
+
logger$15.debug('broadcast_channel_connector_created', {
|
|
12042
12044
|
channel: this.channelName,
|
|
12043
12045
|
connector_id: this.connectorId,
|
|
12044
12046
|
local_node_id: this.localNodeId,
|
|
@@ -12050,7 +12052,7 @@ let BroadcastChannelConnector$2 = class BroadcastChannelConnector extends BaseAs
|
|
|
12050
12052
|
this.onMsg = (event) => {
|
|
12051
12053
|
// Guard: Don't process if listener was unregistered
|
|
12052
12054
|
if (!this.listenerRegistered) {
|
|
12053
|
-
logger$
|
|
12055
|
+
logger$15.warning('broadcast_channel_message_after_unregister', {
|
|
12054
12056
|
channel: this.channelName,
|
|
12055
12057
|
connector_id: this.connectorId,
|
|
12056
12058
|
timestamp: new Date().toISOString(),
|
|
@@ -12058,7 +12060,7 @@ let BroadcastChannelConnector$2 = class BroadcastChannelConnector extends BaseAs
|
|
|
12058
12060
|
return;
|
|
12059
12061
|
}
|
|
12060
12062
|
const message = event.data;
|
|
12061
|
-
logger$
|
|
12063
|
+
logger$15.debug('broadcast_channel_raw_event', {
|
|
12062
12064
|
channel: this.channelName,
|
|
12063
12065
|
connector_id: this.connectorId,
|
|
12064
12066
|
message_type: message && typeof message === 'object'
|
|
@@ -12074,7 +12076,7 @@ let BroadcastChannelConnector$2 = class BroadcastChannelConnector extends BaseAs
|
|
|
12074
12076
|
const busMessage = message;
|
|
12075
12077
|
const senderNodeId = BroadcastChannelConnector.normalizeNodeId(busMessage.senderNodeId);
|
|
12076
12078
|
if (!senderNodeId) {
|
|
12077
|
-
logger$
|
|
12079
|
+
logger$15.debug('broadcast_channel_message_rejected', {
|
|
12078
12080
|
channel: this.channelName,
|
|
12079
12081
|
connector_id: this.connectorId,
|
|
12080
12082
|
reason: 'missing_sender_node_id',
|
|
@@ -12082,7 +12084,7 @@ let BroadcastChannelConnector$2 = class BroadcastChannelConnector extends BaseAs
|
|
|
12082
12084
|
return;
|
|
12083
12085
|
}
|
|
12084
12086
|
if (senderNodeId === this.localNodeId) {
|
|
12085
|
-
logger$
|
|
12087
|
+
logger$15.debug('broadcast_channel_message_rejected', {
|
|
12086
12088
|
channel: this.channelName,
|
|
12087
12089
|
connector_id: this.connectorId,
|
|
12088
12090
|
reason: 'self_echo',
|
|
@@ -12096,14 +12098,14 @@ let BroadcastChannelConnector$2 = class BroadcastChannelConnector extends BaseAs
|
|
|
12096
12098
|
}
|
|
12097
12099
|
const payload = BroadcastChannelConnector.coercePayload(busMessage.payload);
|
|
12098
12100
|
if (!payload) {
|
|
12099
|
-
logger$
|
|
12101
|
+
logger$15.debug('broadcast_channel_payload_rejected', {
|
|
12100
12102
|
channel: this.channelName,
|
|
12101
12103
|
connector_id: this.connectorId,
|
|
12102
12104
|
reason: 'unrecognized_payload_type',
|
|
12103
12105
|
});
|
|
12104
12106
|
return;
|
|
12105
12107
|
}
|
|
12106
|
-
logger$
|
|
12108
|
+
logger$15.debug('broadcast_channel_message_received', {
|
|
12107
12109
|
channel: this.channelName,
|
|
12108
12110
|
sender_id: message?.senderId,
|
|
12109
12111
|
sender_node_id: senderNodeId,
|
|
@@ -12132,14 +12134,14 @@ let BroadcastChannelConnector$2 = class BroadcastChannelConnector extends BaseAs
|
|
|
12132
12134
|
}
|
|
12133
12135
|
catch (error) {
|
|
12134
12136
|
if (error instanceof QueueFullError) {
|
|
12135
|
-
logger$
|
|
12137
|
+
logger$15.warning('broadcast_channel_receive_queue_full', {
|
|
12136
12138
|
channel: this.channelName,
|
|
12137
12139
|
inbox_capacity: this.inboxCapacity,
|
|
12138
12140
|
inbox_remaining_capacity: this.inbox.remainingCapacity,
|
|
12139
12141
|
});
|
|
12140
12142
|
}
|
|
12141
12143
|
else {
|
|
12142
|
-
logger$
|
|
12144
|
+
logger$15.error('broadcast_channel_receive_error', {
|
|
12143
12145
|
channel: this.channelName,
|
|
12144
12146
|
error: error instanceof Error ? error.message : String(error),
|
|
12145
12147
|
});
|
|
@@ -12153,7 +12155,7 @@ let BroadcastChannelConnector$2 = class BroadcastChannelConnector extends BaseAs
|
|
|
12153
12155
|
// Setup visibility change monitoring
|
|
12154
12156
|
this.visibilityChangeHandler = () => {
|
|
12155
12157
|
const isHidden = document.hidden;
|
|
12156
|
-
logger$
|
|
12158
|
+
logger$15.debug('broadcast_channel_visibility_changed', {
|
|
12157
12159
|
channel: this.channelName,
|
|
12158
12160
|
connector_id: this.connectorId,
|
|
12159
12161
|
visibility: isHidden ? 'hidden' : 'visible',
|
|
@@ -12162,7 +12164,7 @@ let BroadcastChannelConnector$2 = class BroadcastChannelConnector extends BaseAs
|
|
|
12162
12164
|
// Pause/resume connector based on visibility
|
|
12163
12165
|
if (isHidden && this.state === core.ConnectorState.STARTED) {
|
|
12164
12166
|
this.pause().catch((err) => {
|
|
12165
|
-
logger$
|
|
12167
|
+
logger$15.warning('broadcast_channel_pause_failed', {
|
|
12166
12168
|
channel: this.channelName,
|
|
12167
12169
|
connector_id: this.connectorId,
|
|
12168
12170
|
error: err instanceof Error ? err.message : String(err),
|
|
@@ -12171,7 +12173,7 @@ let BroadcastChannelConnector$2 = class BroadcastChannelConnector extends BaseAs
|
|
|
12171
12173
|
}
|
|
12172
12174
|
else if (!isHidden && this.state === core.ConnectorState.PAUSED) {
|
|
12173
12175
|
this.resume().catch((err) => {
|
|
12174
|
-
logger$
|
|
12176
|
+
logger$15.warning('broadcast_channel_resume_failed', {
|
|
12175
12177
|
channel: this.channelName,
|
|
12176
12178
|
connector_id: this.connectorId,
|
|
12177
12179
|
error: err instanceof Error ? err.message : String(err),
|
|
@@ -12185,7 +12187,7 @@ let BroadcastChannelConnector$2 = class BroadcastChannelConnector extends BaseAs
|
|
|
12185
12187
|
// Track page lifecycle events to detect browser unload/discard
|
|
12186
12188
|
if (typeof window !== 'undefined') {
|
|
12187
12189
|
const lifecycleLogger = (event) => {
|
|
12188
|
-
logger$
|
|
12190
|
+
logger$15.debug('broadcast_channel_page_lifecycle', {
|
|
12189
12191
|
channel: this.channelName,
|
|
12190
12192
|
connector_id: this.connectorId,
|
|
12191
12193
|
event_type: event.type,
|
|
@@ -12201,7 +12203,7 @@ let BroadcastChannelConnector$2 = class BroadcastChannelConnector extends BaseAs
|
|
|
12201
12203
|
document.addEventListener('resume', lifecycleLogger);
|
|
12202
12204
|
}
|
|
12203
12205
|
// Log initial state with detailed visibility info
|
|
12204
|
-
logger$
|
|
12206
|
+
logger$15.debug('broadcast_channel_initial_visibility', {
|
|
12205
12207
|
channel: this.channelName,
|
|
12206
12208
|
connector_id: this.connectorId,
|
|
12207
12209
|
visibility: document.hidden ? 'hidden' : 'visible',
|
|
@@ -12233,14 +12235,14 @@ let BroadcastChannelConnector$2 = class BroadcastChannelConnector extends BaseAs
|
|
|
12233
12235
|
}
|
|
12234
12236
|
catch (error) {
|
|
12235
12237
|
if (error instanceof QueueFullError) {
|
|
12236
|
-
logger$
|
|
12238
|
+
logger$15.warning('broadcast_channel_push_queue_full', {
|
|
12237
12239
|
channel: this.channelName,
|
|
12238
12240
|
inbox_capacity: this.inboxCapacity,
|
|
12239
12241
|
inbox_remaining_capacity: this.inbox.remainingCapacity,
|
|
12240
12242
|
});
|
|
12241
12243
|
throw error;
|
|
12242
12244
|
}
|
|
12243
|
-
logger$
|
|
12245
|
+
logger$15.error('broadcast_channel_push_failed', {
|
|
12244
12246
|
channel: this.channelName,
|
|
12245
12247
|
error: error instanceof Error ? error.message : String(error),
|
|
12246
12248
|
});
|
|
@@ -12250,7 +12252,7 @@ let BroadcastChannelConnector$2 = class BroadcastChannelConnector extends BaseAs
|
|
|
12250
12252
|
async _transportSendBytes(data) {
|
|
12251
12253
|
ensureBroadcastEnvironment();
|
|
12252
12254
|
const targetNodeId = this.targetNodeId ?? '*';
|
|
12253
|
-
logger$
|
|
12255
|
+
logger$15.debug('broadcast_channel_message_sending', {
|
|
12254
12256
|
channel: this.channelName,
|
|
12255
12257
|
sender_id: this.connectorId,
|
|
12256
12258
|
sender_node_id: this.localNodeId,
|
|
@@ -12271,7 +12273,7 @@ let BroadcastChannelConnector$2 = class BroadcastChannelConnector extends BaseAs
|
|
|
12271
12273
|
return item;
|
|
12272
12274
|
}
|
|
12273
12275
|
async _transportClose(code, reason) {
|
|
12274
|
-
logger$
|
|
12276
|
+
logger$15.debug('broadcast_channel_transport_closing', {
|
|
12275
12277
|
channel: this.channelName,
|
|
12276
12278
|
connector_id: this.connectorId,
|
|
12277
12279
|
code,
|
|
@@ -12280,14 +12282,14 @@ let BroadcastChannelConnector$2 = class BroadcastChannelConnector extends BaseAs
|
|
|
12280
12282
|
timestamp: new Date().toISOString(),
|
|
12281
12283
|
});
|
|
12282
12284
|
if (this.listenerRegistered) {
|
|
12283
|
-
logger$
|
|
12285
|
+
logger$15.debug('broadcast_channel_removing_listener', {
|
|
12284
12286
|
channel: this.channelName,
|
|
12285
12287
|
connector_id: this.connectorId,
|
|
12286
12288
|
timestamp: new Date().toISOString(),
|
|
12287
12289
|
});
|
|
12288
12290
|
this.channel.removeEventListener('message', this.onMsg);
|
|
12289
12291
|
this.listenerRegistered = false;
|
|
12290
|
-
logger$
|
|
12292
|
+
logger$15.debug('broadcast_channel_listener_removed', {
|
|
12291
12293
|
channel: this.channelName,
|
|
12292
12294
|
connector_id: this.connectorId,
|
|
12293
12295
|
timestamp: new Date().toISOString(),
|
|
@@ -12300,13 +12302,13 @@ let BroadcastChannelConnector$2 = class BroadcastChannelConnector extends BaseAs
|
|
|
12300
12302
|
this.visibilityChangeListenerRegistered = false;
|
|
12301
12303
|
this.visibilityChangeHandler = undefined;
|
|
12302
12304
|
}
|
|
12303
|
-
logger$
|
|
12305
|
+
logger$15.debug('broadcast_channel_closing', {
|
|
12304
12306
|
channel: this.channelName,
|
|
12305
12307
|
connector_id: this.connectorId,
|
|
12306
12308
|
timestamp: new Date().toISOString(),
|
|
12307
12309
|
});
|
|
12308
12310
|
this.channel.close();
|
|
12309
|
-
logger$
|
|
12311
|
+
logger$15.debug('broadcast_channel_closed', {
|
|
12310
12312
|
channel: this.channelName,
|
|
12311
12313
|
connector_id: this.connectorId,
|
|
12312
12314
|
timestamp: new Date().toISOString(),
|
|
@@ -12330,7 +12332,7 @@ let BroadcastChannelConnector$2 = class BroadcastChannelConnector extends BaseAs
|
|
|
12330
12332
|
if (targetNodeId &&
|
|
12331
12333
|
targetNodeId !== '*' &&
|
|
12332
12334
|
targetNodeId !== this.localNodeId) {
|
|
12333
|
-
logger$
|
|
12335
|
+
logger$15.debug('broadcast_channel_message_rejected', {
|
|
12334
12336
|
channel: this.channelName,
|
|
12335
12337
|
connector_id: this.connectorId,
|
|
12336
12338
|
reason: 'wildcard_target_mismatch',
|
|
@@ -12346,7 +12348,7 @@ let BroadcastChannelConnector$2 = class BroadcastChannelConnector extends BaseAs
|
|
|
12346
12348
|
if (expectedSender &&
|
|
12347
12349
|
expectedSender !== '*' &&
|
|
12348
12350
|
senderNodeId !== expectedSender) {
|
|
12349
|
-
logger$
|
|
12351
|
+
logger$15.debug('broadcast_channel_message_rejected', {
|
|
12350
12352
|
channel: this.channelName,
|
|
12351
12353
|
connector_id: this.connectorId,
|
|
12352
12354
|
reason: 'unexpected_sender',
|
|
@@ -12359,7 +12361,7 @@ let BroadcastChannelConnector$2 = class BroadcastChannelConnector extends BaseAs
|
|
|
12359
12361
|
if (targetNodeId &&
|
|
12360
12362
|
targetNodeId !== '*' &&
|
|
12361
12363
|
targetNodeId !== this.localNodeId) {
|
|
12362
|
-
logger$
|
|
12364
|
+
logger$15.debug('broadcast_channel_message_rejected', {
|
|
12363
12365
|
channel: this.channelName,
|
|
12364
12366
|
connector_id: this.connectorId,
|
|
12365
12367
|
reason: 'unexpected_target',
|
|
@@ -12384,7 +12386,7 @@ let BroadcastChannelConnector$2 = class BroadcastChannelConnector extends BaseAs
|
|
|
12384
12386
|
return 'unknown';
|
|
12385
12387
|
}
|
|
12386
12388
|
logInboxSnapshot(event, extra = {}) {
|
|
12387
|
-
logger$
|
|
12389
|
+
logger$15.debug(event, {
|
|
12388
12390
|
channel: this.channelName,
|
|
12389
12391
|
connector_id: this.connectorId,
|
|
12390
12392
|
connector_state: this.state,
|
|
@@ -12400,7 +12402,7 @@ let BroadcastChannelConnector$2 = class BroadcastChannelConnector extends BaseAs
|
|
|
12400
12402
|
await super.start(inboundHandler);
|
|
12401
12403
|
// After transitioning to STARTED, check if tab is already hidden
|
|
12402
12404
|
if (typeof document !== 'undefined' && document.hidden) {
|
|
12403
|
-
logger$
|
|
12405
|
+
logger$15.debug('broadcast_channel_start_in_hidden_tab', {
|
|
12404
12406
|
channel: this.channelName,
|
|
12405
12407
|
connector_id: this.connectorId,
|
|
12406
12408
|
document_hidden: document.hidden,
|
|
@@ -12410,7 +12412,7 @@ let BroadcastChannelConnector$2 = class BroadcastChannelConnector extends BaseAs
|
|
|
12410
12412
|
});
|
|
12411
12413
|
// Immediately pause if tab is hidden at start time
|
|
12412
12414
|
await this.pause().catch((err) => {
|
|
12413
|
-
logger$
|
|
12415
|
+
logger$15.warning('broadcast_channel_initial_pause_failed', {
|
|
12414
12416
|
channel: this.channelName,
|
|
12415
12417
|
connector_id: this.connectorId,
|
|
12416
12418
|
error: err instanceof Error ? err.message : String(err),
|
|
@@ -12428,7 +12430,7 @@ let BroadcastChannelConnector$2 = class BroadcastChannelConnector extends BaseAs
|
|
|
12428
12430
|
return;
|
|
12429
12431
|
}
|
|
12430
12432
|
this.targetNodeId = normalized;
|
|
12431
|
-
logger$
|
|
12433
|
+
logger$15.debug('broadcast_channel_target_updated', {
|
|
12432
12434
|
channel: this.channelName,
|
|
12433
12435
|
connector_id: this.connectorId,
|
|
12434
12436
|
local_node_id: this.localNodeId,
|
|
@@ -12438,7 +12440,7 @@ let BroadcastChannelConnector$2 = class BroadcastChannelConnector extends BaseAs
|
|
|
12438
12440
|
}
|
|
12439
12441
|
setWildcardTarget() {
|
|
12440
12442
|
this.targetNodeId = '*';
|
|
12441
|
-
logger$
|
|
12443
|
+
logger$15.debug('broadcast_channel_target_updated', {
|
|
12442
12444
|
channel: this.channelName,
|
|
12443
12445
|
connector_id: this.connectorId,
|
|
12444
12446
|
local_node_id: this.localNodeId,
|
|
@@ -12566,7 +12568,7 @@ function broadcastChannelGrantToConnectorConfig(grant) {
|
|
|
12566
12568
|
return config;
|
|
12567
12569
|
}
|
|
12568
12570
|
|
|
12569
|
-
const logger$
|
|
12571
|
+
const logger$14 = getLogger('naylence.fame.node.upstream_session_manager');
|
|
12570
12572
|
function isPlainRecord$4(value) {
|
|
12571
12573
|
if (typeof value !== 'object' || value === null) {
|
|
12572
12574
|
return false;
|
|
@@ -12639,6 +12641,7 @@ function normalizeOptions$k(options) {
|
|
|
12639
12641
|
const onEpochChangeValue = pickOption$2(record, 'onEpochChange', 'on_epoch_change');
|
|
12640
12642
|
const onEpochChange = typeof onEpochChangeValue === 'function' ? onEpochChangeValue : undefined;
|
|
12641
12643
|
const admissionClient = pickOption$2(record, 'admissionClient', 'admission_client');
|
|
12644
|
+
const retryPolicy = pickOption$2(record, 'retryPolicy', 'retry_policy');
|
|
12642
12645
|
return {
|
|
12643
12646
|
node,
|
|
12644
12647
|
attachClient,
|
|
@@ -12650,6 +12653,7 @@ function normalizeOptions$k(options) {
|
|
|
12650
12653
|
onAttach: validatedOnAttach,
|
|
12651
12654
|
onEpochChange,
|
|
12652
12655
|
admissionClient: admissionClient ?? undefined,
|
|
12656
|
+
retryPolicy: retryPolicy ?? undefined,
|
|
12653
12657
|
};
|
|
12654
12658
|
}
|
|
12655
12659
|
class UpstreamSessionManager extends TaskSpawner {
|
|
@@ -12669,6 +12673,7 @@ class UpstreamSessionManager extends TaskSpawner {
|
|
|
12669
12673
|
this.hadSuccessfulAttach = false;
|
|
12670
12674
|
this.lastConnectorState = null;
|
|
12671
12675
|
this.connectEpoch = 0;
|
|
12676
|
+
this.initialAttempts = 0;
|
|
12672
12677
|
this._visibilityHandler = null;
|
|
12673
12678
|
const options = normalizeOptions$k(optionsInput);
|
|
12674
12679
|
this.node = options.node;
|
|
@@ -12682,31 +12687,34 @@ class UpstreamSessionManager extends TaskSpawner {
|
|
|
12682
12687
|
this.admissionClient =
|
|
12683
12688
|
options.admissionClient ?? options.node.admissionClient;
|
|
12684
12689
|
this.wrappedHandler = this.makeHeartbeatEnabledHandler(options.inboundHandler);
|
|
12685
|
-
|
|
12690
|
+
// Store the connection retry policy (can be null, in which case default behavior applies)
|
|
12691
|
+
this.connectionRetryPolicy = options.retryPolicy ?? null;
|
|
12692
|
+
logger$14.debug('created_upstream_session_manager', {
|
|
12686
12693
|
target_system_id: this.targetSystemId,
|
|
12694
|
+
has_retry_policy: this.connectionRetryPolicy !== null,
|
|
12687
12695
|
});
|
|
12688
12696
|
}
|
|
12689
12697
|
get systemId() {
|
|
12690
12698
|
return this.targetSystemId;
|
|
12691
12699
|
}
|
|
12692
12700
|
setupVisibilityListener() {
|
|
12693
|
-
logger$
|
|
12701
|
+
logger$14.debug('setup_visibility_listener_called', {
|
|
12694
12702
|
has_document: typeof document !== 'undefined',
|
|
12695
12703
|
});
|
|
12696
12704
|
if (typeof document !== 'undefined' && document.addEventListener) {
|
|
12697
12705
|
this._visibilityHandler = () => {
|
|
12698
|
-
logger$
|
|
12706
|
+
logger$14.debug('visibility_change_event_fired', {
|
|
12699
12707
|
state: document.visibilityState,
|
|
12700
12708
|
});
|
|
12701
12709
|
if (document.visibilityState === 'visible') {
|
|
12702
|
-
logger$
|
|
12710
|
+
logger$14.debug('visibility_change_detected_waking_up');
|
|
12703
12711
|
this.wakeEvent.set();
|
|
12704
12712
|
}
|
|
12705
12713
|
};
|
|
12706
12714
|
document.addEventListener('visibilitychange', this._visibilityHandler);
|
|
12707
12715
|
}
|
|
12708
12716
|
else {
|
|
12709
|
-
logger$
|
|
12717
|
+
logger$14.debug('setup_visibility_listener_skipped_no_document');
|
|
12710
12718
|
}
|
|
12711
12719
|
}
|
|
12712
12720
|
teardownVisibilityListener() {
|
|
@@ -12739,13 +12747,13 @@ class UpstreamSessionManager extends TaskSpawner {
|
|
|
12739
12747
|
}
|
|
12740
12748
|
throw new FameConnectError('Upstream session manager failed to attach');
|
|
12741
12749
|
}
|
|
12742
|
-
logger$
|
|
12750
|
+
logger$14.debug('upstream_session_manager_started');
|
|
12743
12751
|
}
|
|
12744
12752
|
getActiveConnector() {
|
|
12745
12753
|
return this.connector;
|
|
12746
12754
|
}
|
|
12747
12755
|
async stop() {
|
|
12748
|
-
logger$
|
|
12756
|
+
logger$14.debug('upstream_session_manager_stopping');
|
|
12749
12757
|
this.teardownVisibilityListener();
|
|
12750
12758
|
this.stopEvent.set();
|
|
12751
12759
|
this.currentStopSubtasks?.set();
|
|
@@ -12756,7 +12764,7 @@ class UpstreamSessionManager extends TaskSpawner {
|
|
|
12756
12764
|
}
|
|
12757
12765
|
catch (error) {
|
|
12758
12766
|
if (!(error instanceof TaskCancelledError)) {
|
|
12759
|
-
logger$
|
|
12767
|
+
logger$14.debug('fsm_task_stopped_with_error', {
|
|
12760
12768
|
error: error.message,
|
|
12761
12769
|
});
|
|
12762
12770
|
}
|
|
@@ -12765,13 +12773,13 @@ class UpstreamSessionManager extends TaskSpawner {
|
|
|
12765
12773
|
}
|
|
12766
12774
|
if (this.connector) {
|
|
12767
12775
|
await this.connector.stop().catch((error) => {
|
|
12768
|
-
logger$
|
|
12776
|
+
logger$14.debug('connector_stop_error', {
|
|
12769
12777
|
error: error.message,
|
|
12770
12778
|
});
|
|
12771
12779
|
});
|
|
12772
12780
|
this.connector = null;
|
|
12773
12781
|
}
|
|
12774
|
-
logger$
|
|
12782
|
+
logger$14.debug('upstream_session_manager_stopped');
|
|
12775
12783
|
}
|
|
12776
12784
|
async send(envelope) {
|
|
12777
12785
|
if (this.messageQueue.length >= UpstreamSessionManager.TX_QUEUE_MAX) {
|
|
@@ -12799,11 +12807,14 @@ class UpstreamSessionManager extends TaskSpawner {
|
|
|
12799
12807
|
}
|
|
12800
12808
|
async fsmLoop() {
|
|
12801
12809
|
let delay = UpstreamSessionManager.BACKOFF_INITIAL;
|
|
12810
|
+
this.initialAttempts = 0;
|
|
12802
12811
|
while (!this.stopEvent.isSet()) {
|
|
12803
12812
|
const startTime = Date.now();
|
|
12813
|
+
this.initialAttempts += 1;
|
|
12804
12814
|
try {
|
|
12805
12815
|
await this.connectCycle();
|
|
12806
12816
|
delay = UpstreamSessionManager.BACKOFF_INITIAL;
|
|
12817
|
+
this.initialAttempts = 0; // Reset on success
|
|
12807
12818
|
}
|
|
12808
12819
|
catch (error) {
|
|
12809
12820
|
// Reset backoff if the connection was alive for more than 10 seconds
|
|
@@ -12813,32 +12824,38 @@ class UpstreamSessionManager extends TaskSpawner {
|
|
|
12813
12824
|
if (error instanceof TaskCancelledError) {
|
|
12814
12825
|
throw error;
|
|
12815
12826
|
}
|
|
12827
|
+
// Determine if we should fail-fast or retry
|
|
12828
|
+
const shouldFailFast = this.shouldFailFastOnError(error);
|
|
12816
12829
|
if (error instanceof FameTransportClose ||
|
|
12817
12830
|
error instanceof FameConnectError) {
|
|
12818
|
-
logger$
|
|
12831
|
+
logger$14.warning('upstream_link_closed', {
|
|
12819
12832
|
error: error.message,
|
|
12820
|
-
will_retry:
|
|
12833
|
+
will_retry: !shouldFailFast,
|
|
12834
|
+
attempt: this.initialAttempts,
|
|
12835
|
+
has_retry_policy: this.connectionRetryPolicy !== null,
|
|
12821
12836
|
});
|
|
12822
|
-
if (
|
|
12837
|
+
if (shouldFailFast && error instanceof FameConnectError) {
|
|
12823
12838
|
throw error;
|
|
12824
12839
|
}
|
|
12825
12840
|
}
|
|
12826
12841
|
else {
|
|
12827
12842
|
const err = error;
|
|
12828
12843
|
if (err.name === 'OAuth2PkceRedirectInitiatedError') {
|
|
12829
|
-
logger$
|
|
12844
|
+
logger$14.info('upstream_link_redirecting', {
|
|
12830
12845
|
error: err.message,
|
|
12831
12846
|
will_retry: true,
|
|
12832
12847
|
});
|
|
12833
12848
|
}
|
|
12834
12849
|
else {
|
|
12835
|
-
logger$
|
|
12850
|
+
logger$14.warning('upstream_link_closed', {
|
|
12836
12851
|
error: err.message,
|
|
12837
|
-
will_retry:
|
|
12852
|
+
will_retry: !shouldFailFast,
|
|
12853
|
+
attempt: this.initialAttempts,
|
|
12854
|
+
has_retry_policy: this.connectionRetryPolicy !== null,
|
|
12838
12855
|
exc_info: true,
|
|
12839
12856
|
});
|
|
12840
12857
|
}
|
|
12841
|
-
if (
|
|
12858
|
+
if (shouldFailFast) {
|
|
12842
12859
|
throw error;
|
|
12843
12860
|
}
|
|
12844
12861
|
}
|
|
@@ -12846,52 +12863,77 @@ class UpstreamSessionManager extends TaskSpawner {
|
|
|
12846
12863
|
}
|
|
12847
12864
|
}
|
|
12848
12865
|
}
|
|
12866
|
+
/**
|
|
12867
|
+
* Determine whether to fail immediately or continue retrying.
|
|
12868
|
+
* Returns true if we should throw the error instead of retrying.
|
|
12869
|
+
*/
|
|
12870
|
+
shouldFailFastOnError(error) {
|
|
12871
|
+
// If no policy is configured, use legacy behavior (fail-fast after first attempt)
|
|
12872
|
+
if (!this.connectionRetryPolicy) {
|
|
12873
|
+
// After first successful attach, always retry (existing behavior)
|
|
12874
|
+
if (this.hadSuccessfulAttach) {
|
|
12875
|
+
return false;
|
|
12876
|
+
}
|
|
12877
|
+
// Without a policy, fail on first error
|
|
12878
|
+
return true;
|
|
12879
|
+
}
|
|
12880
|
+
// Delegate decision to the policy
|
|
12881
|
+
const shouldRetry = this.connectionRetryPolicy.shouldRetry({
|
|
12882
|
+
hadSuccessfulAttach: this.hadSuccessfulAttach,
|
|
12883
|
+
attemptNumber: this.initialAttempts,
|
|
12884
|
+
error,
|
|
12885
|
+
});
|
|
12886
|
+
return !shouldRetry;
|
|
12887
|
+
}
|
|
12849
12888
|
async applyBackoff(delay) {
|
|
12850
12889
|
const jitter = Math.random() * delay;
|
|
12851
|
-
await this.sleepWithStop(delay + jitter);
|
|
12890
|
+
const wasWoken = await this.sleepWithStop(delay + jitter);
|
|
12891
|
+
// If sleep was interrupted by visibility change (user returned to tab),
|
|
12892
|
+
// reset backoff to initial delay for immediate retry with fresh backoff
|
|
12893
|
+
if (wasWoken) {
|
|
12894
|
+
logger$14.debug('backoff_reset_on_visibility_change', {
|
|
12895
|
+
previous_delay: delay,
|
|
12896
|
+
new_delay: UpstreamSessionManager.BACKOFF_INITIAL,
|
|
12897
|
+
});
|
|
12898
|
+
return UpstreamSessionManager.BACKOFF_INITIAL;
|
|
12899
|
+
}
|
|
12852
12900
|
return Math.min(delay * 2, UpstreamSessionManager.BACKOFF_CAP);
|
|
12853
12901
|
}
|
|
12902
|
+
/**
|
|
12903
|
+
* Sleep for the specified duration, but can be interrupted by stop or wake events.
|
|
12904
|
+
* @returns true if interrupted by wake event (e.g., visibility change), false otherwise
|
|
12905
|
+
*/
|
|
12854
12906
|
async sleepWithStop(delaySeconds) {
|
|
12855
12907
|
if (delaySeconds <= 0) {
|
|
12856
|
-
return;
|
|
12857
|
-
}
|
|
12858
|
-
// If the document is visible, cap the backoff delay to improve UX
|
|
12859
|
-
// This ensures that if the user is watching, we retry quickly (e.g. 1s)
|
|
12860
|
-
// instead of waiting for the full exponential backoff (up to 30s).
|
|
12861
|
-
let effectiveDelay = delaySeconds;
|
|
12862
|
-
if (typeof document !== 'undefined' &&
|
|
12863
|
-
document.visibilityState === 'visible') {
|
|
12864
|
-
effectiveDelay = Math.min(delaySeconds, 1.0);
|
|
12865
|
-
if (effectiveDelay < delaySeconds) {
|
|
12866
|
-
logger$13.debug('sleep_reduced_document_visible', {
|
|
12867
|
-
original: delaySeconds,
|
|
12868
|
-
new: effectiveDelay,
|
|
12869
|
-
});
|
|
12870
|
-
}
|
|
12908
|
+
return false;
|
|
12871
12909
|
}
|
|
12910
|
+
// Check if wake event is already set (e.g., visibility just changed)
|
|
12872
12911
|
if (this.wakeEvent.isSet()) {
|
|
12873
12912
|
this.wakeEvent.clear();
|
|
12874
|
-
|
|
12913
|
+
logger$14.debug('sleep_skipped_wake_event_pending');
|
|
12914
|
+
return true;
|
|
12875
12915
|
}
|
|
12876
12916
|
let timeout;
|
|
12877
12917
|
const sleepPromise = new Promise((resolve) => {
|
|
12878
12918
|
timeout = setTimeout(() => {
|
|
12879
12919
|
timeout = undefined;
|
|
12880
12920
|
resolve();
|
|
12881
|
-
},
|
|
12921
|
+
}, delaySeconds * 1000);
|
|
12882
12922
|
});
|
|
12883
12923
|
await Promise.race([
|
|
12884
12924
|
sleepPromise,
|
|
12885
12925
|
this.stopEvent.wait(),
|
|
12886
12926
|
this.wakeEvent.wait(),
|
|
12887
12927
|
]);
|
|
12888
|
-
|
|
12889
|
-
|
|
12928
|
+
const wasWoken = this.wakeEvent.isSet();
|
|
12929
|
+
if (wasWoken) {
|
|
12930
|
+
logger$14.debug('sleep_interrupted_by_wake_event');
|
|
12890
12931
|
this.wakeEvent.clear();
|
|
12891
12932
|
}
|
|
12892
12933
|
if (timeout !== undefined) {
|
|
12893
12934
|
clearTimeout(timeout);
|
|
12894
12935
|
}
|
|
12936
|
+
return wasWoken;
|
|
12895
12937
|
}
|
|
12896
12938
|
getNodeAttachGrant(connectionGrants) {
|
|
12897
12939
|
if (!connectionGrants) {
|
|
@@ -12948,7 +12990,7 @@ class UpstreamSessionManager extends TaskSpawner {
|
|
|
12948
12990
|
await connector.start(this.wrappedHandler);
|
|
12949
12991
|
this.connector = connector;
|
|
12950
12992
|
const callbackGrants = this.node.gatherSupportedCallbackGrants();
|
|
12951
|
-
logger$
|
|
12993
|
+
logger$14.debug('callback_grants_before_augmentation', {
|
|
12952
12994
|
count: callbackGrants.length,
|
|
12953
12995
|
types: callbackGrants.map((g) => g.type),
|
|
12954
12996
|
});
|
|
@@ -12958,7 +13000,7 @@ class UpstreamSessionManager extends TaskSpawner {
|
|
|
12958
13000
|
const broadcastCallbackGrant = shouldAddBroadcastGrant
|
|
12959
13001
|
? this.createBroadcastCallbackGrant(grant)
|
|
12960
13002
|
: null;
|
|
12961
|
-
logger$
|
|
13003
|
+
logger$14.debug('broadcast_callback_grant_check', {
|
|
12962
13004
|
should_add: shouldAddBroadcastGrant,
|
|
12963
13005
|
grant_created: !!broadcastCallbackGrant,
|
|
12964
13006
|
});
|
|
@@ -12977,12 +13019,12 @@ class UpstreamSessionManager extends TaskSpawner {
|
|
|
12977
13019
|
const isDuplicate = callbackGrants.some((existing) => JSON.stringify(existing) === JSON.stringify(grant));
|
|
12978
13020
|
if (!isDuplicate) {
|
|
12979
13021
|
callbackGrants.push(grant);
|
|
12980
|
-
logger$
|
|
13022
|
+
logger$14.debug('added_connection_grant_as_callback', {
|
|
12981
13023
|
type: grant.type,
|
|
12982
13024
|
});
|
|
12983
13025
|
}
|
|
12984
13026
|
else {
|
|
12985
|
-
logger$
|
|
13027
|
+
logger$14.debug('skipped_duplicate_connection_grant', {
|
|
12986
13028
|
type: grant.type,
|
|
12987
13029
|
});
|
|
12988
13030
|
}
|
|
@@ -12994,12 +13036,12 @@ class UpstreamSessionManager extends TaskSpawner {
|
|
|
12994
13036
|
if (broadcastCallbackGrant &&
|
|
12995
13037
|
this.shouldAdvertiseBroadcastGrant(grant, callbackGrants)) {
|
|
12996
13038
|
callbackGrants.push(broadcastCallbackGrant);
|
|
12997
|
-
logger$
|
|
13039
|
+
logger$14.debug('added_broadcast_callback_grant');
|
|
12998
13040
|
}
|
|
12999
13041
|
else if (broadcastCallbackGrant) {
|
|
13000
|
-
logger$
|
|
13042
|
+
logger$14.debug('skipped_duplicate_broadcast_callback_grant');
|
|
13001
13043
|
}
|
|
13002
|
-
logger$
|
|
13044
|
+
logger$14.debug('callback_grants_after_augmentation', {
|
|
13003
13045
|
count: callbackGrants.length,
|
|
13004
13046
|
types: callbackGrants.map((g) => g.type),
|
|
13005
13047
|
});
|
|
@@ -13012,7 +13054,7 @@ class UpstreamSessionManager extends TaskSpawner {
|
|
|
13012
13054
|
targetAware.setTargetNodeId(this.targetSystemId);
|
|
13013
13055
|
}
|
|
13014
13056
|
catch (error) {
|
|
13015
|
-
logger$
|
|
13057
|
+
logger$14.warning('broadcast_channel_target_apply_failed', {
|
|
13016
13058
|
error: error instanceof Error ? error.message : String(error),
|
|
13017
13059
|
target_node_id: this.targetSystemId,
|
|
13018
13060
|
});
|
|
@@ -13034,14 +13076,14 @@ class UpstreamSessionManager extends TaskSpawner {
|
|
|
13034
13076
|
});
|
|
13035
13077
|
}
|
|
13036
13078
|
else {
|
|
13037
|
-
logger$
|
|
13079
|
+
logger$14.warning('parent_epoch_changed', { epoch });
|
|
13038
13080
|
}
|
|
13039
13081
|
}
|
|
13040
13082
|
if (!this.readyEvent.isSet()) {
|
|
13041
13083
|
this.readyEvent.set();
|
|
13042
13084
|
}
|
|
13043
13085
|
if (this.messageQueue.length > 0) {
|
|
13044
|
-
logger$
|
|
13086
|
+
logger$14.debug('flushing_buffered_frames', {
|
|
13045
13087
|
queue_size: this.messageQueue.length,
|
|
13046
13088
|
});
|
|
13047
13089
|
this.queueEvent.set();
|
|
@@ -13058,12 +13100,12 @@ class UpstreamSessionManager extends TaskSpawner {
|
|
|
13058
13100
|
name: `expiry-guard-${this.connectEpoch}`,
|
|
13059
13101
|
});
|
|
13060
13102
|
if (this.hadSuccessfulAttach) {
|
|
13061
|
-
logger$
|
|
13103
|
+
logger$14.debug('reconnected_to_upstream', {
|
|
13062
13104
|
attach_expires_at: attachInfo.attachExpiresAt?.toISOString?.() ?? null,
|
|
13063
13105
|
});
|
|
13064
13106
|
}
|
|
13065
13107
|
else {
|
|
13066
|
-
logger$
|
|
13108
|
+
logger$14.debug('connected_to_upstream', {
|
|
13067
13109
|
attach_expires_at: attachInfo.attachExpiresAt?.toISOString?.() ?? null,
|
|
13068
13110
|
});
|
|
13069
13111
|
}
|
|
@@ -13081,18 +13123,18 @@ class UpstreamSessionManager extends TaskSpawner {
|
|
|
13081
13123
|
this.currentStopSubtasks = null;
|
|
13082
13124
|
await Promise.allSettled(tasks.map((task) => task.promise));
|
|
13083
13125
|
if (this.connector) {
|
|
13084
|
-
logger$
|
|
13126
|
+
logger$14.debug('upstream_stopping_old_connector', {
|
|
13085
13127
|
connect_epoch: this.connectEpoch,
|
|
13086
13128
|
target_system_id: this.targetSystemId,
|
|
13087
13129
|
timestamp: new Date().toISOString(),
|
|
13088
13130
|
});
|
|
13089
13131
|
await this.connector.stop().catch((err) => {
|
|
13090
|
-
logger$
|
|
13132
|
+
logger$14.warning('upstream_connector_stop_error', {
|
|
13091
13133
|
connect_epoch: this.connectEpoch,
|
|
13092
13134
|
error: err instanceof Error ? err.message : String(err),
|
|
13093
13135
|
});
|
|
13094
13136
|
});
|
|
13095
|
-
logger$
|
|
13137
|
+
logger$14.debug('upstream_old_connector_stopped', {
|
|
13096
13138
|
connect_epoch: this.connectEpoch,
|
|
13097
13139
|
target_system_id: this.targetSystemId,
|
|
13098
13140
|
timestamp: new Date().toISOString(),
|
|
@@ -13145,7 +13187,7 @@ class UpstreamSessionManager extends TaskSpawner {
|
|
|
13145
13187
|
});
|
|
13146
13188
|
}
|
|
13147
13189
|
catch (error) {
|
|
13148
|
-
logger$
|
|
13190
|
+
logger$14.debug('broadcast_callback_grant_generation_failed', {
|
|
13149
13191
|
error: error instanceof Error ? error.message : String(error),
|
|
13150
13192
|
});
|
|
13151
13193
|
return null;
|
|
@@ -13200,7 +13242,7 @@ class UpstreamSessionManager extends TaskSpawner {
|
|
|
13200
13242
|
}
|
|
13201
13243
|
}
|
|
13202
13244
|
async heartbeatLoop(connector, stopEvt, signal) {
|
|
13203
|
-
logger$
|
|
13245
|
+
logger$14.debug('starting_heartbeat_loop');
|
|
13204
13246
|
const intervalMs = UpstreamSessionManager.HEARTBEAT_INTERVAL * 1000;
|
|
13205
13247
|
const graceMs = intervalMs * UpstreamSessionManager.HEARTBEAT_GRACE;
|
|
13206
13248
|
this.lastHeartbeatAckTime = Date.now();
|
|
@@ -13236,7 +13278,7 @@ class UpstreamSessionManager extends TaskSpawner {
|
|
|
13236
13278
|
// Skip heartbeat if connector is paused (e.g., tab is hidden)
|
|
13237
13279
|
// Keep ack time current so we don't timeout immediately after resuming
|
|
13238
13280
|
if (currentState === core.ConnectorState.PAUSED) {
|
|
13239
|
-
logger$
|
|
13281
|
+
logger$14.debug('skipping_heartbeat_connector_paused', {
|
|
13240
13282
|
connector_state: currentState,
|
|
13241
13283
|
});
|
|
13242
13284
|
this.lastHeartbeatAckTime = Date.now();
|
|
@@ -13245,14 +13287,14 @@ class UpstreamSessionManager extends TaskSpawner {
|
|
|
13245
13287
|
// Reset ack time if just resumed from pause (prevents immediate timeout)
|
|
13246
13288
|
if (previousState === core.ConnectorState.PAUSED &&
|
|
13247
13289
|
currentState === core.ConnectorState.STARTED) {
|
|
13248
|
-
logger$
|
|
13290
|
+
logger$14.debug('connector_just_resumed_resetting_ack_time', {
|
|
13249
13291
|
previous_state: previousState,
|
|
13250
13292
|
current_state: currentState,
|
|
13251
13293
|
});
|
|
13252
13294
|
this.lastHeartbeatAckTime = Date.now();
|
|
13253
13295
|
}
|
|
13254
13296
|
const envelope = await this.makeHeartbeatEnvelope();
|
|
13255
|
-
logger$
|
|
13297
|
+
logger$14.debug('sending_heartbeat', {
|
|
13256
13298
|
hb_corr_id: envelope.corrId,
|
|
13257
13299
|
hb_env_id: envelope.id,
|
|
13258
13300
|
});
|
|
@@ -13278,7 +13320,7 @@ class UpstreamSessionManager extends TaskSpawner {
|
|
|
13278
13320
|
throw new FameConnectError('missed heartbeat acknowledgement');
|
|
13279
13321
|
}
|
|
13280
13322
|
}
|
|
13281
|
-
logger$
|
|
13323
|
+
logger$14.debug('completed_heartbeat_loop');
|
|
13282
13324
|
}
|
|
13283
13325
|
async messagePumpLoop(connector, stopEvt, signal) {
|
|
13284
13326
|
while (!stopEvt.isSet() && !signal?.aborted) {
|
|
@@ -13295,19 +13337,19 @@ class UpstreamSessionManager extends TaskSpawner {
|
|
|
13295
13337
|
if (!envelope) {
|
|
13296
13338
|
continue;
|
|
13297
13339
|
}
|
|
13298
|
-
logger$
|
|
13340
|
+
logger$14.debug('upstream_pump_sending_envelope', {
|
|
13299
13341
|
envelopeId: envelope.id,
|
|
13300
13342
|
type: envelope.frame?.type,
|
|
13301
13343
|
});
|
|
13302
13344
|
try {
|
|
13303
13345
|
await connector.send(envelope);
|
|
13304
|
-
logger$
|
|
13346
|
+
logger$14.debug('upstream_pump_sent_envelope', {
|
|
13305
13347
|
envelopeId: envelope.id,
|
|
13306
13348
|
});
|
|
13307
13349
|
}
|
|
13308
13350
|
catch (error) {
|
|
13309
13351
|
if (error instanceof FameMessageTooLarge) {
|
|
13310
|
-
logger$
|
|
13352
|
+
logger$14.error('failed_to_send_message', { error: error.message });
|
|
13311
13353
|
await this.handleMessageTooLarge(envelope, error.message);
|
|
13312
13354
|
}
|
|
13313
13355
|
else if (error instanceof FameTransportClose) {
|
|
@@ -13369,7 +13411,7 @@ class UpstreamSessionManager extends TaskSpawner {
|
|
|
13369
13411
|
await fabric.send(ackEnvelope);
|
|
13370
13412
|
}
|
|
13371
13413
|
catch (error) {
|
|
13372
|
-
logger$
|
|
13414
|
+
logger$14.warning('failed_to_send_nack', {
|
|
13373
13415
|
error: error.message,
|
|
13374
13416
|
});
|
|
13375
13417
|
}
|
|
@@ -13383,7 +13425,7 @@ class UpstreamSessionManager extends TaskSpawner {
|
|
|
13383
13425
|
timestamps.push(info.attachExpiresAt);
|
|
13384
13426
|
}
|
|
13385
13427
|
if (!timestamps.length) {
|
|
13386
|
-
logger$
|
|
13428
|
+
logger$14.debug('no_ttl_expiry_configured');
|
|
13387
13429
|
await this.waitEvent(stopEvt, signal);
|
|
13388
13430
|
return;
|
|
13389
13431
|
}
|
|
@@ -13392,7 +13434,7 @@ class UpstreamSessionManager extends TaskSpawner {
|
|
|
13392
13434
|
let delaySeconds = (earliest.getTime() - now.getTime()) / 1000 -
|
|
13393
13435
|
UpstreamSessionManager.JWT_REFRESH_SAFETY;
|
|
13394
13436
|
delaySeconds = Math.max(delaySeconds, UpstreamSessionManager.JWT_REFRESH_SAFETY);
|
|
13395
|
-
logger$
|
|
13437
|
+
logger$14.debug('ttl_expiry_guard_started', {
|
|
13396
13438
|
welcome_expires_at: welcome.frame.expiresAt ?? null,
|
|
13397
13439
|
attach_expires_at: info.attachExpiresAt?.toISOString?.() ?? null,
|
|
13398
13440
|
earliest_expiry: earliest.toISOString(),
|
|
@@ -13420,7 +13462,7 @@ class UpstreamSessionManager extends TaskSpawner {
|
|
|
13420
13462
|
}
|
|
13421
13463
|
}
|
|
13422
13464
|
if (!stopEvt.isSet()) {
|
|
13423
|
-
logger$
|
|
13465
|
+
logger$14.debug('ttl_expiry_triggered_reconnect', {
|
|
13424
13466
|
expires_at: earliest.toISOString(),
|
|
13425
13467
|
current_time: new Date().toISOString(),
|
|
13426
13468
|
seconds_before_expiry: UpstreamSessionManager.JWT_REFRESH_SAFETY,
|
|
@@ -13465,7 +13507,7 @@ class UpstreamSessionManager extends TaskSpawner {
|
|
|
13465
13507
|
}
|
|
13466
13508
|
await this.node.dispatchEnvelopeEvent('onEnvelopeReceived', this.node, env, context);
|
|
13467
13509
|
if (env.frame.type === 'NodeHeartbeatAck') {
|
|
13468
|
-
logger$
|
|
13510
|
+
logger$14.debug('received_heartbeat_ack', {
|
|
13469
13511
|
hb_ack_env_id: env.id,
|
|
13470
13512
|
hb_ack_corr_id: env.corrId,
|
|
13471
13513
|
hb_routing_epoch: env.frame.routingEpoch,
|
|
@@ -13479,7 +13521,7 @@ class UpstreamSessionManager extends TaskSpawner {
|
|
|
13479
13521
|
await this.onEpochChange(epoch);
|
|
13480
13522
|
}
|
|
13481
13523
|
else {
|
|
13482
|
-
logger$
|
|
13524
|
+
logger$14.warning('parent_epoch_changed', { epoch });
|
|
13483
13525
|
}
|
|
13484
13526
|
}
|
|
13485
13527
|
return;
|
|
@@ -13498,7 +13540,7 @@ UpstreamSessionManager.TX_QUEUE_MAX = 512;
|
|
|
13498
13540
|
UpstreamSessionManager.BACKOFF_INITIAL = 1; // seconds
|
|
13499
13541
|
UpstreamSessionManager.BACKOFF_CAP = 30; // seconds
|
|
13500
13542
|
|
|
13501
|
-
const logger$
|
|
13543
|
+
const logger$13 = getLogger('naylence.fame.node.admission.noop_admission_client');
|
|
13502
13544
|
class NoopAdmissionClient {
|
|
13503
13545
|
constructor(options = {}) {
|
|
13504
13546
|
this.hasUpstream = false;
|
|
@@ -13512,7 +13554,7 @@ class NoopAdmissionClient {
|
|
|
13512
13554
|
const acceptedLogicals = this.autoAcceptLogicals
|
|
13513
13555
|
? [...(requestedLogicals ?? [])]
|
|
13514
13556
|
: [];
|
|
13515
|
-
logger$
|
|
13557
|
+
logger$13.debug('noop_admission_hello', {
|
|
13516
13558
|
systemId: effectiveSystemId,
|
|
13517
13559
|
instanceId,
|
|
13518
13560
|
requestedLogicals,
|
|
@@ -13530,7 +13572,7 @@ class NoopAdmissionClient {
|
|
|
13530
13572
|
});
|
|
13531
13573
|
}
|
|
13532
13574
|
async close() {
|
|
13533
|
-
logger$
|
|
13575
|
+
logger$13.debug('noop_admission_close');
|
|
13534
13576
|
}
|
|
13535
13577
|
}
|
|
13536
13578
|
|
|
@@ -13736,7 +13778,7 @@ class DefaultServiceManager {
|
|
|
13736
13778
|
}
|
|
13737
13779
|
|
|
13738
13780
|
const SYSTEM_INBOX$1 = '__sys__';
|
|
13739
|
-
const logger$
|
|
13781
|
+
const logger$12 = getLogger('naylence.fame.node.node');
|
|
13740
13782
|
function isSnakeCase(name) {
|
|
13741
13783
|
return name.includes('_');
|
|
13742
13784
|
}
|
|
@@ -13863,6 +13905,8 @@ class FameNode extends TaskSpawner {
|
|
|
13863
13905
|
this._acceptedLogicals = new Set(acceptedLogicalsOption);
|
|
13864
13906
|
const deliveryPolicyOption = resolveOption(options, 'deliveryPolicy', 'delivery_policy');
|
|
13865
13907
|
this._deliveryPolicy = deliveryPolicyOption ?? null;
|
|
13908
|
+
const connectionRetryPolicyOption = resolveOption(options, 'connectionRetryPolicy', 'connection_retry_policy');
|
|
13909
|
+
this._connectionRetryPolicy = connectionRetryPolicyOption ?? null;
|
|
13866
13910
|
const admissionClientOption = resolveOption(options, 'admissionClient', 'admission_client');
|
|
13867
13911
|
this._admissionClient = admissionClientOption ?? null;
|
|
13868
13912
|
const attachClientOption = resolveOption(options, 'attachClient', 'attach_client');
|
|
@@ -13992,6 +14036,7 @@ class FameNode extends TaskSpawner {
|
|
|
13992
14036
|
onAttach: (info, connector) => this.handleAttach(info, connector),
|
|
13993
14037
|
onEpochChange: (epoch) => this.handleEpochChange(epoch),
|
|
13994
14038
|
admissionClient: this._admissionClient,
|
|
14039
|
+
retryPolicy: this._connectionRetryPolicy,
|
|
13995
14040
|
});
|
|
13996
14041
|
this._sessionManager = manager;
|
|
13997
14042
|
await manager.start();
|
|
@@ -14003,7 +14048,7 @@ class FameNode extends TaskSpawner {
|
|
|
14003
14048
|
confirmIdentity(systemId, source) {
|
|
14004
14049
|
if (this._confirmedId) {
|
|
14005
14050
|
if (this._confirmedId !== systemId) {
|
|
14006
|
-
logger$
|
|
14051
|
+
logger$12.error('node_identity_mismatch', {
|
|
14007
14052
|
current_id: this._confirmedId,
|
|
14008
14053
|
new_id: systemId,
|
|
14009
14054
|
source,
|
|
@@ -14015,14 +14060,14 @@ class FameNode extends TaskSpawner {
|
|
|
14015
14060
|
const isReassignment = this._provisionalId !== systemId;
|
|
14016
14061
|
this._confirmedId = systemId;
|
|
14017
14062
|
if (isReassignment) {
|
|
14018
|
-
logger$
|
|
14063
|
+
logger$12.debug('node_identity_reassigned', {
|
|
14019
14064
|
system_id: systemId,
|
|
14020
14065
|
previous_id: this._provisionalId,
|
|
14021
14066
|
source,
|
|
14022
14067
|
});
|
|
14023
14068
|
}
|
|
14024
14069
|
else {
|
|
14025
|
-
logger$
|
|
14070
|
+
logger$12.debug('node_identity_confirmed', {
|
|
14026
14071
|
system_id: systemId,
|
|
14027
14072
|
source,
|
|
14028
14073
|
});
|
|
@@ -14090,7 +14135,7 @@ class FameNode extends TaskSpawner {
|
|
|
14090
14135
|
return;
|
|
14091
14136
|
}
|
|
14092
14137
|
if (frameType === 'NodeHeartbeat') {
|
|
14093
|
-
logger$
|
|
14138
|
+
logger$12.debug('received_heartbeat_frame', {
|
|
14094
14139
|
envelopeId: envelope.id,
|
|
14095
14140
|
corrId: envelope.corrId ?? null,
|
|
14096
14141
|
});
|
|
@@ -14102,7 +14147,7 @@ class FameNode extends TaskSpawner {
|
|
|
14102
14147
|
await this.handleDeliveryAck(envelope, context);
|
|
14103
14148
|
return;
|
|
14104
14149
|
}
|
|
14105
|
-
logger$
|
|
14150
|
+
logger$12.debug('unhandled_system_frame', {
|
|
14106
14151
|
envelopeId: envelope.id,
|
|
14107
14152
|
frameType,
|
|
14108
14153
|
});
|
|
@@ -14114,13 +14159,13 @@ class FameNode extends TaskSpawner {
|
|
|
14114
14159
|
}
|
|
14115
14160
|
await this._deliveryTracker.onEnvelopeDelivered(SYSTEM_INBOX$1, envelope, context);
|
|
14116
14161
|
if (frame.ok !== false) {
|
|
14117
|
-
logger$
|
|
14162
|
+
logger$12.debug('delivery_ack_received', {
|
|
14118
14163
|
envelopeId: envelope.id,
|
|
14119
14164
|
corrId: envelope.corrId ?? null,
|
|
14120
14165
|
});
|
|
14121
14166
|
return;
|
|
14122
14167
|
}
|
|
14123
|
-
logger$
|
|
14168
|
+
logger$12.warning('delivery_nack_received', {
|
|
14124
14169
|
envelopeId: envelope.id,
|
|
14125
14170
|
corrId: envelope.corrId ?? null,
|
|
14126
14171
|
code: frame.code ?? null,
|
|
@@ -14130,7 +14175,7 @@ class FameNode extends TaskSpawner {
|
|
|
14130
14175
|
await this.onDeliveryNack(frame, envelope, context);
|
|
14131
14176
|
}
|
|
14132
14177
|
async onDeliveryNack(frame, envelope, _context) {
|
|
14133
|
-
logger$
|
|
14178
|
+
logger$12.debug('delivery_nack_processed', {
|
|
14134
14179
|
envelopeId: envelope.id,
|
|
14135
14180
|
code: frame.code ?? null,
|
|
14136
14181
|
reason: frame.reason ?? null,
|
|
@@ -14245,7 +14290,7 @@ class FameNode extends TaskSpawner {
|
|
|
14245
14290
|
await this._bindingManager.restore();
|
|
14246
14291
|
await this._envelopeListenerManager.start();
|
|
14247
14292
|
this._isStarted = true;
|
|
14248
|
-
logger$
|
|
14293
|
+
logger$12.debug('node_started', {
|
|
14249
14294
|
node_id: this.id,
|
|
14250
14295
|
sid: this.sid,
|
|
14251
14296
|
path: this.physicalPath,
|
|
@@ -14277,7 +14322,7 @@ class FameNode extends TaskSpawner {
|
|
|
14277
14322
|
await this._serviceManager.stop();
|
|
14278
14323
|
await this.dispatchEvent('onNodeStopped', this);
|
|
14279
14324
|
this._isStarted = false;
|
|
14280
|
-
logger$
|
|
14325
|
+
logger$12.debug('node_stopped', {
|
|
14281
14326
|
node_id: this.id,
|
|
14282
14327
|
});
|
|
14283
14328
|
}
|
|
@@ -14467,20 +14512,20 @@ class FameNode extends TaskSpawner {
|
|
|
14467
14512
|
await this.forwardUpstream(processedEnvelope, context);
|
|
14468
14513
|
}
|
|
14469
14514
|
else {
|
|
14470
|
-
logger$
|
|
14515
|
+
logger$12.error('attempted_upstream_loop', {
|
|
14471
14516
|
envelopeId: processedEnvelope.id,
|
|
14472
14517
|
});
|
|
14473
14518
|
}
|
|
14474
14519
|
return;
|
|
14475
14520
|
}
|
|
14476
14521
|
if (!processedEnvelope.to) {
|
|
14477
|
-
logger$
|
|
14522
|
+
logger$12.error('dropping_envelope_without_destination', {
|
|
14478
14523
|
envelopeId: processedEnvelope.id,
|
|
14479
14524
|
capabilities: processedEnvelope.capabilities ?? [],
|
|
14480
14525
|
});
|
|
14481
14526
|
return;
|
|
14482
14527
|
}
|
|
14483
|
-
logger$
|
|
14528
|
+
logger$12.warning('no_local_handler_for_address', {
|
|
14484
14529
|
address: processedEnvelope.to.toString?.() ?? String(processedEnvelope.to),
|
|
14485
14530
|
originType: context?.originType ?? null,
|
|
14486
14531
|
});
|
|
@@ -14604,7 +14649,7 @@ class FameNode extends TaskSpawner {
|
|
|
14604
14649
|
}
|
|
14605
14650
|
}
|
|
14606
14651
|
catch (error) {
|
|
14607
|
-
logger$
|
|
14652
|
+
logger$12.warning('callback_grant_collection_failed', {
|
|
14608
14653
|
error: error instanceof Error ? error.message : String(error),
|
|
14609
14654
|
});
|
|
14610
14655
|
}
|
|
@@ -14667,7 +14712,7 @@ class FameNode extends TaskSpawner {
|
|
|
14667
14712
|
await store.set('self', record);
|
|
14668
14713
|
}
|
|
14669
14714
|
catch (error) {
|
|
14670
|
-
logger$
|
|
14715
|
+
logger$12.warning('node_meta_persist_failed', {
|
|
14671
14716
|
error: error instanceof Error ? error.message : String(error),
|
|
14672
14717
|
});
|
|
14673
14718
|
}
|
|
@@ -14698,6 +14743,7 @@ const FameNodeConfigSchemaInternal = zod.z
|
|
|
14698
14743
|
telemetry: zod.z.unknown().optional().nullable(),
|
|
14699
14744
|
requestedCapabilities: zod.z.array(zod.z.string()).optional(),
|
|
14700
14745
|
identityPolicy: zod.z.unknown().optional().nullable(),
|
|
14746
|
+
connectionRetryPolicy: zod.z.unknown().optional().nullable(),
|
|
14701
14747
|
})
|
|
14702
14748
|
.passthrough();
|
|
14703
14749
|
function normalizeFameNodeConfig(input) {
|
|
@@ -14739,6 +14785,9 @@ function normalizeFameNodeConfig(input) {
|
|
|
14739
14785
|
identityPolicy: parsed.identityPolicy === undefined
|
|
14740
14786
|
? null
|
|
14741
14787
|
: parsed.identityPolicy,
|
|
14788
|
+
connectionRetryPolicy: parsed.connectionRetryPolicy === undefined
|
|
14789
|
+
? null
|
|
14790
|
+
: parsed.connectionRetryPolicy,
|
|
14742
14791
|
};
|
|
14743
14792
|
if (parsed.requestedCapabilities) {
|
|
14744
14793
|
normalized.requestedCapabilities = coerceStringArray$4(parsed.requestedCapabilities);
|
|
@@ -14783,6 +14832,24 @@ class AdmissionClientFactory extends factory.AbstractResourceFactory {
|
|
|
14783
14832
|
}
|
|
14784
14833
|
}
|
|
14785
14834
|
|
|
14835
|
+
const CONNECTION_RETRY_POLICY_FACTORY_BASE_TYPE = 'ConnectionRetryPolicyFactory';
|
|
14836
|
+
class ConnectionRetryPolicyFactory extends factory.AbstractResourceFactory {
|
|
14837
|
+
static async createConnectionRetryPolicy(config, options = {}) {
|
|
14838
|
+
if (config) {
|
|
14839
|
+
const policy = await factory.createResource(CONNECTION_RETRY_POLICY_FACTORY_BASE_TYPE, config, options);
|
|
14840
|
+
if (!policy) {
|
|
14841
|
+
throw new Error('Failed to create connection retry policy from configuration');
|
|
14842
|
+
}
|
|
14843
|
+
return policy;
|
|
14844
|
+
}
|
|
14845
|
+
const policy = await factory.createDefaultResource(CONNECTION_RETRY_POLICY_FACTORY_BASE_TYPE, null, options);
|
|
14846
|
+
if (!policy) {
|
|
14847
|
+
throw new Error('Failed to create default connection retry policy');
|
|
14848
|
+
}
|
|
14849
|
+
return policy;
|
|
14850
|
+
}
|
|
14851
|
+
}
|
|
14852
|
+
|
|
14786
14853
|
const TOKEN_PROVIDER_FACTORY_BASE_TYPE = 'TokenProviderFactory';
|
|
14787
14854
|
class TokenProviderFactory extends factory.AbstractResourceFactory {
|
|
14788
14855
|
static async createTokenProvider(config, options = {}) {
|
|
@@ -14820,7 +14887,7 @@ function isIdentityExposingTokenProvider(candidate) {
|
|
|
14820
14887
|
'function');
|
|
14821
14888
|
}
|
|
14822
14889
|
|
|
14823
|
-
const logger$
|
|
14890
|
+
const logger$11 = getLogger('naylence.fame.node.default_node_identity_policy');
|
|
14824
14891
|
class DefaultNodeIdentityPolicy {
|
|
14825
14892
|
async resolveInitialNodeId(context) {
|
|
14826
14893
|
if (context.configuredId) {
|
|
@@ -14850,7 +14917,7 @@ class DefaultNodeIdentityPolicy {
|
|
|
14850
14917
|
if (isIdentityExposingTokenProvider(provider)) {
|
|
14851
14918
|
const identity = await provider.getIdentity();
|
|
14852
14919
|
if (identity && identity.subject) {
|
|
14853
|
-
logger$
|
|
14920
|
+
logger$11.debug('identity_extracted_from_grant', {
|
|
14854
14921
|
identity_id: identity.subject,
|
|
14855
14922
|
grant_type: grant.type,
|
|
14856
14923
|
});
|
|
@@ -14859,7 +14926,7 @@ class DefaultNodeIdentityPolicy {
|
|
|
14859
14926
|
}
|
|
14860
14927
|
}
|
|
14861
14928
|
catch (error) {
|
|
14862
|
-
logger$
|
|
14929
|
+
logger$11.warning('identity_extraction_failed', {
|
|
14863
14930
|
error: error instanceof Error ? error.message : String(error),
|
|
14864
14931
|
grant_type: grant.type,
|
|
14865
14932
|
});
|
|
@@ -14943,7 +15010,7 @@ class AttachmentKeyValidator {
|
|
|
14943
15010
|
}
|
|
14944
15011
|
}
|
|
14945
15012
|
|
|
14946
|
-
const logger
|
|
15013
|
+
const logger$10 = getLogger('naylence.fame.node.admission.default_node_attach_client');
|
|
14947
15014
|
const HANDSHAKE_POLL_INTERVAL_MS = 20;
|
|
14948
15015
|
class DefaultNodeAttachClient {
|
|
14949
15016
|
constructor(options = {}) {
|
|
@@ -14967,7 +15034,7 @@ class DefaultNodeAttachClient {
|
|
|
14967
15034
|
}
|
|
14968
15035
|
else {
|
|
14969
15036
|
// Silently ignore frames from other agents during concurrent handshakes
|
|
14970
|
-
logger
|
|
15037
|
+
logger$10.debug('handshake_ignoring_frame_from_different_system', {
|
|
14971
15038
|
frame_type: envelope.frame.type,
|
|
14972
15039
|
frame_system_id: frameSystemId,
|
|
14973
15040
|
expected_system_id: this.expectedSystemId,
|
|
@@ -15010,7 +15077,7 @@ class DefaultNodeAttachClient {
|
|
|
15010
15077
|
}
|
|
15011
15078
|
}
|
|
15012
15079
|
catch (error) {
|
|
15013
|
-
logger
|
|
15080
|
+
logger$10.debug('stickiness_offer_skipped', {
|
|
15014
15081
|
error: error instanceof Error ? error.message : String(error),
|
|
15015
15082
|
});
|
|
15016
15083
|
}
|
|
@@ -15031,7 +15098,7 @@ class DefaultNodeAttachClient {
|
|
|
15031
15098
|
if (!processedEnvelope) {
|
|
15032
15099
|
throw new Error('Envelope was blocked by onForwardUpstream event');
|
|
15033
15100
|
}
|
|
15034
|
-
logger
|
|
15101
|
+
logger$10.debug('sending_node_attach_envelope', {
|
|
15035
15102
|
envp_id: processedEnvelope.id ?? envelope.id ?? null,
|
|
15036
15103
|
frame_type: processedEnvelope.frame?.type ?? 'unknown',
|
|
15037
15104
|
trace_id: processedEnvelope.traceId ?? envelope.traceId ?? null,
|
|
@@ -15067,7 +15134,7 @@ class DefaultNodeAttachClient {
|
|
|
15067
15134
|
try {
|
|
15068
15135
|
const keyInfos = await this.attachmentKeyValidator.validateKeys(parentKeys);
|
|
15069
15136
|
if (Array.isArray(keyInfos) && keyInfos.length > 0) {
|
|
15070
|
-
logger
|
|
15137
|
+
logger$10.debug('parent_certificate_validation_passed', {
|
|
15071
15138
|
parent_id: parentId,
|
|
15072
15139
|
correlation_id: corrId,
|
|
15073
15140
|
validated_keys: keyInfos.length,
|
|
@@ -15076,7 +15143,7 @@ class DefaultNodeAttachClient {
|
|
|
15076
15143
|
}
|
|
15077
15144
|
catch (error) {
|
|
15078
15145
|
if (error instanceof KeyValidationError) {
|
|
15079
|
-
logger
|
|
15146
|
+
logger$10.error('parent_certificate_validation_failed', {
|
|
15080
15147
|
parent_id: parentId,
|
|
15081
15148
|
correlation_id: corrId,
|
|
15082
15149
|
error_code: error.code,
|
|
@@ -15090,12 +15157,12 @@ class DefaultNodeAttachClient {
|
|
|
15090
15157
|
}
|
|
15091
15158
|
}
|
|
15092
15159
|
else {
|
|
15093
|
-
logger
|
|
15160
|
+
logger$10.debug('parent_certificate_validation_skipped', {
|
|
15094
15161
|
parent_id: parentId,
|
|
15095
15162
|
reason: 'no_validator',
|
|
15096
15163
|
});
|
|
15097
15164
|
}
|
|
15098
|
-
logger
|
|
15165
|
+
logger$10.debug('processing_node_attach_ack', {
|
|
15099
15166
|
parent_id: ackFrame.targetSystemId,
|
|
15100
15167
|
});
|
|
15101
15168
|
this.inHandshake = false;
|
|
@@ -15126,7 +15193,7 @@ class DefaultNodeAttachClient {
|
|
|
15126
15193
|
}
|
|
15127
15194
|
}
|
|
15128
15195
|
catch (error) {
|
|
15129
|
-
logger
|
|
15196
|
+
logger$10.debug('stickiness_accept_skipped', {
|
|
15130
15197
|
error: error instanceof Error ? error.message : String(error),
|
|
15131
15198
|
});
|
|
15132
15199
|
}
|
|
@@ -15180,7 +15247,7 @@ class DefaultNodeAttachClient {
|
|
|
15180
15247
|
// NodeAttach frames during handshake are expected in multi-agent scenarios
|
|
15181
15248
|
// where multiple agents attach concurrently to the same channel
|
|
15182
15249
|
if (envelope.frame.type === 'NodeAttach') {
|
|
15183
|
-
logger
|
|
15250
|
+
logger$10.debug('handshake_ignoring_concurrent_attach', {
|
|
15184
15251
|
frame_type: envelope.frame.type,
|
|
15185
15252
|
frame_system_id: envelope.frame?.systemId ??
|
|
15186
15253
|
'unknown',
|
|
@@ -15188,7 +15255,7 @@ class DefaultNodeAttachClient {
|
|
|
15188
15255
|
}
|
|
15189
15256
|
else {
|
|
15190
15257
|
// Other unexpected frames are still logged as errors
|
|
15191
|
-
logger
|
|
15258
|
+
logger$10.error('unexpected_frame_during_handshake', {
|
|
15192
15259
|
frame_type: envelope.frame.type,
|
|
15193
15260
|
});
|
|
15194
15261
|
}
|
|
@@ -15323,7 +15390,7 @@ class TraceEmitterFactory extends factory.AbstractResourceFactory {
|
|
|
15323
15390
|
// void import('./trace-emitter-profile-factory.js');
|
|
15324
15391
|
|
|
15325
15392
|
const BINDING_STORE_NAMESPACE = '__binding_store';
|
|
15326
|
-
const logger
|
|
15393
|
+
const logger$$ = getLogger('naylence.fame.node.factory_commons');
|
|
15327
15394
|
function isPlainRecord$2(value) {
|
|
15328
15395
|
return Boolean(value) && typeof value === 'object' && !Array.isArray(value);
|
|
15329
15396
|
}
|
|
@@ -15430,6 +15497,7 @@ async function makeCommonOptions(config, rawConfig) {
|
|
|
15430
15497
|
const telemetryConfig = pickOption$1(config.telemetry ?? null, aliasRecord, 'trace_emitter', 'telemetry_config');
|
|
15431
15498
|
const securityConfig = pickOption$1(config.security ?? null, aliasRecord, 'security_manager', 'security_profile');
|
|
15432
15499
|
const identityPolicyConfig = pickOption$1(config.identityPolicy ?? null, aliasRecord, 'identity_policy', 'node_identity_policy');
|
|
15500
|
+
const connectionRetryPolicyConfig = pickOption$1(config.connectionRetryPolicy ?? null, aliasRecord, 'connection_retry_policy', 'retry_policy');
|
|
15433
15501
|
const publicUrl = pickString$2(config.publicUrl ?? null, aliasRecord, 'public_url') ?? null;
|
|
15434
15502
|
const directParentUrl = pickString$2(config.directParentUrl ?? null, aliasRecord, 'direct_parent_url') ?? null;
|
|
15435
15503
|
const hasParentFlag = config.hasParent || Boolean(aliasRecord.has_parent ?? false);
|
|
@@ -15439,6 +15507,7 @@ async function makeCommonOptions(config, rawConfig) {
|
|
|
15439
15507
|
const nodeMetaStore = await storageProvider.getKeyValueStore(NodeMetaRecord, NODE_META_NAMESPACE);
|
|
15440
15508
|
const nodeMeta = await nodeMetaStore.get('self');
|
|
15441
15509
|
const identityPolicy = await resolveNodeIdentityPolicy(identityPolicyConfig ?? null, expressionOptions);
|
|
15510
|
+
const connectionRetryPolicy = await resolveConnectionRetryPolicy(connectionRetryPolicyConfig ?? null, expressionOptions);
|
|
15442
15511
|
const admissionClient = await resolveAdmissionClient(admissionConfig ?? null, expressionOptions, identityPolicy ?? undefined);
|
|
15443
15512
|
const hasParent = determineHasParent(hasParentFlag, directParentUrl, admissionClient);
|
|
15444
15513
|
const replicaStickinessManager = await resolveReplicaStickinessManager(hasParent, requestedLogicals, expressionOptions);
|
|
@@ -15507,6 +15576,7 @@ async function makeCommonOptions(config, rawConfig) {
|
|
|
15507
15576
|
transportListeners,
|
|
15508
15577
|
traceEmitter,
|
|
15509
15578
|
identityPolicy: identityPolicy ?? undefined,
|
|
15579
|
+
connectionRetryPolicy: connectionRetryPolicy ?? undefined,
|
|
15510
15580
|
};
|
|
15511
15581
|
}
|
|
15512
15582
|
async function resolveNodeIdentityPolicy(config, options) {
|
|
@@ -15514,7 +15584,18 @@ async function resolveNodeIdentityPolicy(config, options) {
|
|
|
15514
15584
|
return await NodeIdentityPolicyFactory.createNodeIdentityPolicy(config ?? undefined, cloneCreateOptions(options));
|
|
15515
15585
|
}
|
|
15516
15586
|
catch (error) {
|
|
15517
|
-
logger
|
|
15587
|
+
logger$$.warning('node_identity_policy_creation_failed', {
|
|
15588
|
+
error: error instanceof Error ? error.message : String(error),
|
|
15589
|
+
});
|
|
15590
|
+
return null;
|
|
15591
|
+
}
|
|
15592
|
+
}
|
|
15593
|
+
async function resolveConnectionRetryPolicy(config, options) {
|
|
15594
|
+
try {
|
|
15595
|
+
return await ConnectionRetryPolicyFactory.createConnectionRetryPolicy(config ?? undefined, cloneCreateOptions(options));
|
|
15596
|
+
}
|
|
15597
|
+
catch (error) {
|
|
15598
|
+
logger$$.warning('connection_retry_policy_creation_failed', {
|
|
15518
15599
|
error: error instanceof Error ? error.message : String(error),
|
|
15519
15600
|
});
|
|
15520
15601
|
return null;
|
|
@@ -15526,7 +15607,7 @@ async function resolveStorageProvider(config, options) {
|
|
|
15526
15607
|
return await StorageProviderFactory.createStorageProvider(config, cloneCreateOptions(options));
|
|
15527
15608
|
}
|
|
15528
15609
|
catch (error) {
|
|
15529
|
-
logger
|
|
15610
|
+
logger$$.warning('storage_provider_creation_failed', {
|
|
15530
15611
|
error: error instanceof Error ? error.message : String(error),
|
|
15531
15612
|
});
|
|
15532
15613
|
}
|
|
@@ -15548,7 +15629,7 @@ async function resolveAdmissionClient(config, options, identityPolicy) {
|
|
|
15548
15629
|
return await AdmissionClientFactory.createAdmissionClient((config ?? null), createOptions);
|
|
15549
15630
|
}
|
|
15550
15631
|
catch (error) {
|
|
15551
|
-
logger
|
|
15632
|
+
logger$$.warning('admission_client_creation_failed', {
|
|
15552
15633
|
error: error instanceof Error ? error.message : String(error),
|
|
15553
15634
|
});
|
|
15554
15635
|
return null;
|
|
@@ -15575,7 +15656,7 @@ async function resolveReplicaStickinessManager(hasParent, requestedLogicals, opt
|
|
|
15575
15656
|
return await ReplicaStickinessManagerFactory.createReplicaStickinessManager(undefined, cloneCreateOptions(options));
|
|
15576
15657
|
}
|
|
15577
15658
|
catch (error) {
|
|
15578
|
-
logger
|
|
15659
|
+
logger$$.debug('replica_stickiness_manager_unavailable', { error });
|
|
15579
15660
|
return null;
|
|
15580
15661
|
}
|
|
15581
15662
|
}
|
|
@@ -15584,7 +15665,7 @@ async function resolveAttachmentKeyValidator(config, options) {
|
|
|
15584
15665
|
return await AttachmentKeyValidatorFactory.createAttachmentKeyValidator(config ?? undefined, cloneCreateOptions(options));
|
|
15585
15666
|
}
|
|
15586
15667
|
catch (error) {
|
|
15587
|
-
logger
|
|
15668
|
+
logger$$.warning('attachment_key_validator_creation_failed', {
|
|
15588
15669
|
error: error instanceof Error ? error.message : String(error),
|
|
15589
15670
|
});
|
|
15590
15671
|
return null;
|
|
@@ -15602,7 +15683,7 @@ async function resolveDeliveryPolicy(config, options) {
|
|
|
15602
15683
|
return await DeliveryPolicyFactory.createDeliveryPolicy(config ?? undefined, cloneCreateOptions(options));
|
|
15603
15684
|
}
|
|
15604
15685
|
catch (error) {
|
|
15605
|
-
logger
|
|
15686
|
+
logger$$.warning('delivery_policy_creation_failed', {
|
|
15606
15687
|
error: error instanceof Error ? error.message : String(error),
|
|
15607
15688
|
});
|
|
15608
15689
|
return null;
|
|
@@ -15616,7 +15697,7 @@ async function resolveTransportListeners(configs, eventListeners, options) {
|
|
|
15616
15697
|
return await TransportListenerFactory.createTransportListeners(configs, eventListeners, cloneCreateOptions(options));
|
|
15617
15698
|
}
|
|
15618
15699
|
catch (error) {
|
|
15619
|
-
logger
|
|
15700
|
+
logger$$.warning('transport_listener_creation_failed', {
|
|
15620
15701
|
error: error instanceof Error ? error.message : String(error),
|
|
15621
15702
|
});
|
|
15622
15703
|
return [];
|
|
@@ -15627,7 +15708,7 @@ async function resolveTraceEmitter(config, options) {
|
|
|
15627
15708
|
return await TraceEmitterFactory.createTraceEmitter(config ?? undefined, cloneCreateOptions(options));
|
|
15628
15709
|
}
|
|
15629
15710
|
catch (error) {
|
|
15630
|
-
logger
|
|
15711
|
+
logger$$.warning('trace_emitter_creation_failed', {
|
|
15631
15712
|
error: error instanceof Error ? error.message : String(error),
|
|
15632
15713
|
});
|
|
15633
15714
|
return null;
|
|
@@ -15683,7 +15764,7 @@ async function createSecurityManagerFromConfig(config, overrides, options) {
|
|
|
15683
15764
|
return manager ?? null;
|
|
15684
15765
|
}
|
|
15685
15766
|
catch (error) {
|
|
15686
|
-
logger
|
|
15767
|
+
logger$$.warning('security_manager_creation_failed', {
|
|
15687
15768
|
error: error instanceof Error ? error.message : String(error),
|
|
15688
15769
|
});
|
|
15689
15770
|
return null;
|
|
@@ -15712,7 +15793,7 @@ async function resolveCryptoProvider(config, options) {
|
|
|
15712
15793
|
// This happens with overlay security profiles that need envelope signing
|
|
15713
15794
|
if (requiresCryptoProvider(config)) {
|
|
15714
15795
|
try {
|
|
15715
|
-
logger
|
|
15796
|
+
logger$$.debug('auto_creating_crypto_provider', {
|
|
15716
15797
|
reason: 'overlay_security_requires_signing',
|
|
15717
15798
|
});
|
|
15718
15799
|
// Dynamically import to avoid circular dependencies
|
|
@@ -15732,7 +15813,7 @@ async function resolveCryptoProvider(config, options) {
|
|
|
15732
15813
|
});
|
|
15733
15814
|
}
|
|
15734
15815
|
catch (error) {
|
|
15735
|
-
logger
|
|
15816
|
+
logger$$.error('failed_to_auto_create_crypto_provider', {
|
|
15736
15817
|
error: error instanceof Error ? error.message : String(error),
|
|
15737
15818
|
});
|
|
15738
15819
|
throw error;
|
|
@@ -16283,7 +16364,7 @@ class NodeLikeFactory extends factory.AbstractResourceFactory {
|
|
|
16283
16364
|
// registerFactory(NODE_LIKE_FACTORY_BASE_TYPE, type, factory);
|
|
16284
16365
|
// }
|
|
16285
16366
|
|
|
16286
|
-
const FACTORY_META$
|
|
16367
|
+
const FACTORY_META$17 = {
|
|
16287
16368
|
base: NODE_LIKE_FACTORY_BASE_TYPE,
|
|
16288
16369
|
key: 'Node',
|
|
16289
16370
|
};
|
|
@@ -16317,6 +16398,7 @@ class NodeFactory extends NodeLikeFactory {
|
|
|
16317
16398
|
nodeMetaStore: components.nodeMetaStore,
|
|
16318
16399
|
transportListeners: components.transportListeners,
|
|
16319
16400
|
defaultServiceConfigs: serviceConfigs,
|
|
16401
|
+
connectionRetryPolicy: components.connectionRetryPolicy,
|
|
16320
16402
|
});
|
|
16321
16403
|
return node;
|
|
16322
16404
|
}
|
|
@@ -16324,7 +16406,7 @@ class NodeFactory extends NodeLikeFactory {
|
|
|
16324
16406
|
|
|
16325
16407
|
var nodeFactory = /*#__PURE__*/Object.freeze({
|
|
16326
16408
|
__proto__: null,
|
|
16327
|
-
FACTORY_META: FACTORY_META$
|
|
16409
|
+
FACTORY_META: FACTORY_META$17,
|
|
16328
16410
|
NodeFactory: NodeFactory,
|
|
16329
16411
|
default: NodeFactory
|
|
16330
16412
|
});
|
|
@@ -16897,7 +16979,7 @@ function normalizeSecurityRequirements(value) {
|
|
|
16897
16979
|
};
|
|
16898
16980
|
}
|
|
16899
16981
|
|
|
16900
|
-
const logger$
|
|
16982
|
+
const logger$_ = getLogger('naylence.fame.node.envelope_security_handler');
|
|
16901
16983
|
const ENCRYPTION_OPTION_ALIAS_PAIRS = [
|
|
16902
16984
|
['recipKid', 'recip_kid'],
|
|
16903
16985
|
['recipientKeyId', 'recipient_key_id'],
|
|
@@ -16946,7 +17028,7 @@ class EnvelopeSecurityHandler {
|
|
|
16946
17028
|
const shouldSign = this.securityPolicy
|
|
16947
17029
|
? await this.securityPolicy.shouldSignEnvelope(envelope, context, this.node)
|
|
16948
17030
|
: false;
|
|
16949
|
-
logger$
|
|
17031
|
+
logger$_.debug('checking_signing', {
|
|
16950
17032
|
has_signer: Boolean(this.envelopeSigner),
|
|
16951
17033
|
should_sign: shouldSign,
|
|
16952
17034
|
envp_id: envelope.id,
|
|
@@ -16968,7 +17050,7 @@ class EnvelopeSecurityHandler {
|
|
|
16968
17050
|
const shouldEncrypt = this.securityPolicy
|
|
16969
17051
|
? await this.securityPolicy.shouldEncryptEnvelope(envelope, context, this.node)
|
|
16970
17052
|
: false;
|
|
16971
|
-
logger$
|
|
17053
|
+
logger$_.debug('checking_encryption', {
|
|
16972
17054
|
has_encryption_manager: Boolean(this.encryptionManager),
|
|
16973
17055
|
should_encrypt: shouldEncrypt,
|
|
16974
17056
|
envp_id: envelope.id,
|
|
@@ -16976,7 +17058,7 @@ class EnvelopeSecurityHandler {
|
|
|
16976
17058
|
});
|
|
16977
17059
|
if (this.encryptionManager && this.securityPolicy) {
|
|
16978
17060
|
if (envelope.sec?.enc) {
|
|
16979
|
-
logger$
|
|
17061
|
+
logger$_.debug('skipping_encryption_already_encrypted', {
|
|
16980
17062
|
envp_id: envelope.id,
|
|
16981
17063
|
destination: envelope.to ? String(envelope.to) : undefined,
|
|
16982
17064
|
});
|
|
@@ -16989,7 +17071,7 @@ class EnvelopeSecurityHandler {
|
|
|
16989
17071
|
exports.CryptoLevel.PLAINTEXT;
|
|
16990
17072
|
desiredCryptoLevel =
|
|
16991
17073
|
await this.securityPolicy.decideResponseCryptoLevel(requestCryptoLevel, envelope, context);
|
|
16992
|
-
logger$
|
|
17074
|
+
logger$_.debug('response_crypto_level_decided', {
|
|
16993
17075
|
envp_id: envelope.id,
|
|
16994
17076
|
crypto_level: desiredCryptoLevel,
|
|
16995
17077
|
destination: envelope.to ? String(envelope.to) : undefined,
|
|
@@ -17000,7 +17082,7 @@ class EnvelopeSecurityHandler {
|
|
|
17000
17082
|
else {
|
|
17001
17083
|
desiredCryptoLevel =
|
|
17002
17084
|
await this.securityPolicy.decideOutboundCryptoLevel(envelope, context, this.node);
|
|
17003
|
-
logger$
|
|
17085
|
+
logger$_.debug('outbound_crypto_level_decided', {
|
|
17004
17086
|
envp_id: envelope.id,
|
|
17005
17087
|
frame_type: envelope.frame.type,
|
|
17006
17088
|
crypto_level: desiredCryptoLevel,
|
|
@@ -17008,11 +17090,11 @@ class EnvelopeSecurityHandler {
|
|
|
17008
17090
|
});
|
|
17009
17091
|
}
|
|
17010
17092
|
if (desiredCryptoLevel === exports.CryptoLevel.SEALED) {
|
|
17011
|
-
logger$
|
|
17093
|
+
logger$_.debug('applying_sealed_encryption', { envp_id: envelope.id });
|
|
17012
17094
|
return await this.handleSealedEncryption(envelope, context);
|
|
17013
17095
|
}
|
|
17014
17096
|
if (desiredCryptoLevel === exports.CryptoLevel.CHANNEL) {
|
|
17015
|
-
logger$
|
|
17097
|
+
logger$_.debug('applying_channel_encryption', { envp_id: envelope.id });
|
|
17016
17098
|
return await this.handleChannelEncryption(envelope, context);
|
|
17017
17099
|
}
|
|
17018
17100
|
}
|
|
@@ -17063,7 +17145,7 @@ class EnvelopeSecurityHandler {
|
|
|
17063
17145
|
frameType === 'KeyAnnounce' ||
|
|
17064
17146
|
frameType === 'SecureOpen' ||
|
|
17065
17147
|
frameType === 'SecureAccept') {
|
|
17066
|
-
logger$
|
|
17148
|
+
logger$_.error('critical_frame_unsigned_rejected', {
|
|
17067
17149
|
envp_id: envelope.id,
|
|
17068
17150
|
frame_type: frameType,
|
|
17069
17151
|
reason: 'critical_frames_must_be_signed',
|
|
@@ -17071,7 +17153,7 @@ class EnvelopeSecurityHandler {
|
|
|
17071
17153
|
return [envelope, false];
|
|
17072
17154
|
}
|
|
17073
17155
|
const action = this.securityPolicy.getUnsignedViolationAction(envelope, context);
|
|
17074
|
-
logger$
|
|
17156
|
+
logger$_.warning('unsigned_envelope_violation', {
|
|
17075
17157
|
envp_id: envelope.id,
|
|
17076
17158
|
frame_type: frameType,
|
|
17077
17159
|
action,
|
|
@@ -17083,26 +17165,26 @@ class EnvelopeSecurityHandler {
|
|
|
17083
17165
|
return [envelope, true];
|
|
17084
17166
|
}
|
|
17085
17167
|
async handleChannelHandshakeComplete(channelId, destination) {
|
|
17086
|
-
logger$
|
|
17168
|
+
logger$_.debug('channel_handshake_completed', {
|
|
17087
17169
|
channel_id: channelId,
|
|
17088
17170
|
destination,
|
|
17089
17171
|
});
|
|
17090
17172
|
if (this.encryptionManager?.notifyChannelEstablished) {
|
|
17091
17173
|
await this.encryptionManager.notifyChannelEstablished(channelId);
|
|
17092
|
-
logger$
|
|
17174
|
+
logger$_.debug('notified_encryption_manager_channel_ready', {
|
|
17093
17175
|
channel_id: channelId,
|
|
17094
17176
|
});
|
|
17095
17177
|
}
|
|
17096
17178
|
}
|
|
17097
17179
|
async handleChannelHandshakeFailed(channelId, destination, reason = 'handshake_failed') {
|
|
17098
|
-
logger$
|
|
17180
|
+
logger$_.debug('channel_handshake_failed', {
|
|
17099
17181
|
channel_id: channelId,
|
|
17100
17182
|
destination,
|
|
17101
17183
|
reason,
|
|
17102
17184
|
});
|
|
17103
17185
|
if (this.encryptionManager?.notifyChannelFailed) {
|
|
17104
17186
|
await this.encryptionManager.notifyChannelFailed(channelId, reason);
|
|
17105
|
-
logger$
|
|
17187
|
+
logger$_.debug('notified_encryption_manager_channel_failed', {
|
|
17106
17188
|
channel_id: channelId,
|
|
17107
17189
|
reason,
|
|
17108
17190
|
});
|
|
@@ -17149,7 +17231,7 @@ class EnvelopeSecurityHandler {
|
|
|
17149
17231
|
checkPayload: false,
|
|
17150
17232
|
});
|
|
17151
17233
|
if (verified) {
|
|
17152
|
-
logger$
|
|
17234
|
+
logger$_.debug('envelope_verified', {
|
|
17153
17235
|
envp_id: envelope.id,
|
|
17154
17236
|
sid: envelope.sid,
|
|
17155
17237
|
kid,
|
|
@@ -17160,7 +17242,7 @@ class EnvelopeSecurityHandler {
|
|
|
17160
17242
|
}
|
|
17161
17243
|
this.keyManagementHandler.queuePendingSignedEnvelope(kid, envelope, context);
|
|
17162
17244
|
await this.keyManagementHandler.maybeRequestSigningKey(kid, context.originType, fromSystemId);
|
|
17163
|
-
logger$
|
|
17245
|
+
logger$_.debug('queued_envelope_missing_signing_key', {
|
|
17164
17246
|
kid,
|
|
17165
17247
|
envp_id: envelope.id,
|
|
17166
17248
|
});
|
|
@@ -17168,7 +17250,7 @@ class EnvelopeSecurityHandler {
|
|
|
17168
17250
|
}
|
|
17169
17251
|
async handleSealedEncryption(envelope, context) {
|
|
17170
17252
|
if (!envelope.to) {
|
|
17171
|
-
logger$
|
|
17253
|
+
logger$_.warning('sealed_encryption_requested_but_no_destination', {
|
|
17172
17254
|
envp_id: envelope.id,
|
|
17173
17255
|
});
|
|
17174
17256
|
return true;
|
|
@@ -17180,20 +17262,20 @@ class EnvelopeSecurityHandler {
|
|
|
17180
17262
|
: undefined;
|
|
17181
17263
|
if (options) {
|
|
17182
17264
|
if (options.encryptionType === 'channel') {
|
|
17183
|
-
logger$
|
|
17265
|
+
logger$_.warning('policy_returned_channel_for_sealed_request', {
|
|
17184
17266
|
envp_id: envelope.id,
|
|
17185
17267
|
});
|
|
17186
17268
|
return await this.handleToBeEncryptedEnvelopeWithOptions(envelope, context, normalizeEncryptionOptions({
|
|
17187
17269
|
requestAddress: envelope.to,
|
|
17188
17270
|
}));
|
|
17189
17271
|
}
|
|
17190
|
-
logger$
|
|
17272
|
+
logger$_.debug('using_sealed_encryption_options', {
|
|
17191
17273
|
envp_id: envelope.id,
|
|
17192
17274
|
options,
|
|
17193
17275
|
});
|
|
17194
17276
|
return await this.handleToBeEncryptedEnvelopeWithOptions(envelope, context, options);
|
|
17195
17277
|
}
|
|
17196
|
-
logger$
|
|
17278
|
+
logger$_.debug('no_encryption_options_requesting_key', {
|
|
17197
17279
|
envp_id: envelope.id,
|
|
17198
17280
|
});
|
|
17199
17281
|
return await this.handleToBeEncryptedEnvelopeWithOptions(envelope, context, normalizeEncryptionOptions({
|
|
@@ -17201,7 +17283,7 @@ class EnvelopeSecurityHandler {
|
|
|
17201
17283
|
}));
|
|
17202
17284
|
}
|
|
17203
17285
|
catch (error) {
|
|
17204
|
-
logger$
|
|
17286
|
+
logger$_.debug('sealed_key_lookup_failed_requesting', {
|
|
17205
17287
|
envp_id: envelope.id,
|
|
17206
17288
|
error: error instanceof Error ? error.message : String(error),
|
|
17207
17289
|
});
|
|
@@ -17212,7 +17294,7 @@ class EnvelopeSecurityHandler {
|
|
|
17212
17294
|
}
|
|
17213
17295
|
async handleChannelEncryption(envelope, context) {
|
|
17214
17296
|
if (!envelope.to) {
|
|
17215
|
-
logger$
|
|
17297
|
+
logger$_.warning('channel_encryption_requested_but_no_destination', {
|
|
17216
17298
|
envp_id: envelope.id,
|
|
17217
17299
|
});
|
|
17218
17300
|
return true;
|
|
@@ -17227,13 +17309,13 @@ class EnvelopeSecurityHandler {
|
|
|
17227
17309
|
return true;
|
|
17228
17310
|
}
|
|
17229
17311
|
if (context.originType !== core.DeliveryOriginType.LOCAL) {
|
|
17230
|
-
logger$
|
|
17312
|
+
logger$_.warning('envelope_encryption_rejected_non_local', {
|
|
17231
17313
|
origin: context.originType,
|
|
17232
17314
|
});
|
|
17233
17315
|
return true;
|
|
17234
17316
|
}
|
|
17235
17317
|
if (!isDataFrame$4(envelope.frame)) {
|
|
17236
|
-
logger$
|
|
17318
|
+
logger$_.trace('skipping_encryption_non_dataframe', {
|
|
17237
17319
|
envp_id: envelope.id,
|
|
17238
17320
|
frame_type: envelope.frame.type,
|
|
17239
17321
|
});
|
|
@@ -17244,7 +17326,7 @@ class EnvelopeSecurityHandler {
|
|
|
17244
17326
|
? normalizeEncryptionOptions(rawOptions)
|
|
17245
17327
|
: undefined;
|
|
17246
17328
|
if (!options) {
|
|
17247
|
-
logger$
|
|
17329
|
+
logger$_.warning('no_encryption_options_provided', {
|
|
17248
17330
|
envp_id: envelope.id,
|
|
17249
17331
|
});
|
|
17250
17332
|
return true;
|
|
@@ -17256,13 +17338,13 @@ class EnvelopeSecurityHandler {
|
|
|
17256
17338
|
return true;
|
|
17257
17339
|
}
|
|
17258
17340
|
if (context.originType !== core.DeliveryOriginType.LOCAL) {
|
|
17259
|
-
logger$
|
|
17341
|
+
logger$_.warning('envelope_encryption_rejected_non_local', {
|
|
17260
17342
|
origin: context.originType,
|
|
17261
17343
|
});
|
|
17262
17344
|
return true;
|
|
17263
17345
|
}
|
|
17264
17346
|
if (!isDataFrame$4(envelope.frame)) {
|
|
17265
|
-
logger$
|
|
17347
|
+
logger$_.trace('skipping_encryption_non_dataframe', {
|
|
17266
17348
|
envp_id: envelope.id,
|
|
17267
17349
|
frame_type: envelope.frame.type,
|
|
17268
17350
|
});
|
|
@@ -17279,7 +17361,7 @@ class EnvelopeSecurityHandler {
|
|
|
17279
17361
|
// Skip encryption if envelope is already encrypted
|
|
17280
17362
|
// This prevents re-queuing when replayed envelopes go through security again
|
|
17281
17363
|
if (envelope.sec?.enc) {
|
|
17282
|
-
logger$
|
|
17364
|
+
logger$_.debug('skipping_encryption_already_encrypted', {
|
|
17283
17365
|
envp_id: envelope.id,
|
|
17284
17366
|
destination: envelope.to ? String(envelope.to) : undefined,
|
|
17285
17367
|
});
|
|
@@ -17288,14 +17370,14 @@ class EnvelopeSecurityHandler {
|
|
|
17288
17370
|
try {
|
|
17289
17371
|
const result = await this.encryptionManager.encryptEnvelope(envelope, normalizedOptions);
|
|
17290
17372
|
if (result.status === exports.EncryptionStatus.QUEUED) {
|
|
17291
|
-
logger$
|
|
17373
|
+
logger$_.debug('envelope_queued_for_encryption', {
|
|
17292
17374
|
envp_id: envelope.id,
|
|
17293
17375
|
});
|
|
17294
17376
|
await this.handleEncryptionQueueing(envelope, context, normalizedOptions);
|
|
17295
17377
|
return false;
|
|
17296
17378
|
}
|
|
17297
17379
|
if (result.status === exports.EncryptionStatus.OK) {
|
|
17298
|
-
logger$
|
|
17380
|
+
logger$_.debug('envelope_encrypted', { envp_id: envelope.id });
|
|
17299
17381
|
if (result.envelope) {
|
|
17300
17382
|
envelope.frame = result.envelope.frame;
|
|
17301
17383
|
envelope.sec = result.envelope.sec;
|
|
@@ -17303,17 +17385,17 @@ class EnvelopeSecurityHandler {
|
|
|
17303
17385
|
return true;
|
|
17304
17386
|
}
|
|
17305
17387
|
if (result.status === exports.EncryptionStatus.SKIPPED) {
|
|
17306
|
-
logger$
|
|
17388
|
+
logger$_.debug('envelope_encryption_skipped', { envp_id: envelope.id });
|
|
17307
17389
|
return true;
|
|
17308
17390
|
}
|
|
17309
|
-
logger$
|
|
17391
|
+
logger$_.warning('unknown_encryption_status', {
|
|
17310
17392
|
envp_id: envelope.id,
|
|
17311
17393
|
status: result.status,
|
|
17312
17394
|
});
|
|
17313
17395
|
return true;
|
|
17314
17396
|
}
|
|
17315
17397
|
catch (error) {
|
|
17316
|
-
logger$
|
|
17398
|
+
logger$_.error('encryption_failed', {
|
|
17317
17399
|
envp_id: envelope.id,
|
|
17318
17400
|
error: error instanceof Error ? error.message : String(error),
|
|
17319
17401
|
});
|
|
@@ -17352,7 +17434,7 @@ class EnvelopeSecurityHandler {
|
|
|
17352
17434
|
return;
|
|
17353
17435
|
}
|
|
17354
17436
|
if (normalizedOptions.encryptionType === 'channel') {
|
|
17355
|
-
logger$
|
|
17437
|
+
logger$_.debug('channel_encryption_queueing_handled_internally', {
|
|
17356
17438
|
envp_id: envelope.id,
|
|
17357
17439
|
destination: normalizedOptions.destination
|
|
17358
17440
|
? String(normalizedOptions.destination)
|
|
@@ -17360,13 +17442,13 @@ class EnvelopeSecurityHandler {
|
|
|
17360
17442
|
});
|
|
17361
17443
|
return;
|
|
17362
17444
|
}
|
|
17363
|
-
logger$
|
|
17445
|
+
logger$_.warning('unknown_encryption_queueing_options', {
|
|
17364
17446
|
envp_id: envelope.id,
|
|
17365
17447
|
options: normalizedOptions,
|
|
17366
17448
|
});
|
|
17367
17449
|
}
|
|
17368
17450
|
async handleFailedChannelEnvelopeCleanup(destination, reason) {
|
|
17369
|
-
logger$
|
|
17451
|
+
logger$_.debug('channel_handshake_failure_cleanup_attempted', {
|
|
17370
17452
|
destination,
|
|
17371
17453
|
reason,
|
|
17372
17454
|
note: 'envelope_cleanup_handled_by_encryption_manager',
|
|
@@ -17377,7 +17459,7 @@ class EnvelopeSecurityHandler {
|
|
|
17377
17459
|
}
|
|
17378
17460
|
}
|
|
17379
17461
|
|
|
17380
|
-
const logger$
|
|
17462
|
+
const logger$Z = getLogger('naylence.fame.node.secure_channel_frame_handler');
|
|
17381
17463
|
function isPlainRecord$1(value) {
|
|
17382
17464
|
if (typeof value !== 'object' || value === null) {
|
|
17383
17465
|
return false;
|
|
@@ -17467,7 +17549,7 @@ class SecureChannelFrameHandler {
|
|
|
17467
17549
|
assertSecureChannelManager(this.secureChannelManager);
|
|
17468
17550
|
const frame = envelope.frame;
|
|
17469
17551
|
assertFrameType(frame, 'SecureOpen');
|
|
17470
|
-
logger$
|
|
17552
|
+
logger$Z.debug('received_secure_open', {
|
|
17471
17553
|
cid: frame.cid,
|
|
17472
17554
|
algorithm: frame.alg,
|
|
17473
17555
|
});
|
|
@@ -17490,13 +17572,13 @@ class SecureChannelFrameHandler {
|
|
|
17490
17572
|
stickySid: envelope.sid ?? undefined,
|
|
17491
17573
|
expectedResponseType: core.FameResponseType.NONE,
|
|
17492
17574
|
};
|
|
17493
|
-
logger$
|
|
17575
|
+
logger$Z.debug('stickiness_requested_for_channel_encryption', {
|
|
17494
17576
|
cid: frame.cid,
|
|
17495
17577
|
reason: 'secure_channel_established',
|
|
17496
17578
|
});
|
|
17497
17579
|
}
|
|
17498
17580
|
await this.sendCallback(responseEnvelope, responseContext);
|
|
17499
|
-
logger$
|
|
17581
|
+
logger$Z.debug('sent_secure_accept', { cid: frame.cid, ok: acceptFrame.ok });
|
|
17500
17582
|
if (acceptFrame.ok && this.envelopeSecurityHandler) {
|
|
17501
17583
|
const destination = extractDestinationFromChannelId(frame.cid);
|
|
17502
17584
|
if (destination) {
|
|
@@ -17508,13 +17590,13 @@ class SecureChannelFrameHandler {
|
|
|
17508
17590
|
assertSecureChannelManager(this.secureChannelManager);
|
|
17509
17591
|
const frame = envelope.frame;
|
|
17510
17592
|
assertFrameType(frame, 'SecureAccept');
|
|
17511
|
-
logger$
|
|
17593
|
+
logger$Z.debug('received_secure_accept', { cid: frame.cid, ok: frame.ok });
|
|
17512
17594
|
const success = await this.secureChannelManager.handleAcceptFrame(frame);
|
|
17513
17595
|
if (!success) {
|
|
17514
|
-
logger$
|
|
17596
|
+
logger$Z.warning('failed_to_complete_channel', { cid: frame.cid });
|
|
17515
17597
|
}
|
|
17516
17598
|
else {
|
|
17517
|
-
logger$
|
|
17599
|
+
logger$Z.debug('channel_established', { cid: frame.cid });
|
|
17518
17600
|
if (this.envelopeSecurityHandler) {
|
|
17519
17601
|
const destination = extractDestinationFromChannelId(frame.cid);
|
|
17520
17602
|
if (destination) {
|
|
@@ -17526,7 +17608,7 @@ class SecureChannelFrameHandler {
|
|
|
17526
17608
|
const destination = extractDestinationFromChannelId(frame.cid);
|
|
17527
17609
|
if (destination) {
|
|
17528
17610
|
await this.envelopeSecurityHandler.handleChannelHandshakeFailed(frame.cid, destination, 'negative_secure_accept');
|
|
17529
|
-
logger$
|
|
17611
|
+
logger$Z.debug('notified_handshake_failure', {
|
|
17530
17612
|
cid: frame.cid,
|
|
17531
17613
|
destination,
|
|
17532
17614
|
});
|
|
@@ -17537,7 +17619,7 @@ class SecureChannelFrameHandler {
|
|
|
17537
17619
|
assertSecureChannelManager(this.secureChannelManager);
|
|
17538
17620
|
const frame = envelope.frame;
|
|
17539
17621
|
assertFrameType(frame, 'SecureClose');
|
|
17540
|
-
logger$
|
|
17622
|
+
logger$Z.debug('received_secure_close', {
|
|
17541
17623
|
cid: frame.cid,
|
|
17542
17624
|
reason: frame.reason,
|
|
17543
17625
|
});
|
|
@@ -17595,7 +17677,7 @@ function createNodeDeliveryContext(options = {}) {
|
|
|
17595
17677
|
class FameEnvironmentContext {
|
|
17596
17678
|
}
|
|
17597
17679
|
|
|
17598
|
-
const FACTORY_META$
|
|
17680
|
+
const FACTORY_META$16 = {
|
|
17599
17681
|
base: NODE_IDENTITY_POLICY_FACTORY_BASE_TYPE,
|
|
17600
17682
|
key: 'DefaultNodeIdentityPolicy',
|
|
17601
17683
|
};
|
|
@@ -17613,11 +17695,11 @@ class DefaultNodeIdentityPolicyFactory extends NodeIdentityPolicyFactory {
|
|
|
17613
17695
|
var defaultNodeIdentityPolicyFactory = /*#__PURE__*/Object.freeze({
|
|
17614
17696
|
__proto__: null,
|
|
17615
17697
|
DefaultNodeIdentityPolicyFactory: DefaultNodeIdentityPolicyFactory,
|
|
17616
|
-
FACTORY_META: FACTORY_META$
|
|
17698
|
+
FACTORY_META: FACTORY_META$16,
|
|
17617
17699
|
default: DefaultNodeIdentityPolicyFactory
|
|
17618
17700
|
});
|
|
17619
17701
|
|
|
17620
|
-
const logger$
|
|
17702
|
+
const logger$Y = getLogger('naylence.fame.node.token_subject_node_identity_policy');
|
|
17621
17703
|
class TokenSubjectNodeIdentityPolicy {
|
|
17622
17704
|
async resolveInitialNodeId(context) {
|
|
17623
17705
|
if (context.configuredId) {
|
|
@@ -17629,7 +17711,7 @@ class TokenSubjectNodeIdentityPolicy {
|
|
|
17629
17711
|
return core.generateIdAsync();
|
|
17630
17712
|
}
|
|
17631
17713
|
async resolveAdmissionNodeId(context) {
|
|
17632
|
-
logger$
|
|
17714
|
+
logger$Y.debug('resolve_admission_node_id_start', {
|
|
17633
17715
|
grantsCount: context.grants?.length ?? 0,
|
|
17634
17716
|
currentNodeId: context.currentNodeId,
|
|
17635
17717
|
});
|
|
@@ -17638,31 +17720,31 @@ class TokenSubjectNodeIdentityPolicy {
|
|
|
17638
17720
|
try {
|
|
17639
17721
|
const auth = grant.auth;
|
|
17640
17722
|
if (!auth) {
|
|
17641
|
-
logger$
|
|
17723
|
+
logger$Y.debug('skipping_grant_no_auth', { grantType: grant.type });
|
|
17642
17724
|
continue;
|
|
17643
17725
|
}
|
|
17644
17726
|
const tokenProviderConfig = (auth.tokenProvider ??
|
|
17645
17727
|
auth.token_provider);
|
|
17646
17728
|
if (!tokenProviderConfig ||
|
|
17647
17729
|
typeof tokenProviderConfig.type !== 'string') {
|
|
17648
|
-
logger$
|
|
17730
|
+
logger$Y.debug('skipping_grant_invalid_token_provider_config', {
|
|
17649
17731
|
grantType: grant.type,
|
|
17650
17732
|
config: tokenProviderConfig,
|
|
17651
17733
|
});
|
|
17652
17734
|
continue;
|
|
17653
17735
|
}
|
|
17654
|
-
logger$
|
|
17736
|
+
logger$Y.debug('creating_token_provider', {
|
|
17655
17737
|
type: tokenProviderConfig.type,
|
|
17656
17738
|
});
|
|
17657
17739
|
const provider = await TokenProviderFactory.createTokenProvider(tokenProviderConfig);
|
|
17658
17740
|
const isExposing = isIdentityExposingTokenProvider(provider);
|
|
17659
|
-
logger$
|
|
17741
|
+
logger$Y.debug('token_provider_created', {
|
|
17660
17742
|
type: tokenProviderConfig.type,
|
|
17661
17743
|
isIdentityExposing: isExposing,
|
|
17662
17744
|
});
|
|
17663
17745
|
if (isExposing) {
|
|
17664
17746
|
const identity = await provider.getIdentity();
|
|
17665
|
-
logger$
|
|
17747
|
+
logger$Y.debug('retrieved_identity', { identity });
|
|
17666
17748
|
if (identity && identity.subject) {
|
|
17667
17749
|
const hashedSubject = await core.generateIdAsync({
|
|
17668
17750
|
mode: 'fingerprint',
|
|
@@ -17670,7 +17752,7 @@ class TokenSubjectNodeIdentityPolicy {
|
|
|
17670
17752
|
length: 8,
|
|
17671
17753
|
});
|
|
17672
17754
|
const newNodeId = `${hashedSubject}-${context.currentNodeId}`;
|
|
17673
|
-
logger$
|
|
17755
|
+
logger$Y.info('resolved_identity_from_token', {
|
|
17674
17756
|
subject: identity.subject,
|
|
17675
17757
|
hashedSubject,
|
|
17676
17758
|
newNodeId,
|
|
@@ -17678,17 +17760,17 @@ class TokenSubjectNodeIdentityPolicy {
|
|
|
17678
17760
|
return newNodeId;
|
|
17679
17761
|
}
|
|
17680
17762
|
else {
|
|
17681
|
-
logger$
|
|
17763
|
+
logger$Y.debug('identity_missing_subject', { identity });
|
|
17682
17764
|
}
|
|
17683
17765
|
}
|
|
17684
17766
|
}
|
|
17685
17767
|
catch (err) {
|
|
17686
|
-
logger$
|
|
17768
|
+
logger$Y.warning('failed_to_extract_identity_from_grant', { error: err });
|
|
17687
17769
|
}
|
|
17688
17770
|
}
|
|
17689
17771
|
}
|
|
17690
17772
|
else {
|
|
17691
|
-
logger$
|
|
17773
|
+
logger$Y.debug('no_grants_available');
|
|
17692
17774
|
}
|
|
17693
17775
|
return context.currentNodeId;
|
|
17694
17776
|
}
|
|
@@ -17699,7 +17781,7 @@ var tokenSubjectNodeIdentityPolicy = /*#__PURE__*/Object.freeze({
|
|
|
17699
17781
|
TokenSubjectNodeIdentityPolicy: TokenSubjectNodeIdentityPolicy
|
|
17700
17782
|
});
|
|
17701
17783
|
|
|
17702
|
-
const FACTORY_META$
|
|
17784
|
+
const FACTORY_META$15 = {
|
|
17703
17785
|
base: NODE_IDENTITY_POLICY_FACTORY_BASE_TYPE,
|
|
17704
17786
|
key: 'TokenSubjectNodeIdentityPolicy',
|
|
17705
17787
|
};
|
|
@@ -17718,12 +17800,12 @@ class TokenSubjectNodeIdentityPolicyFactory extends NodeIdentityPolicyFactory {
|
|
|
17718
17800
|
|
|
17719
17801
|
var tokenSubjectNodeIdentityPolicyFactory = /*#__PURE__*/Object.freeze({
|
|
17720
17802
|
__proto__: null,
|
|
17721
|
-
FACTORY_META: FACTORY_META$
|
|
17803
|
+
FACTORY_META: FACTORY_META$15,
|
|
17722
17804
|
TokenSubjectNodeIdentityPolicyFactory: TokenSubjectNodeIdentityPolicyFactory,
|
|
17723
17805
|
default: TokenSubjectNodeIdentityPolicyFactory
|
|
17724
17806
|
});
|
|
17725
17807
|
|
|
17726
|
-
const logger$
|
|
17808
|
+
const logger$X = getLogger('naylence.fame.node.node_identity_policy_profile_factory');
|
|
17727
17809
|
const PROFILE_NAME_DEFAULT = 'default';
|
|
17728
17810
|
const PROFILE_NAME_TOKEN_SUBJECT = 'token-subject';
|
|
17729
17811
|
const PROFILE_NAME_TOKEN_SUBJECT_ALIAS = 'token_subject';
|
|
@@ -17738,7 +17820,7 @@ const PROFILE_MAP$5 = {
|
|
|
17738
17820
|
[PROFILE_NAME_TOKEN_SUBJECT]: TOKEN_SUBJECT_PROFILE,
|
|
17739
17821
|
[PROFILE_NAME_TOKEN_SUBJECT_ALIAS]: TOKEN_SUBJECT_PROFILE,
|
|
17740
17822
|
};
|
|
17741
|
-
const FACTORY_META$
|
|
17823
|
+
const FACTORY_META$14 = {
|
|
17742
17824
|
base: NODE_IDENTITY_POLICY_FACTORY_BASE_TYPE,
|
|
17743
17825
|
key: 'NodeIdentityPolicyProfile',
|
|
17744
17826
|
};
|
|
@@ -17750,7 +17832,7 @@ class NodeIdentityPolicyProfileFactory extends NodeIdentityPolicyFactory {
|
|
|
17750
17832
|
async create(config) {
|
|
17751
17833
|
const normalized = normalizeConfig$t(config);
|
|
17752
17834
|
const profileConfig = resolveProfileConfig$4(normalized.profile);
|
|
17753
|
-
logger$
|
|
17835
|
+
logger$X.debug('enabling_node_identity_policy_profile', {
|
|
17754
17836
|
profile: normalized.profile,
|
|
17755
17837
|
});
|
|
17756
17838
|
return NodeIdentityPolicyFactory.createNodeIdentityPolicy(profileConfig);
|
|
@@ -17786,11 +17868,95 @@ function deepClone$4(value) {
|
|
|
17786
17868
|
|
|
17787
17869
|
var nodeIdentityPolicyProfileFactory = /*#__PURE__*/Object.freeze({
|
|
17788
17870
|
__proto__: null,
|
|
17789
|
-
FACTORY_META: FACTORY_META$
|
|
17871
|
+
FACTORY_META: FACTORY_META$14,
|
|
17790
17872
|
NodeIdentityPolicyProfileFactory: NodeIdentityPolicyProfileFactory,
|
|
17791
17873
|
default: NodeIdentityPolicyProfileFactory
|
|
17792
17874
|
});
|
|
17793
17875
|
|
|
17876
|
+
/**
|
|
17877
|
+
* Environment variable for overriding max initial attempts.
|
|
17878
|
+
*/
|
|
17879
|
+
const ENV_VAR_SESSION_MAX_INITIAL_ATTEMPTS = 'FAME_SESSION_MAX_INITIAL_ATTEMPTS';
|
|
17880
|
+
/**
|
|
17881
|
+
* Default implementation of connection retry policy.
|
|
17882
|
+
*
|
|
17883
|
+
* Before first successful attach:
|
|
17884
|
+
* - Respects maxInitialAttempts configuration
|
|
17885
|
+
* - Uses exponential backoff with jitter
|
|
17886
|
+
*
|
|
17887
|
+
* After first successful attach:
|
|
17888
|
+
* - Always retries (unlimited) to maintain connection
|
|
17889
|
+
* - Resets backoff if connection was stable for >10 seconds
|
|
17890
|
+
*/
|
|
17891
|
+
class DefaultConnectionRetryPolicy {
|
|
17892
|
+
constructor(options = {}) {
|
|
17893
|
+
// Check for environment variable override
|
|
17894
|
+
const envValue = typeof process !== 'undefined'
|
|
17895
|
+
? process.env?.[ENV_VAR_SESSION_MAX_INITIAL_ATTEMPTS]
|
|
17896
|
+
: undefined;
|
|
17897
|
+
if (envValue !== undefined && envValue !== '') {
|
|
17898
|
+
const parsed = parseInt(envValue, 10);
|
|
17899
|
+
this.maxInitialAttempts = isNaN(parsed) ? (options.maxInitialAttempts ?? 1) : parsed;
|
|
17900
|
+
}
|
|
17901
|
+
else {
|
|
17902
|
+
this.maxInitialAttempts = options.maxInitialAttempts ?? 1;
|
|
17903
|
+
}
|
|
17904
|
+
}
|
|
17905
|
+
shouldRetry(context) {
|
|
17906
|
+
// After first successful attach, always retry to maintain connection
|
|
17907
|
+
if (context.hadSuccessfulAttach) {
|
|
17908
|
+
return true;
|
|
17909
|
+
}
|
|
17910
|
+
// maxInitialAttempts = 0 means unlimited retries
|
|
17911
|
+
if (this.maxInitialAttempts === 0) {
|
|
17912
|
+
return true;
|
|
17913
|
+
}
|
|
17914
|
+
// Fail if we've exceeded the configured max attempts
|
|
17915
|
+
return context.attemptNumber < this.maxInitialAttempts;
|
|
17916
|
+
}
|
|
17917
|
+
calculateRetryDelay(_context, baseDelay) {
|
|
17918
|
+
// Add jitter to prevent thundering herd
|
|
17919
|
+
const jitter = Math.random() * baseDelay;
|
|
17920
|
+
return baseDelay + jitter;
|
|
17921
|
+
}
|
|
17922
|
+
}
|
|
17923
|
+
|
|
17924
|
+
const logger$W = getLogger('naylence.fame.node.default-connection-retry-policy-factory');
|
|
17925
|
+
const FACTORY_META$13 = {
|
|
17926
|
+
base: CONNECTION_RETRY_POLICY_FACTORY_BASE_TYPE,
|
|
17927
|
+
key: 'DefaultConnectionRetryPolicy',
|
|
17928
|
+
};
|
|
17929
|
+
class DefaultConnectionRetryPolicyFactory extends ConnectionRetryPolicyFactory {
|
|
17930
|
+
constructor() {
|
|
17931
|
+
super(...arguments);
|
|
17932
|
+
this.type = 'DefaultConnectionRetryPolicy';
|
|
17933
|
+
this.isDefault = true;
|
|
17934
|
+
}
|
|
17935
|
+
async create(config) {
|
|
17936
|
+
const options = {};
|
|
17937
|
+
if (config) {
|
|
17938
|
+
const rawMax = config.maxInitialAttempts ??
|
|
17939
|
+
config.max_initial_attempts;
|
|
17940
|
+
if (rawMax !== undefined && rawMax !== null) {
|
|
17941
|
+
options.maxInitialAttempts =
|
|
17942
|
+
typeof rawMax === 'string' ? parseInt(rawMax, 10) : Number(rawMax);
|
|
17943
|
+
}
|
|
17944
|
+
}
|
|
17945
|
+
const policy = new DefaultConnectionRetryPolicy(options);
|
|
17946
|
+
logger$W.debug('connection_retry_policy_created', {
|
|
17947
|
+
maxInitialAttempts: policy.maxInitialAttempts,
|
|
17948
|
+
});
|
|
17949
|
+
return policy;
|
|
17950
|
+
}
|
|
17951
|
+
}
|
|
17952
|
+
|
|
17953
|
+
var defaultConnectionRetryPolicyFactory = /*#__PURE__*/Object.freeze({
|
|
17954
|
+
__proto__: null,
|
|
17955
|
+
DefaultConnectionRetryPolicyFactory: DefaultConnectionRetryPolicyFactory,
|
|
17956
|
+
FACTORY_META: FACTORY_META$13,
|
|
17957
|
+
default: DefaultConnectionRetryPolicyFactory
|
|
17958
|
+
});
|
|
17959
|
+
|
|
17794
17960
|
const LOAD_BALANCER_STICKINESS_MANAGER_FACTORY_BASE_TYPE = 'LoadBalancerStickinessManagerFactory';
|
|
17795
17961
|
class LoadBalancerStickinessManagerFactory extends factory.AbstractResourceFactory {
|
|
17796
17962
|
static async createLoadBalancerStickinessManager(config, options = {}) {
|
|
@@ -20862,6 +21028,7 @@ class Sentinel extends FameNode {
|
|
|
20862
21028
|
this.maxAttachTtlSec = opts.maxAttachTtlSec ?? null;
|
|
20863
21029
|
this.requestedLogicals = opts.requestedLogicals ?? [];
|
|
20864
21030
|
this.attachClient = opts.attachClient ?? null;
|
|
21031
|
+
this.connectionRetryPolicy = opts.connectionRetryPolicy ?? null;
|
|
20865
21032
|
this.nodeAttachFrameHandler = new NodeAttachFrameHandler({
|
|
20866
21033
|
routingNode: this,
|
|
20867
21034
|
routeManager: this.routeManager,
|
|
@@ -21411,6 +21578,7 @@ class Sentinel extends FameNode {
|
|
|
21411
21578
|
onAttach: (info, connector) => this.onNodeAttachToPeer(info, connector),
|
|
21412
21579
|
onEpochChange: (epoch) => this.onEpochChange(epoch),
|
|
21413
21580
|
onWelcome: async () => undefined,
|
|
21581
|
+
retryPolicy: this.connectionRetryPolicy,
|
|
21414
21582
|
});
|
|
21415
21583
|
await sessionManager.start();
|
|
21416
21584
|
const systemId = sessionManager.systemId;
|
|
@@ -43679,13 +43847,17 @@ exports.BindingStoreEntryRecord = BindingStoreEntryRecord;
|
|
|
43679
43847
|
exports.BrowserAutoKeyCredentialProvider = BrowserAutoKeyCredentialProvider;
|
|
43680
43848
|
exports.BrowserWrappedKeyCredentialProvider = BrowserWrappedKeyCredentialProvider;
|
|
43681
43849
|
exports.CERTIFICATE_MANAGER_FACTORY_BASE_TYPE = CERTIFICATE_MANAGER_FACTORY_BASE_TYPE;
|
|
43850
|
+
exports.CONNECTION_RETRY_POLICY_FACTORY_BASE_TYPE = CONNECTION_RETRY_POLICY_FACTORY_BASE_TYPE;
|
|
43682
43851
|
exports.CREDENTIAL_PROVIDER_FACTORY_BASE_TYPE = CREDENTIAL_PROVIDER_FACTORY_BASE_TYPE;
|
|
43683
43852
|
exports.CRYPTO_LEVEL_SECURITY_ORDER = CRYPTO_LEVEL_SECURITY_ORDER;
|
|
43684
43853
|
exports.CertificateManagerFactory = CertificateManagerFactory;
|
|
43854
|
+
exports.ConnectionRetryPolicyFactory = ConnectionRetryPolicyFactory;
|
|
43685
43855
|
exports.ConnectorConfigDefaults = ConnectorConfigDefaults;
|
|
43686
43856
|
exports.ConnectorFactory = ConnectorFactory;
|
|
43687
43857
|
exports.ConsoleMetricsEmitter = ConsoleMetricsEmitter;
|
|
43688
43858
|
exports.DEFAULT_WELCOME_FACTORY_META = FACTORY_META$_;
|
|
43859
|
+
exports.DefaultConnectionRetryPolicy = DefaultConnectionRetryPolicy;
|
|
43860
|
+
exports.DefaultConnectionRetryPolicyFactory = DefaultConnectionRetryPolicyFactory;
|
|
43689
43861
|
exports.DefaultCryptoProvider = DefaultCryptoProvider;
|
|
43690
43862
|
exports.DefaultHttpServer = DefaultHttpServer;
|
|
43691
43863
|
exports.DefaultKeyManager = DefaultKeyManager;
|
|
@@ -43707,6 +43879,7 @@ exports.ENV_VAR_JWT_AUDIENCE = ENV_VAR_JWT_AUDIENCE$2;
|
|
|
43707
43879
|
exports.ENV_VAR_JWT_REVERSE_AUTH_AUDIENCE = ENV_VAR_JWT_REVERSE_AUTH_AUDIENCE;
|
|
43708
43880
|
exports.ENV_VAR_JWT_REVERSE_AUTH_TRUSTED_ISSUER = ENV_VAR_JWT_REVERSE_AUTH_TRUSTED_ISSUER;
|
|
43709
43881
|
exports.ENV_VAR_JWT_TRUSTED_ISSUER = ENV_VAR_JWT_TRUSTED_ISSUER;
|
|
43882
|
+
exports.ENV_VAR_SESSION_MAX_INITIAL_ATTEMPTS = ENV_VAR_SESSION_MAX_INITIAL_ATTEMPTS;
|
|
43710
43883
|
exports.ENV_VAR_SHOW_ENVELOPES = ENV_VAR_SHOW_ENVELOPES$1;
|
|
43711
43884
|
exports.EdDSAEnvelopeSigner = EdDSAEnvelopeSigner;
|
|
43712
43885
|
exports.EncryptedKeyValueStore = EncryptedKeyValueStore;
|