@naylence/runtime 0.3.21 → 0.3.22
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser/index.cjs +367 -396
- package/dist/browser/index.mjs +367 -396
- package/dist/cjs/naylence/fame/node/default-node-identity-policy.js +9 -41
- package/dist/cjs/version.js +2 -2
- package/dist/esm/naylence/fame/node/default-node-identity-policy.js +9 -41
- package/dist/esm/version.js +2 -2
- package/dist/node/index.cjs +367 -396
- package/dist/node/index.mjs +367 -396
- package/dist/node/node.cjs +389 -418
- package/dist/node/node.mjs +389 -418
- package/dist/types/naylence/fame/node/default-node-identity-policy.d.ts +6 -0
- package/dist/types/version.d.ts +1 -1
- package/package.json +1 -1
package/dist/node/index.mjs
CHANGED
|
@@ -13,12 +13,12 @@ import fastify from 'fastify';
|
|
|
13
13
|
import websocketPlugin from '@fastify/websocket';
|
|
14
14
|
|
|
15
15
|
// This file is auto-generated during build - do not edit manually
|
|
16
|
-
// Generated from package.json version: 0.3.
|
|
16
|
+
// Generated from package.json version: 0.3.22
|
|
17
17
|
/**
|
|
18
18
|
* The package version, injected at build time.
|
|
19
19
|
* @internal
|
|
20
20
|
*/
|
|
21
|
-
const VERSION = '0.3.
|
|
21
|
+
const VERSION = '0.3.22';
|
|
22
22
|
|
|
23
23
|
/**
|
|
24
24
|
* Fame protocol specific error classes with WebSocket close codes and proper inheritance.
|
|
@@ -836,7 +836,7 @@ class TaskCancelledError extends Error {
|
|
|
836
836
|
* Provides functionality similar to Python's asyncio TaskSpawner with proper
|
|
837
837
|
* error handling, cancellation, and graceful shutdown capabilities.
|
|
838
838
|
*/
|
|
839
|
-
const logger$
|
|
839
|
+
const logger$1g = getLogger('naylence.fame.util.task_spawner');
|
|
840
840
|
function firstDefined(source, keys) {
|
|
841
841
|
for (const key of keys) {
|
|
842
842
|
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
@@ -997,7 +997,7 @@ class TaskSpawner {
|
|
|
997
997
|
const taskId = `task-${++this._taskCounter}`;
|
|
998
998
|
const taskName = normalizedOptions.name || `unnamed-${taskId}`;
|
|
999
999
|
const timeout = normalizedOptions.timeout ?? this._config.defaultTimeout;
|
|
1000
|
-
logger$
|
|
1000
|
+
logger$1g.debug('starting_background_task', {
|
|
1001
1001
|
task_name: taskName,
|
|
1002
1002
|
task_id: taskId,
|
|
1003
1003
|
});
|
|
@@ -1014,7 +1014,7 @@ class TaskSpawner {
|
|
|
1014
1014
|
task.promise
|
|
1015
1015
|
.then(() => {
|
|
1016
1016
|
if (!this._suppressCompletionLogging) {
|
|
1017
|
-
logger$
|
|
1017
|
+
logger$1g.debug('task_completed_successfully', {
|
|
1018
1018
|
task_name: taskName,
|
|
1019
1019
|
task_id: taskId,
|
|
1020
1020
|
duration_ms: Date.now() - task.startTime,
|
|
@@ -1068,7 +1068,7 @@ class TaskSpawner {
|
|
|
1068
1068
|
error.name === 'AbortError' ||
|
|
1069
1069
|
error.message === 'Task cancelled' ||
|
|
1070
1070
|
error.message === 'Aborted') {
|
|
1071
|
-
logger$
|
|
1071
|
+
logger$1g.debug('task_cancelled', {
|
|
1072
1072
|
task_name: taskName,
|
|
1073
1073
|
note: 'Task cancelled as requested',
|
|
1074
1074
|
});
|
|
@@ -1076,7 +1076,7 @@ class TaskSpawner {
|
|
|
1076
1076
|
}
|
|
1077
1077
|
// Handle timeout
|
|
1078
1078
|
if (error instanceof TaskTimeoutError) {
|
|
1079
|
-
logger$
|
|
1079
|
+
logger$1g.warning('task_timed_out', {
|
|
1080
1080
|
task_name: taskName,
|
|
1081
1081
|
error: error.message,
|
|
1082
1082
|
});
|
|
@@ -1088,7 +1088,7 @@ class TaskSpawner {
|
|
|
1088
1088
|
// Handle known WebSocket shutdown race condition (similar to Python version)
|
|
1089
1089
|
if (error.message.includes("await wasn't used with future") ||
|
|
1090
1090
|
error.message.includes('WebSocket closed during receive')) {
|
|
1091
|
-
logger$
|
|
1091
|
+
logger$1g.debug('task_shutdown_race_condition_handled', {
|
|
1092
1092
|
task_name: taskName,
|
|
1093
1093
|
note: 'Normal WebSocket close timing during shutdown - not an error',
|
|
1094
1094
|
});
|
|
@@ -1098,7 +1098,7 @@ class TaskSpawner {
|
|
|
1098
1098
|
if (error.name === 'FameTransportClose' ||
|
|
1099
1099
|
error.message.includes('normal closure') ||
|
|
1100
1100
|
error.message.includes('Connection closed')) {
|
|
1101
|
-
logger$
|
|
1101
|
+
logger$1g.debug('task_shutdown_completed_normally', {
|
|
1102
1102
|
task_name: taskName,
|
|
1103
1103
|
note: 'Task closed normally during shutdown',
|
|
1104
1104
|
});
|
|
@@ -1106,7 +1106,7 @@ class TaskSpawner {
|
|
|
1106
1106
|
}
|
|
1107
1107
|
// Handle PKCE redirect "errors" as info
|
|
1108
1108
|
if (error.name === 'OAuth2PkceRedirectInitiatedError') {
|
|
1109
|
-
logger$
|
|
1109
|
+
logger$1g.debug('background_task_redirecting', {
|
|
1110
1110
|
task_name: taskName,
|
|
1111
1111
|
note: 'Task interrupted for PKCE redirect',
|
|
1112
1112
|
});
|
|
@@ -1119,14 +1119,14 @@ class TaskSpawner {
|
|
|
1119
1119
|
// Log retriable errors as warnings (they'll be retried by upstream logic)
|
|
1120
1120
|
// Log non-retriable errors as errors (fatal failures)
|
|
1121
1121
|
if (isRetriableError) {
|
|
1122
|
-
logger$
|
|
1122
|
+
logger$1g.warning('background_task_failed', {
|
|
1123
1123
|
task_name: taskName,
|
|
1124
1124
|
error: error.message,
|
|
1125
1125
|
retriable: true,
|
|
1126
1126
|
});
|
|
1127
1127
|
}
|
|
1128
1128
|
else {
|
|
1129
|
-
logger$
|
|
1129
|
+
logger$1g.error('background_task_failed', {
|
|
1130
1130
|
task_name: taskName,
|
|
1131
1131
|
error: error.message,
|
|
1132
1132
|
stack: error.stack,
|
|
@@ -1145,11 +1145,11 @@ class TaskSpawner {
|
|
|
1145
1145
|
async shutdownTasks(options = {}) {
|
|
1146
1146
|
const { gracePeriod, cancelHanging, joinTimeout } = normalizeShutdownOptions(options);
|
|
1147
1147
|
if (this._tasks.size === 0) {
|
|
1148
|
-
logger$
|
|
1148
|
+
logger$1g.debug('shutdown_tasks_no_tasks_to_shutdown');
|
|
1149
1149
|
return;
|
|
1150
1150
|
}
|
|
1151
1151
|
this._suppressCompletionLogging = true;
|
|
1152
|
-
logger$
|
|
1152
|
+
logger$1g.debug('shutting_down_tasks', {
|
|
1153
1153
|
task_count: this._tasks.size,
|
|
1154
1154
|
task_names: Array.from(this._tasks.values()).map((t) => t.name),
|
|
1155
1155
|
grace_period_ms: gracePeriod,
|
|
@@ -1164,7 +1164,7 @@ class TaskSpawner {
|
|
|
1164
1164
|
if (cancelHanging) {
|
|
1165
1165
|
const stillRunning = tasks.filter((task) => task.getState() === TaskState.RUNNING && !completed.has(task));
|
|
1166
1166
|
if (stillRunning.length > 0) {
|
|
1167
|
-
logger$
|
|
1167
|
+
logger$1g.debug('tasks_did_not_complete_within_grace_period', {
|
|
1168
1168
|
hanging_count: stillRunning.length,
|
|
1169
1169
|
});
|
|
1170
1170
|
// Wait for them to finish with individual timeouts
|
|
@@ -1174,7 +1174,7 @@ class TaskSpawner {
|
|
|
1174
1174
|
}
|
|
1175
1175
|
catch (error) {
|
|
1176
1176
|
if (error instanceof TaskTimeoutError) {
|
|
1177
|
-
logger$
|
|
1177
|
+
logger$1g.warning('task_did_not_shutdown', {
|
|
1178
1178
|
task_name: task.name || task.id,
|
|
1179
1179
|
join_timeout_ms: joinTimeout,
|
|
1180
1180
|
});
|
|
@@ -1185,7 +1185,7 @@ class TaskSpawner {
|
|
|
1185
1185
|
}
|
|
1186
1186
|
else if (!(error instanceof TaskCancelledError)) {
|
|
1187
1187
|
/* istanbul ignore next - unreachable defensive branch */
|
|
1188
|
-
logger$
|
|
1188
|
+
logger$1g.error('task_raised_during_cancellation', {
|
|
1189
1189
|
task_name: task.name || task.id,
|
|
1190
1190
|
error: error instanceof Error ? error.message : String(error),
|
|
1191
1191
|
});
|
|
@@ -2322,7 +2322,7 @@ async function safeImport(loader, dependencyNameOrOptions, maybeOptions) {
|
|
|
2322
2322
|
* condition/promise and ensure at most one notifier coroutine exists for a
|
|
2323
2323
|
* flow at any time.
|
|
2324
2324
|
*/
|
|
2325
|
-
const logger$
|
|
2325
|
+
const logger$1f = getLogger('naylence.fame.flow.flow_controller');
|
|
2326
2326
|
/**
|
|
2327
2327
|
* Simple condition variable implementation for TypeScript/Node.js
|
|
2328
2328
|
* Similar to Python's asyncio.Condition
|
|
@@ -2456,7 +2456,7 @@ class FlowController {
|
|
|
2456
2456
|
const newBalance = Math.max(0, Math.min(this.initialWindow, prev + delta));
|
|
2457
2457
|
this.credits.set(flowId, newBalance);
|
|
2458
2458
|
const crossedZero = prev <= 0 && newBalance > 0;
|
|
2459
|
-
logger$
|
|
2459
|
+
logger$1f.debug('flow_controller_add_credits', {
|
|
2460
2460
|
flow_id: flowId,
|
|
2461
2461
|
delta,
|
|
2462
2462
|
prev_balance: prev,
|
|
@@ -2476,12 +2476,12 @@ class FlowController {
|
|
|
2476
2476
|
async acquire(flowId) {
|
|
2477
2477
|
this.ensureFlow(flowId);
|
|
2478
2478
|
const condition = this.conditions.get(flowId);
|
|
2479
|
-
logger$
|
|
2479
|
+
logger$1f.debug('flow_controller_acquire_attempt', {
|
|
2480
2480
|
flow_id: flowId,
|
|
2481
2481
|
current_balance: this.credits.get(flowId),
|
|
2482
2482
|
});
|
|
2483
2483
|
while (this.credits.get(flowId) <= 0) {
|
|
2484
|
-
logger$
|
|
2484
|
+
logger$1f.debug('flow_controller_waiting_for_credits', {
|
|
2485
2485
|
flow_id: flowId,
|
|
2486
2486
|
current_balance: this.credits.get(flowId),
|
|
2487
2487
|
});
|
|
@@ -2489,12 +2489,12 @@ class FlowController {
|
|
|
2489
2489
|
}
|
|
2490
2490
|
const newBalance = this.credits.get(flowId) - 1;
|
|
2491
2491
|
this.credits.set(flowId, newBalance);
|
|
2492
|
-
logger$
|
|
2492
|
+
logger$1f.debug('flow_controller_acquire_success', {
|
|
2493
2493
|
flow_id: flowId,
|
|
2494
2494
|
new_balance: newBalance,
|
|
2495
2495
|
});
|
|
2496
2496
|
if (newBalance <= this.lowWatermark) {
|
|
2497
|
-
logger$
|
|
2497
|
+
logger$1f.debug('flow_controller_acquire_below_low_watermark', {
|
|
2498
2498
|
flow_id: flowId,
|
|
2499
2499
|
low_watermark: this.lowWatermark,
|
|
2500
2500
|
});
|
|
@@ -2518,7 +2518,7 @@ class FlowController {
|
|
|
2518
2518
|
const current = this.credits.get(flowId);
|
|
2519
2519
|
const remaining = Math.max(current - credits, 0);
|
|
2520
2520
|
this.credits.set(flowId, remaining);
|
|
2521
|
-
logger$
|
|
2521
|
+
logger$1f.debug('flow_controller_consume', {
|
|
2522
2522
|
flow_id: flowId,
|
|
2523
2523
|
requested: credits,
|
|
2524
2524
|
prev_balance: current,
|
|
@@ -2544,7 +2544,7 @@ class FlowController {
|
|
|
2544
2544
|
this.windowIds.delete(flowId);
|
|
2545
2545
|
this.credits.set(flowId, this.initialWindow);
|
|
2546
2546
|
this.wakeWaiters(flowId);
|
|
2547
|
-
logger$
|
|
2547
|
+
logger$1f.debug('flow_controller_flow_reset', {
|
|
2548
2548
|
flow_id: flowId,
|
|
2549
2549
|
reset_balance: this.initialWindow,
|
|
2550
2550
|
});
|
|
@@ -2832,7 +2832,7 @@ class InMemoryBinding {
|
|
|
2832
2832
|
* TypeScript port of Python's InMemoryFanoutBroker that extends TaskSpawner
|
|
2833
2833
|
* to manage multiple WriteChannel subscribers with concurrent message distribution.
|
|
2834
2834
|
*/
|
|
2835
|
-
const logger$
|
|
2835
|
+
const logger$1e = getLogger('naylence.fame.channel.in_memory.in_memory_fanout_broker');
|
|
2836
2836
|
// Sentinel object for shutdown signaling
|
|
2837
2837
|
const SENTINEL = Symbol('fanout-broker-sentinel');
|
|
2838
2838
|
function isCloseable(obj) {
|
|
@@ -2885,7 +2885,7 @@ class InMemoryFanoutBroker extends TaskSpawner {
|
|
|
2885
2885
|
}
|
|
2886
2886
|
catch (error) {
|
|
2887
2887
|
// Ignore errors when sending sentinel (sink might be closed)
|
|
2888
|
-
logger$
|
|
2888
|
+
logger$1e.debug('error_sending_sentinel', {
|
|
2889
2889
|
error: error.message,
|
|
2890
2890
|
});
|
|
2891
2891
|
}
|
|
@@ -2899,7 +2899,7 @@ class InMemoryFanoutBroker extends TaskSpawner {
|
|
|
2899
2899
|
await sub.close();
|
|
2900
2900
|
}
|
|
2901
2901
|
catch (error) {
|
|
2902
|
-
logger$
|
|
2902
|
+
logger$1e.error('error_closing_subscriber', {
|
|
2903
2903
|
subscriber: sub.toString(),
|
|
2904
2904
|
error: error.message,
|
|
2905
2905
|
});
|
|
@@ -2939,7 +2939,7 @@ class InMemoryFanoutBroker extends TaskSpawner {
|
|
|
2939
2939
|
[envelope, context] = extractEnvelopeAndContext(msg);
|
|
2940
2940
|
}
|
|
2941
2941
|
catch (error) {
|
|
2942
|
-
logger$
|
|
2942
|
+
logger$1e.debug('failed_to_extract_envelope', {
|
|
2943
2943
|
error: error.message,
|
|
2944
2944
|
});
|
|
2945
2945
|
continue;
|
|
@@ -2961,7 +2961,7 @@ class InMemoryFanoutBroker extends TaskSpawner {
|
|
|
2961
2961
|
await sub.send(messageToSend);
|
|
2962
2962
|
}
|
|
2963
2963
|
catch (error) {
|
|
2964
|
-
logger$
|
|
2964
|
+
logger$1e.error('error_sending_to_subscriber', {
|
|
2965
2965
|
subscriber: sub.toString(),
|
|
2966
2966
|
error: error.message,
|
|
2967
2967
|
action: 'unsubscribing',
|
|
@@ -2977,7 +2977,7 @@ class InMemoryFanoutBroker extends TaskSpawner {
|
|
|
2977
2977
|
}
|
|
2978
2978
|
catch (error) {
|
|
2979
2979
|
// Critical broker-level error: log and back off, but keep the loop running
|
|
2980
|
-
logger$
|
|
2980
|
+
logger$1e.critical('receive_loop_failed_unexpectedly', {
|
|
2981
2981
|
error: error.message,
|
|
2982
2982
|
stack: error.stack,
|
|
2983
2983
|
});
|
|
@@ -4653,7 +4653,7 @@ function normalizeResponseType(value) {
|
|
|
4653
4653
|
return value;
|
|
4654
4654
|
}
|
|
4655
4655
|
|
|
4656
|
-
const logger$
|
|
4656
|
+
const logger$1d = getLogger('naylence.fame.node.binding_manager');
|
|
4657
4657
|
const SYSTEM_INBOX$3 = '__sys__';
|
|
4658
4658
|
const DEFAULT_ACK_TIMEOUT_MS = 20000;
|
|
4659
4659
|
class BindingStoreEntryRecord {
|
|
@@ -4739,7 +4739,7 @@ class BindingManager {
|
|
|
4739
4739
|
if (!this.bindings.has(key)) {
|
|
4740
4740
|
const binding = this.bindingFactory(new FameAddress(key));
|
|
4741
4741
|
this.bindings.set(key, binding);
|
|
4742
|
-
logger$
|
|
4742
|
+
logger$1d.debug('restored_binding', { address: key });
|
|
4743
4743
|
}
|
|
4744
4744
|
}
|
|
4745
4745
|
if (!this.hasUpstream) {
|
|
@@ -4749,13 +4749,13 @@ class BindingManager {
|
|
|
4749
4749
|
await this.readvertiseCapabilitiesUpstream();
|
|
4750
4750
|
}
|
|
4751
4751
|
async bind(participant, capabilities) {
|
|
4752
|
-
logger$
|
|
4752
|
+
logger$1d.debug('binding_participant', { participant });
|
|
4753
4753
|
const { prefixAddress, addresses, propagateAddress, capabilityAddress } = this.computeBindingAddresses(participant);
|
|
4754
4754
|
for (const address of addresses) {
|
|
4755
4755
|
if (!this.bindings.has(address)) {
|
|
4756
4756
|
const binding = this.bindingFactory(new FameAddress(address));
|
|
4757
4757
|
this.bindings.set(address, binding);
|
|
4758
|
-
logger$
|
|
4758
|
+
logger$1d.debug('bound_address', { address, participant });
|
|
4759
4759
|
}
|
|
4760
4760
|
}
|
|
4761
4761
|
let propagatedAddress = null;
|
|
@@ -4784,7 +4784,7 @@ class BindingManager {
|
|
|
4784
4784
|
await this.unbindAddressUpstream(propagatedAddress);
|
|
4785
4785
|
}
|
|
4786
4786
|
catch (rollbackError) {
|
|
4787
|
-
logger$
|
|
4787
|
+
logger$1d.error('bind_rollback_failed', {
|
|
4788
4788
|
address: propagatedAddress.toString(),
|
|
4789
4789
|
error: rollbackError.message,
|
|
4790
4790
|
});
|
|
@@ -4803,7 +4803,7 @@ class BindingManager {
|
|
|
4803
4803
|
physicalPath: null,
|
|
4804
4804
|
});
|
|
4805
4805
|
}
|
|
4806
|
-
logger$
|
|
4806
|
+
logger$1d.debug('bind_success', {
|
|
4807
4807
|
participant,
|
|
4808
4808
|
address: prefixAddress.toString(),
|
|
4809
4809
|
capabilities,
|
|
@@ -4839,7 +4839,7 @@ class BindingManager {
|
|
|
4839
4839
|
await this.bindingStore.delete(address);
|
|
4840
4840
|
}
|
|
4841
4841
|
}
|
|
4842
|
-
logger$
|
|
4842
|
+
logger$1d.debug('unbind_success', {
|
|
4843
4843
|
participant,
|
|
4844
4844
|
address: prefixAddress.toString(),
|
|
4845
4845
|
totalBindings: this.bindings.size,
|
|
@@ -4869,7 +4869,7 @@ class BindingManager {
|
|
|
4869
4869
|
await this.bindAddressUpstream(new FameAddress(address));
|
|
4870
4870
|
}
|
|
4871
4871
|
catch (error) {
|
|
4872
|
-
logger$
|
|
4872
|
+
logger$1d.error('rebind_failed', {
|
|
4873
4873
|
address,
|
|
4874
4874
|
error: error.message,
|
|
4875
4875
|
});
|
|
@@ -4888,7 +4888,7 @@ class BindingManager {
|
|
|
4888
4888
|
await this.advertiseCapabilities(new FameAddress(address), Array.from(capabilities));
|
|
4889
4889
|
}
|
|
4890
4890
|
catch (error) {
|
|
4891
|
-
logger$
|
|
4891
|
+
logger$1d.error('capability_replay_failed', {
|
|
4892
4892
|
address,
|
|
4893
4893
|
error: error.message,
|
|
4894
4894
|
});
|
|
@@ -5155,7 +5155,7 @@ class BindingManager {
|
|
|
5155
5155
|
}
|
|
5156
5156
|
}
|
|
5157
5157
|
|
|
5158
|
-
const logger$
|
|
5158
|
+
const logger$1c = getLogger('naylence.fame.node.response_context_manager');
|
|
5159
5159
|
function cloneSecurityContext(source) {
|
|
5160
5160
|
if (!source) {
|
|
5161
5161
|
return undefined;
|
|
@@ -5183,7 +5183,7 @@ class ResponseContextManager {
|
|
|
5183
5183
|
security: responseSecurity,
|
|
5184
5184
|
expectedResponseType: FameResponseType.NONE,
|
|
5185
5185
|
};
|
|
5186
|
-
logger$
|
|
5186
|
+
logger$1c.debug('created_response_context', {
|
|
5187
5187
|
request_id: requestEnvelope.id,
|
|
5188
5188
|
inherited_crypto_level: responseSecurity?.inboundCryptoLevel ?? null,
|
|
5189
5189
|
channel_id: responseSecurity?.cryptoChannelId ?? null,
|
|
@@ -5203,14 +5203,14 @@ class ResponseContextManager {
|
|
|
5203
5203
|
responseContext.fromSystemId = this.getId();
|
|
5204
5204
|
}
|
|
5205
5205
|
// Envelope-level metadata is intentionally omitted to defer to context usage.
|
|
5206
|
-
logger$
|
|
5206
|
+
logger$1c.debug('ensured_response_metadata', {
|
|
5207
5207
|
response_id: responseEnvelope.id,
|
|
5208
5208
|
request_id: requestEnvelope.id,
|
|
5209
5209
|
});
|
|
5210
5210
|
}
|
|
5211
5211
|
}
|
|
5212
5212
|
|
|
5213
|
-
const logger$
|
|
5213
|
+
const logger$1b = getLogger('naylence.fame.node.streaming_response_handler');
|
|
5214
5214
|
function isObject(value) {
|
|
5215
5215
|
return typeof value === 'object' && value !== null;
|
|
5216
5216
|
}
|
|
@@ -5329,12 +5329,12 @@ class StreamingResponseHandler {
|
|
|
5329
5329
|
}
|
|
5330
5330
|
async handleStreamingFameMessageResponses(responses, requestEnvelope, requestContext) {
|
|
5331
5331
|
const asyncResponses = toAsyncIterable(responses);
|
|
5332
|
-
logger$
|
|
5332
|
+
logger$1b.debug('handling_streaming_fame_message_responses', {
|
|
5333
5333
|
request_id: requestEnvelope.id,
|
|
5334
5334
|
});
|
|
5335
5335
|
for await (const response of asyncResponses) {
|
|
5336
5336
|
if (!response?.envelope) {
|
|
5337
|
-
logger$
|
|
5337
|
+
logger$1b.warning('invalid_streaming_response_type', {
|
|
5338
5338
|
request_id: requestEnvelope.id,
|
|
5339
5339
|
actual_type: typeof response,
|
|
5340
5340
|
});
|
|
@@ -5348,7 +5348,7 @@ class StreamingResponseHandler {
|
|
|
5348
5348
|
}
|
|
5349
5349
|
async handleStreamingResponse(result, requestEnvelope, requestContext, replyTo, requestId) {
|
|
5350
5350
|
const iterable = toAsyncIterable(result);
|
|
5351
|
-
logger$
|
|
5351
|
+
logger$1b.debug('handling_streaming_response', {
|
|
5352
5352
|
request_id: requestId,
|
|
5353
5353
|
reply_to: replyTo,
|
|
5354
5354
|
});
|
|
@@ -5359,7 +5359,7 @@ class StreamingResponseHandler {
|
|
|
5359
5359
|
await this.sendRpcResponse(null, requestEnvelope, requestContext, replyTo, requestId);
|
|
5360
5360
|
}
|
|
5361
5361
|
catch (error) {
|
|
5362
|
-
logger$
|
|
5362
|
+
logger$1b.error('streaming_response_handler_error', {
|
|
5363
5363
|
request_id: requestId,
|
|
5364
5364
|
error: error instanceof Error ? error.message : String(error),
|
|
5365
5365
|
});
|
|
@@ -5386,7 +5386,7 @@ class StreamingResponseHandler {
|
|
|
5386
5386
|
});
|
|
5387
5387
|
const responseContext = this.responseContextManager.createResponseContext(requestEnvelope, requestContext);
|
|
5388
5388
|
this.responseContextManager.ensureResponseMetadata(responseEnvelope, requestEnvelope, responseContext);
|
|
5389
|
-
logger$
|
|
5389
|
+
logger$1b.debug('sending_streaming_rpc_response', {
|
|
5390
5390
|
request_id: requestId,
|
|
5391
5391
|
response_envelope_id: responseEnvelope.id,
|
|
5392
5392
|
reply_to: replyTo,
|
|
@@ -5399,7 +5399,7 @@ class StreamingResponseHandler {
|
|
|
5399
5399
|
}
|
|
5400
5400
|
}
|
|
5401
5401
|
|
|
5402
|
-
const logger$
|
|
5402
|
+
const logger$1a = getLogger('naylence.fame.node.channel_polling_manager');
|
|
5403
5403
|
class ChannelPollingManager {
|
|
5404
5404
|
constructor(deliverWrapper, responseContextManager, streamingResponseHandler) {
|
|
5405
5405
|
this.deliverWrapper = deliverWrapper;
|
|
@@ -5407,7 +5407,7 @@ class ChannelPollingManager {
|
|
|
5407
5407
|
this.streamingResponseHandler = streamingResponseHandler;
|
|
5408
5408
|
}
|
|
5409
5409
|
async startPollingLoop(serviceName, channel, handler, stopState, pollTimeoutMs = DEFAULT_POLLING_TIMEOUT_MS) {
|
|
5410
|
-
logger$
|
|
5410
|
+
logger$1a.debug('poll_loop_started', {
|
|
5411
5411
|
recipient: serviceName,
|
|
5412
5412
|
});
|
|
5413
5413
|
try {
|
|
@@ -5415,7 +5415,7 @@ class ChannelPollingManager {
|
|
|
5415
5415
|
while (true) {
|
|
5416
5416
|
if (this.isStopRequested(stopState) && !draining) {
|
|
5417
5417
|
draining = true;
|
|
5418
|
-
logger$
|
|
5418
|
+
logger$1a.debug('poll_loop_draining_pending_messages', {
|
|
5419
5419
|
recipient: serviceName,
|
|
5420
5420
|
});
|
|
5421
5421
|
}
|
|
@@ -5425,7 +5425,7 @@ class ChannelPollingManager {
|
|
|
5425
5425
|
}
|
|
5426
5426
|
catch (error) {
|
|
5427
5427
|
if (error instanceof FameTransportClose) {
|
|
5428
|
-
logger$
|
|
5428
|
+
logger$1a.debug('channel_closed', {
|
|
5429
5429
|
recipient: serviceName,
|
|
5430
5430
|
message: error.message,
|
|
5431
5431
|
});
|
|
@@ -5438,7 +5438,7 @@ class ChannelPollingManager {
|
|
|
5438
5438
|
continue;
|
|
5439
5439
|
}
|
|
5440
5440
|
if (error instanceof Error && error.name === 'AbortError') {
|
|
5441
|
-
logger$
|
|
5441
|
+
logger$1a.debug('listener_cancelled', {
|
|
5442
5442
|
recipient: serviceName,
|
|
5443
5443
|
});
|
|
5444
5444
|
throw error;
|
|
@@ -5450,13 +5450,13 @@ class ChannelPollingManager {
|
|
|
5450
5450
|
continue;
|
|
5451
5451
|
}
|
|
5452
5452
|
if (error instanceof Error && error.message === 'Channel is closed') {
|
|
5453
|
-
logger$
|
|
5453
|
+
logger$1a.debug('channel_closed', {
|
|
5454
5454
|
recipient: serviceName,
|
|
5455
5455
|
});
|
|
5456
5456
|
break;
|
|
5457
5457
|
}
|
|
5458
5458
|
if (error instanceof Error && error.name === 'TaskCancelledError') {
|
|
5459
|
-
logger$
|
|
5459
|
+
logger$1a.debug('listener_cancelled', {
|
|
5460
5460
|
recipient: serviceName,
|
|
5461
5461
|
});
|
|
5462
5462
|
throw error;
|
|
@@ -5468,12 +5468,12 @@ class ChannelPollingManager {
|
|
|
5468
5468
|
continue;
|
|
5469
5469
|
}
|
|
5470
5470
|
if (error instanceof Error && error.message.includes('closed')) {
|
|
5471
|
-
logger$
|
|
5471
|
+
logger$1a.debug('channel_closed', {
|
|
5472
5472
|
recipient: serviceName,
|
|
5473
5473
|
});
|
|
5474
5474
|
break;
|
|
5475
5475
|
}
|
|
5476
|
-
logger$
|
|
5476
|
+
logger$1a.error('transport_error', {
|
|
5477
5477
|
recipient: serviceName,
|
|
5478
5478
|
error: error instanceof Error ? error.message : String(error),
|
|
5479
5479
|
});
|
|
@@ -5489,7 +5489,7 @@ class ChannelPollingManager {
|
|
|
5489
5489
|
}
|
|
5490
5490
|
}
|
|
5491
5491
|
finally {
|
|
5492
|
-
logger$
|
|
5492
|
+
logger$1a.debug('poll_loop_exiting', {
|
|
5493
5493
|
recipient: serviceName,
|
|
5494
5494
|
});
|
|
5495
5495
|
}
|
|
@@ -5502,7 +5502,7 @@ class ChannelPollingManager {
|
|
|
5502
5502
|
await this.processHandlerResult(result, envelope, deliveryContext, serviceName);
|
|
5503
5503
|
}
|
|
5504
5504
|
catch (error) {
|
|
5505
|
-
logger$
|
|
5505
|
+
logger$1a.error('handler_crashed', {
|
|
5506
5506
|
recipient: serviceName,
|
|
5507
5507
|
error: error instanceof Error ? error.message : String(error),
|
|
5508
5508
|
});
|
|
@@ -5516,7 +5516,7 @@ class ChannelPollingManager {
|
|
|
5516
5516
|
return;
|
|
5517
5517
|
}
|
|
5518
5518
|
if (this.streamingResponseHandler.isStreamingFameMessageResponse(result)) {
|
|
5519
|
-
logger$
|
|
5519
|
+
logger$1a.debug('handling_streaming_fame_message_responses', {
|
|
5520
5520
|
service_name: serviceName,
|
|
5521
5521
|
envelope_id: envelope.id,
|
|
5522
5522
|
});
|
|
@@ -5524,7 +5524,7 @@ class ChannelPollingManager {
|
|
|
5524
5524
|
}
|
|
5525
5525
|
}
|
|
5526
5526
|
async handleMessageResponse(response, requestEnvelope, requestContext, serviceName) {
|
|
5527
|
-
logger$
|
|
5527
|
+
logger$1a.debug('delivering_envelope_response_message', {
|
|
5528
5528
|
service_name: serviceName,
|
|
5529
5529
|
response_envelope_id: response.envelope.id,
|
|
5530
5530
|
});
|
|
@@ -5544,7 +5544,7 @@ class ChannelPollingManager {
|
|
|
5544
5544
|
}
|
|
5545
5545
|
}
|
|
5546
5546
|
|
|
5547
|
-
const logger$
|
|
5547
|
+
const logger$19 = getLogger('naylence.fame.node.rpc_server_handler');
|
|
5548
5548
|
function isPlainRecord$6(value) {
|
|
5549
5549
|
if (typeof value !== 'object' || value === null) {
|
|
5550
5550
|
return false;
|
|
@@ -5588,13 +5588,13 @@ class RPCServerHandler {
|
|
|
5588
5588
|
}
|
|
5589
5589
|
async handleRpcRequest(envelope, handlerContext, handler, serviceName) {
|
|
5590
5590
|
if (!this.isDataFrame(envelope.frame)) {
|
|
5591
|
-
logger$
|
|
5591
|
+
logger$19.warning('rpc_request_missing_data_frame', {
|
|
5592
5592
|
service_name: serviceName,
|
|
5593
5593
|
envelope_id: envelope.id,
|
|
5594
5594
|
});
|
|
5595
5595
|
return;
|
|
5596
5596
|
}
|
|
5597
|
-
logger$
|
|
5597
|
+
logger$19.debug('rpc_request_received', {
|
|
5598
5598
|
service_name: serviceName,
|
|
5599
5599
|
envelope_id: envelope.id,
|
|
5600
5600
|
trace_id: envelope.traceId,
|
|
@@ -5606,7 +5606,7 @@ class RPCServerHandler {
|
|
|
5606
5606
|
request = parseRequest(envelope.frame.payload);
|
|
5607
5607
|
params = cloneParams(request.params);
|
|
5608
5608
|
const paramKeys = Object.keys(params);
|
|
5609
|
-
logger$
|
|
5609
|
+
logger$19.debug('parsed_rpc_request', {
|
|
5610
5610
|
service_name: serviceName,
|
|
5611
5611
|
method: request.method,
|
|
5612
5612
|
request_id: request.id,
|
|
@@ -5615,7 +5615,7 @@ class RPCServerHandler {
|
|
|
5615
5615
|
});
|
|
5616
5616
|
}
|
|
5617
5617
|
catch (error) {
|
|
5618
|
-
logger$
|
|
5618
|
+
logger$19.warning('request_decode_error', {
|
|
5619
5619
|
service_name: serviceName,
|
|
5620
5620
|
envelope_id: envelope.id,
|
|
5621
5621
|
error: error instanceof Error ? error.message : String(error),
|
|
@@ -5623,7 +5623,7 @@ class RPCServerHandler {
|
|
|
5623
5623
|
return;
|
|
5624
5624
|
}
|
|
5625
5625
|
if (request.id == null) {
|
|
5626
|
-
logger$
|
|
5626
|
+
logger$19.warning('request_missing_id', {
|
|
5627
5627
|
service_name: serviceName,
|
|
5628
5628
|
envelope_id: envelope.id,
|
|
5629
5629
|
});
|
|
@@ -5631,7 +5631,7 @@ class RPCServerHandler {
|
|
|
5631
5631
|
}
|
|
5632
5632
|
const replyTo = this.resolveReplyTo(envelope, params);
|
|
5633
5633
|
if (!replyTo) {
|
|
5634
|
-
logger$
|
|
5634
|
+
logger$19.warning('missing_reply_to', {
|
|
5635
5635
|
service_name: serviceName,
|
|
5636
5636
|
envelope_id: envelope.id,
|
|
5637
5637
|
request_id: request.id,
|
|
@@ -5640,13 +5640,13 @@ class RPCServerHandler {
|
|
|
5640
5640
|
}
|
|
5641
5641
|
let handlerResult;
|
|
5642
5642
|
try {
|
|
5643
|
-
logger$
|
|
5643
|
+
logger$19.debug('calling_rpc_handler', {
|
|
5644
5644
|
service_name: serviceName,
|
|
5645
5645
|
method: request.method,
|
|
5646
5646
|
request_id: request.id,
|
|
5647
5647
|
});
|
|
5648
5648
|
handlerResult = await handler(request.method, params);
|
|
5649
|
-
logger$
|
|
5649
|
+
logger$19.debug('rpc_handler_returned', {
|
|
5650
5650
|
service_name: serviceName,
|
|
5651
5651
|
method: request.method,
|
|
5652
5652
|
request_id: request.id,
|
|
@@ -5655,7 +5655,7 @@ class RPCServerHandler {
|
|
|
5655
5655
|
});
|
|
5656
5656
|
}
|
|
5657
5657
|
catch (error) {
|
|
5658
|
-
logger$
|
|
5658
|
+
logger$19.error('rpc_handler_error', {
|
|
5659
5659
|
service_name: serviceName,
|
|
5660
5660
|
request_id: request.id,
|
|
5661
5661
|
envelope_id: envelope.id,
|
|
@@ -5665,7 +5665,7 @@ class RPCServerHandler {
|
|
|
5665
5665
|
return this.createTraditionalResponse(response, request.id, envelope, replyTo, handlerContext, serviceName);
|
|
5666
5666
|
}
|
|
5667
5667
|
if (isFameMessageResponse(handlerResult)) {
|
|
5668
|
-
logger$
|
|
5668
|
+
logger$19.debug('returning_response_message', {
|
|
5669
5669
|
service_name: serviceName,
|
|
5670
5670
|
request_id: request.id,
|
|
5671
5671
|
response_envelope_id: handlerResult.envelope.id,
|
|
@@ -5673,7 +5673,7 @@ class RPCServerHandler {
|
|
|
5673
5673
|
return handlerResult;
|
|
5674
5674
|
}
|
|
5675
5675
|
if (this.streamingResponseHandler.isStreamingResult(handlerResult)) {
|
|
5676
|
-
logger$
|
|
5676
|
+
logger$19.debug('handling_streaming_response', {
|
|
5677
5677
|
service_name: serviceName,
|
|
5678
5678
|
request_id: request.id,
|
|
5679
5679
|
envelope_id: envelope.id,
|
|
@@ -5702,7 +5702,7 @@ class RPCServerHandler {
|
|
|
5702
5702
|
return null;
|
|
5703
5703
|
}
|
|
5704
5704
|
async createTraditionalResponse(payload, requestId, requestEnvelope, replyTo, handlerContext, serviceName) {
|
|
5705
|
-
logger$
|
|
5705
|
+
logger$19.debug('creating_traditional_response_envelope', {
|
|
5706
5706
|
service_name: serviceName,
|
|
5707
5707
|
request_id: requestId,
|
|
5708
5708
|
envelope_id: requestEnvelope.id,
|
|
@@ -5726,7 +5726,7 @@ class RPCServerHandler {
|
|
|
5726
5726
|
if (requestEnvelope.id) {
|
|
5727
5727
|
responseContext.meta['response-to-id'] = requestEnvelope.id;
|
|
5728
5728
|
}
|
|
5729
|
-
logger$
|
|
5729
|
+
logger$19.debug('returning_traditional_response', {
|
|
5730
5730
|
service_name: serviceName,
|
|
5731
5731
|
request_id: requestId,
|
|
5732
5732
|
envelope_id: requestEnvelope.id,
|
|
@@ -5791,7 +5791,7 @@ function normalizeErrorCode(code) {
|
|
|
5791
5791
|
return code;
|
|
5792
5792
|
}
|
|
5793
5793
|
|
|
5794
|
-
const logger$
|
|
5794
|
+
const logger$18 = getLogger('naylence.fame.node.rpc_client_manager');
|
|
5795
5795
|
function isPlainRecord$5(value) {
|
|
5796
5796
|
if (typeof value !== 'object' || value === null) {
|
|
5797
5797
|
return false;
|
|
@@ -6008,7 +6008,7 @@ class RPCClientManager {
|
|
|
6008
6008
|
const metaReason = tracked.meta?.['nack_reason'];
|
|
6009
6009
|
const formattedMessage = formatDeliveryErrorMessage(typeof metaCode === 'string' ? metaCode : 'DELIVERY_ERROR', reason ??
|
|
6010
6010
|
(typeof metaReason === 'string' ? metaReason : undefined));
|
|
6011
|
-
logger$
|
|
6011
|
+
logger$18.debug('pending_request_rejected_by_delivery_nack', {
|
|
6012
6012
|
envelope_id: envelopeId,
|
|
6013
6013
|
request_id: requestId,
|
|
6014
6014
|
code: typeof metaCode === 'string' ? metaCode : 'DELIVERY_ERROR',
|
|
@@ -6031,7 +6031,7 @@ class RPCClientManager {
|
|
|
6031
6031
|
this.trackerWithEvents.removeEventHandler?.(this.trackerEventHandler);
|
|
6032
6032
|
}
|
|
6033
6033
|
catch (error) {
|
|
6034
|
-
logger$
|
|
6034
|
+
logger$18.debug('rpc_tracker_handler_remove_failed', {
|
|
6035
6035
|
error: error instanceof Error ? error.message : String(error),
|
|
6036
6036
|
});
|
|
6037
6037
|
}
|
|
@@ -6074,7 +6074,7 @@ class RPCClientManager {
|
|
|
6074
6074
|
this.rpcListenerAddress = await this.listenCallback(recipient, handler);
|
|
6075
6075
|
this.rpcBound = true;
|
|
6076
6076
|
this.boundPhysicalPath = currentPhysicalPath;
|
|
6077
|
-
logger$
|
|
6077
|
+
logger$18.debug('rpc_reply_listener_bound', {
|
|
6078
6078
|
reply_recipient: recipient,
|
|
6079
6079
|
reply_address: this.rpcReplyAddress?.toString(),
|
|
6080
6080
|
listener_address: this.rpcListenerAddress?.toString(),
|
|
@@ -6168,7 +6168,7 @@ class RPCClientManager {
|
|
|
6168
6168
|
const finalizePromise = this.notifyStreamClosed(envelopeId);
|
|
6169
6169
|
if (finalizePromise) {
|
|
6170
6170
|
finalizePromise.catch((notifyError) => {
|
|
6171
|
-
logger$
|
|
6171
|
+
logger$18.debug('stream_tracker_finalize_failed', {
|
|
6172
6172
|
request_id: requestId,
|
|
6173
6173
|
envelope_id: envelopeId,
|
|
6174
6174
|
error: notifyError instanceof Error
|
|
@@ -6229,7 +6229,7 @@ class RPCClientManager {
|
|
|
6229
6229
|
return iterator;
|
|
6230
6230
|
}
|
|
6231
6231
|
async sendRpcRequest(requestId, envelope, expectedResponseType, timeoutMs) {
|
|
6232
|
-
logger$
|
|
6232
|
+
logger$18.debug('sending_rpc_request', {
|
|
6233
6233
|
envp_id: envelope.id,
|
|
6234
6234
|
corr_id: envelope.corrId,
|
|
6235
6235
|
request_id: requestId,
|
|
@@ -6245,7 +6245,7 @@ class RPCClientManager {
|
|
|
6245
6245
|
}
|
|
6246
6246
|
}
|
|
6247
6247
|
catch (error) {
|
|
6248
|
-
logger$
|
|
6248
|
+
logger$18.warning('delivery_tracker_track_failed', {
|
|
6249
6249
|
request_id: requestId,
|
|
6250
6250
|
error: error instanceof Error ? error.message : String(error),
|
|
6251
6251
|
});
|
|
@@ -6258,14 +6258,14 @@ class RPCClientManager {
|
|
|
6258
6258
|
await this.deliverWrapper()(envelope, context);
|
|
6259
6259
|
}
|
|
6260
6260
|
async handleReplyEnvelope(envelope) {
|
|
6261
|
-
logger$
|
|
6261
|
+
logger$18.debug('handle_reply_envelope_received', {
|
|
6262
6262
|
envelope_id: envelope.id,
|
|
6263
6263
|
corr_id: envelope.corrId,
|
|
6264
6264
|
frame_type: envelope.frame?.['type'],
|
|
6265
6265
|
});
|
|
6266
6266
|
let requestId = envelope.corrId ?? envelope.id;
|
|
6267
6267
|
if (!requestId) {
|
|
6268
|
-
logger$
|
|
6268
|
+
logger$18.warning('reply_envelope_missing_corr_id', {
|
|
6269
6269
|
envelope_id: envelope.id,
|
|
6270
6270
|
});
|
|
6271
6271
|
return;
|
|
@@ -6283,12 +6283,12 @@ class RPCClientManager {
|
|
|
6283
6283
|
}
|
|
6284
6284
|
}
|
|
6285
6285
|
if (!entry) {
|
|
6286
|
-
logger$
|
|
6286
|
+
logger$18.debug('no_pending_request_for_reply', {
|
|
6287
6287
|
request_id: requestId,
|
|
6288
6288
|
});
|
|
6289
6289
|
return;
|
|
6290
6290
|
}
|
|
6291
|
-
logger$
|
|
6291
|
+
logger$18.debug('handle_reply_envelope', {
|
|
6292
6292
|
envelope_id: envelope.id,
|
|
6293
6293
|
request_id: requestId,
|
|
6294
6294
|
corr_id: envelope.corrId,
|
|
@@ -6301,7 +6301,7 @@ class RPCClientManager {
|
|
|
6301
6301
|
const ackIndicatesSuccess = frame.ok === true ||
|
|
6302
6302
|
(frame.ok === undefined && !frame.code && !frame.reason);
|
|
6303
6303
|
if (ackIndicatesSuccess) {
|
|
6304
|
-
logger$
|
|
6304
|
+
logger$18.debug('pending_request_delivery_acknowledged', {
|
|
6305
6305
|
request_id: requestId,
|
|
6306
6306
|
envelope_id: envelope.id,
|
|
6307
6307
|
ref_id: frame.refId ?? null,
|
|
@@ -6329,7 +6329,7 @@ class RPCClientManager {
|
|
|
6329
6329
|
entry.timer = null;
|
|
6330
6330
|
}
|
|
6331
6331
|
if (!this.isDataFrame(envelope.frame)) {
|
|
6332
|
-
logger$
|
|
6332
|
+
logger$18.warning('unexpected_reply_frame_type', {
|
|
6333
6333
|
request_id: requestId,
|
|
6334
6334
|
frame_type: envelope.frame?.['type'],
|
|
6335
6335
|
});
|
|
@@ -6395,7 +6395,7 @@ class RPCClientManager {
|
|
|
6395
6395
|
return;
|
|
6396
6396
|
}
|
|
6397
6397
|
Promise.resolve(this.deliveryTracker.onStreamItem(envelopeId, envelope)).catch((error) => {
|
|
6398
|
-
logger$
|
|
6398
|
+
logger$18.debug('stream_tracker_push_failed', {
|
|
6399
6399
|
envelope_id: envelopeId,
|
|
6400
6400
|
error: error instanceof Error ? error.message : String(error),
|
|
6401
6401
|
});
|
|
@@ -6510,7 +6510,7 @@ function normalizeMailbox(mailbox) {
|
|
|
6510
6510
|
return mailbox;
|
|
6511
6511
|
}
|
|
6512
6512
|
|
|
6513
|
-
const logger$
|
|
6513
|
+
const logger$17 = getLogger('naylence.fame.node.envelope_listener_manager');
|
|
6514
6514
|
const SYSTEM_INBOX$2 = '__sys__';
|
|
6515
6515
|
class EnvelopeListener {
|
|
6516
6516
|
constructor(stopFn, task) {
|
|
@@ -6518,7 +6518,7 @@ class EnvelopeListener {
|
|
|
6518
6518
|
this.task = task;
|
|
6519
6519
|
}
|
|
6520
6520
|
stop() {
|
|
6521
|
-
logger$
|
|
6521
|
+
logger$17.debug('stopping_listener', {
|
|
6522
6522
|
task_name: this.task.name,
|
|
6523
6523
|
});
|
|
6524
6524
|
try {
|
|
@@ -6526,7 +6526,7 @@ class EnvelopeListener {
|
|
|
6526
6526
|
if (maybeCleanup &&
|
|
6527
6527
|
typeof maybeCleanup.then === 'function') {
|
|
6528
6528
|
void maybeCleanup.catch((error) => {
|
|
6529
|
-
logger$
|
|
6529
|
+
logger$17.debug('listener_stop_cleanup_failed', {
|
|
6530
6530
|
task_name: this.task.name,
|
|
6531
6531
|
error: error instanceof Error ? error.message : String(error),
|
|
6532
6532
|
});
|
|
@@ -6534,7 +6534,7 @@ class EnvelopeListener {
|
|
|
6534
6534
|
}
|
|
6535
6535
|
}
|
|
6536
6536
|
catch (error) {
|
|
6537
|
-
logger$
|
|
6537
|
+
logger$17.debug('listener_stop_cleanup_failed', {
|
|
6538
6538
|
task_name: this.task.name,
|
|
6539
6539
|
error: error instanceof Error ? error.message : String(error),
|
|
6540
6540
|
});
|
|
@@ -6564,7 +6564,7 @@ class EnvelopeListenerManager extends TaskSpawner {
|
|
|
6564
6564
|
envelope.replyTo = formatAddress(SYSTEM_INBOX$2, this.nodeLike.physicalPath);
|
|
6565
6565
|
}
|
|
6566
6566
|
catch (error) {
|
|
6567
|
-
logger$
|
|
6567
|
+
logger$17.warning('default_reply_to_assignment_failed', {
|
|
6568
6568
|
envelope_id: envelope.id,
|
|
6569
6569
|
service_name: envelope.capabilities?.[0] ?? null,
|
|
6570
6570
|
error: error instanceof Error ? error.message : String(error),
|
|
@@ -6589,7 +6589,7 @@ class EnvelopeListenerManager extends TaskSpawner {
|
|
|
6589
6589
|
if (serviceName === SYSTEM_INBOX$2) {
|
|
6590
6590
|
continue;
|
|
6591
6591
|
}
|
|
6592
|
-
logger$
|
|
6592
|
+
logger$17.debug('stopping_listener_for_service', {
|
|
6593
6593
|
service_name: serviceName,
|
|
6594
6594
|
});
|
|
6595
6595
|
entry.listener.stop();
|
|
@@ -6599,7 +6599,7 @@ class EnvelopeListenerManager extends TaskSpawner {
|
|
|
6599
6599
|
catch (error) {
|
|
6600
6600
|
if (!(error instanceof Error) ||
|
|
6601
6601
|
error.name !== 'TaskCancelledError') {
|
|
6602
|
-
logger$
|
|
6602
|
+
logger$17.debug('listener_task_stopped', {
|
|
6603
6603
|
service_name: serviceName,
|
|
6604
6604
|
error: error instanceof Error ? error.message : String(error),
|
|
6605
6605
|
});
|
|
@@ -6607,7 +6607,7 @@ class EnvelopeListenerManager extends TaskSpawner {
|
|
|
6607
6607
|
}
|
|
6608
6608
|
}
|
|
6609
6609
|
if (systemEntry) {
|
|
6610
|
-
logger$
|
|
6610
|
+
logger$17.debug('stopping_listener_for_service', {
|
|
6611
6611
|
service_name: SYSTEM_INBOX$2,
|
|
6612
6612
|
});
|
|
6613
6613
|
systemEntry.listener.stop();
|
|
@@ -6617,7 +6617,7 @@ class EnvelopeListenerManager extends TaskSpawner {
|
|
|
6617
6617
|
catch (error) {
|
|
6618
6618
|
if (!(error instanceof Error) ||
|
|
6619
6619
|
error.name !== 'TaskCancelledError') {
|
|
6620
|
-
logger$
|
|
6620
|
+
logger$17.debug('listener_task_stopped', {
|
|
6621
6621
|
service_name: SYSTEM_INBOX$2,
|
|
6622
6622
|
error: error instanceof Error ? error.message : String(error),
|
|
6623
6623
|
});
|
|
@@ -6634,13 +6634,13 @@ class EnvelopeListenerManager extends TaskSpawner {
|
|
|
6634
6634
|
}
|
|
6635
6635
|
async recoverUnhandledInboundEnvelopes() {
|
|
6636
6636
|
if (typeof this.deliveryTracker.listInbound !== 'function') {
|
|
6637
|
-
logger$
|
|
6637
|
+
logger$17.debug('delivery_tracker_missing_inbound_listing');
|
|
6638
6638
|
return;
|
|
6639
6639
|
}
|
|
6640
6640
|
const failedInbound = await this.deliveryTracker.listInbound((env) => env.status === EnvelopeStatus.RECEIVED ||
|
|
6641
6641
|
env.status === EnvelopeStatus.FAILED_TO_HANDLE);
|
|
6642
6642
|
if (!failedInbound.length) {
|
|
6643
|
-
logger$
|
|
6643
|
+
logger$17.debug('no_failed_inbound_envelopes_to_recover');
|
|
6644
6644
|
return;
|
|
6645
6645
|
}
|
|
6646
6646
|
const grouped = new Map();
|
|
@@ -6657,7 +6657,7 @@ class EnvelopeListenerManager extends TaskSpawner {
|
|
|
6657
6657
|
this.pendingRecoveryEnvelopes.set(serviceName, envelopes);
|
|
6658
6658
|
}
|
|
6659
6659
|
});
|
|
6660
|
-
logger$
|
|
6660
|
+
logger$17.debug('discovered_failed_inbound_envelopes', {
|
|
6661
6661
|
total: failedInbound.length,
|
|
6662
6662
|
services: Array.from(grouped.keys()),
|
|
6663
6663
|
});
|
|
@@ -6667,7 +6667,7 @@ class EnvelopeListenerManager extends TaskSpawner {
|
|
|
6667
6667
|
const pollTimeoutMs = options.pollTimeoutMs ??
|
|
6668
6668
|
options.poll_timeout_ms ??
|
|
6669
6669
|
DEFAULT_POLLING_TIMEOUT_MS;
|
|
6670
|
-
logger$
|
|
6670
|
+
logger$17.debug('listen_start', {
|
|
6671
6671
|
recipient: serviceName,
|
|
6672
6672
|
poll_timeout_ms: pollTimeoutMs ?? DEFAULT_POLLING_TIMEOUT_MS,
|
|
6673
6673
|
});
|
|
@@ -6698,7 +6698,7 @@ class EnvelopeListenerManager extends TaskSpawner {
|
|
|
6698
6698
|
tracked?.mailboxType === MailboxType.OUTBOX ||
|
|
6699
6699
|
envelope.frame?.['type'] === 'DeliveryAck';
|
|
6700
6700
|
if (!shouldInvoke) {
|
|
6701
|
-
logger$
|
|
6701
|
+
logger$17.debug('skipping_listener_handler', {
|
|
6702
6702
|
recipient: serviceName,
|
|
6703
6703
|
envelope_id: envelope.id,
|
|
6704
6704
|
tracked_status: tracked?.status,
|
|
@@ -6712,13 +6712,13 @@ class EnvelopeListenerManager extends TaskSpawner {
|
|
|
6712
6712
|
? undefined
|
|
6713
6713
|
: (tracked ?? undefined);
|
|
6714
6714
|
if (trackedForHandler && trackedForHandler.attempt > 0) {
|
|
6715
|
-
logger$
|
|
6715
|
+
logger$17.info('resuming_handler_retry_after_restart', {
|
|
6716
6716
|
envelope_id: envelope.id,
|
|
6717
6717
|
current_attempts: trackedForHandler.attempt,
|
|
6718
6718
|
service_name: serviceName,
|
|
6719
6719
|
});
|
|
6720
6720
|
}
|
|
6721
|
-
logger$
|
|
6721
|
+
logger$17.debug('forwarding_to_listener_handler', {
|
|
6722
6722
|
recipient: serviceName,
|
|
6723
6723
|
envelope_id: envelope.id,
|
|
6724
6724
|
frame_type: envelope.frame?.['type'],
|
|
@@ -6737,7 +6737,7 @@ class EnvelopeListenerManager extends TaskSpawner {
|
|
|
6737
6737
|
await channel.send(null);
|
|
6738
6738
|
}
|
|
6739
6739
|
catch (error) {
|
|
6740
|
-
logger$
|
|
6740
|
+
logger$17.debug('listener_stop_signal_failed', {
|
|
6741
6741
|
service_name: serviceName,
|
|
6742
6742
|
error: error instanceof Error ? error.message : String(error),
|
|
6743
6743
|
});
|
|
@@ -6746,7 +6746,7 @@ class EnvelopeListenerManager extends TaskSpawner {
|
|
|
6746
6746
|
await this.listenersLock.runExclusive(async () => {
|
|
6747
6747
|
const existing = this.listeners.get(serviceName);
|
|
6748
6748
|
if (existing) {
|
|
6749
|
-
logger$
|
|
6749
|
+
logger$17.debug('replacing_envelope_listener', { recipient: serviceName });
|
|
6750
6750
|
existing.listener.stop();
|
|
6751
6751
|
try {
|
|
6752
6752
|
await existing.listener.task.promise;
|
|
@@ -6764,13 +6764,13 @@ class EnvelopeListenerManager extends TaskSpawner {
|
|
|
6764
6764
|
return binding.address;
|
|
6765
6765
|
}
|
|
6766
6766
|
async listenRpc(serviceName, handler, options = {}) {
|
|
6767
|
-
logger$
|
|
6767
|
+
logger$17.debug('rpc_listen_start', { service_name: serviceName });
|
|
6768
6768
|
const rpcHandler = async (envelope, context) => {
|
|
6769
6769
|
const result = await this.rpcServerHandler.handleRpcRequest(envelope, context, handler, serviceName);
|
|
6770
6770
|
return result ?? null;
|
|
6771
6771
|
};
|
|
6772
6772
|
const address = await this.listen(serviceName, rpcHandler, options);
|
|
6773
|
-
logger$
|
|
6773
|
+
logger$17.debug('rpc_listen_bound', {
|
|
6774
6774
|
service_name: serviceName,
|
|
6775
6775
|
address: address.toString(),
|
|
6776
6776
|
});
|
|
@@ -6839,12 +6839,12 @@ class EnvelopeListenerManager extends TaskSpawner {
|
|
|
6839
6839
|
return cached;
|
|
6840
6840
|
});
|
|
6841
6841
|
if (!envelopes.length) {
|
|
6842
|
-
logger$
|
|
6842
|
+
logger$17.debug('no_cached_recovery_for_service', {
|
|
6843
6843
|
service_name: serviceName,
|
|
6844
6844
|
});
|
|
6845
6845
|
return;
|
|
6846
6846
|
}
|
|
6847
|
-
logger$
|
|
6847
|
+
logger$17.debug('recovering_unhandled_envelopes_on_listen', {
|
|
6848
6848
|
service_name: serviceName,
|
|
6849
6849
|
count: envelopes.length,
|
|
6850
6850
|
envelope_ids: envelopes.map((trackedEnvelope) => trackedEnvelope.envelopeId),
|
|
@@ -6855,7 +6855,7 @@ class EnvelopeListenerManager extends TaskSpawner {
|
|
|
6855
6855
|
async recoverServiceEnvelopes(serviceName, envelopes, handler) {
|
|
6856
6856
|
for (const tracked of envelopes) {
|
|
6857
6857
|
try {
|
|
6858
|
-
logger$
|
|
6858
|
+
logger$17.warning('recovering_unhandled_envelope', {
|
|
6859
6859
|
envelope_id: tracked.envelopeId,
|
|
6860
6860
|
service_name: serviceName,
|
|
6861
6861
|
current_attempts: tracked.attempt,
|
|
@@ -6864,13 +6864,13 @@ class EnvelopeListenerManager extends TaskSpawner {
|
|
|
6864
6864
|
const originalEnvelope = tracked.originalEnvelope;
|
|
6865
6865
|
const receiverPolicy = this.nodeLike.deliveryPolicy?.receiverRetryPolicy ?? undefined;
|
|
6866
6866
|
await this.executeHandlerWithRetries(handler, originalEnvelope, undefined, receiverPolicy, tracked, serviceName);
|
|
6867
|
-
logger$
|
|
6867
|
+
logger$17.debug('envelope_recovery_completed', {
|
|
6868
6868
|
envelope_id: tracked.envelopeId,
|
|
6869
6869
|
service_name: serviceName,
|
|
6870
6870
|
});
|
|
6871
6871
|
}
|
|
6872
6872
|
catch (error) {
|
|
6873
|
-
logger$
|
|
6873
|
+
logger$17.error('envelope_recovery_failed', {
|
|
6874
6874
|
envelope_id: tracked.envelopeId,
|
|
6875
6875
|
service_name: serviceName,
|
|
6876
6876
|
error: error instanceof Error ? error.message : String(error),
|
|
@@ -6916,7 +6916,7 @@ class EnvelopeListenerManager extends TaskSpawner {
|
|
|
6916
6916
|
await this.deliveryTracker.onEnvelopeHandled(trackedEnvelope);
|
|
6917
6917
|
}
|
|
6918
6918
|
if (currentAttempt > 0) {
|
|
6919
|
-
logger$
|
|
6919
|
+
logger$17.info('handler_retry_succeeded', {
|
|
6920
6920
|
envelope_id: envelope.id,
|
|
6921
6921
|
attempt: currentAttempt + 1,
|
|
6922
6922
|
total_attempts: currentAttempt + 1,
|
|
@@ -6932,7 +6932,7 @@ class EnvelopeListenerManager extends TaskSpawner {
|
|
|
6932
6932
|
await this.deliveryTracker.onEnvelopeHandleFailed(inboxName, trackedEnvelope, context, error instanceof Error ? error : new Error(String(error)), isFinalAttempt);
|
|
6933
6933
|
}
|
|
6934
6934
|
if (isFinalAttempt) {
|
|
6935
|
-
logger$
|
|
6935
|
+
logger$17.error('handler_execution_failed_exhausted_retries', {
|
|
6936
6936
|
envelope_id: envelope.id,
|
|
6937
6937
|
total_attempts: attemptNumber,
|
|
6938
6938
|
max_retries: retryPolicy?.maxRetries ?? 0,
|
|
@@ -6941,7 +6941,7 @@ class EnvelopeListenerManager extends TaskSpawner {
|
|
|
6941
6941
|
break;
|
|
6942
6942
|
}
|
|
6943
6943
|
const delayMs = retryPolicy?.nextDelayMs(attemptNumber) ?? 0;
|
|
6944
|
-
logger$
|
|
6944
|
+
logger$17.warning('handler_execution_failed_will_retry', {
|
|
6945
6945
|
envelope_id: envelope.id,
|
|
6946
6946
|
attempt: attemptNumber,
|
|
6947
6947
|
max_retries: retryPolicy?.maxRetries ?? 0,
|
|
@@ -6971,7 +6971,7 @@ class EnvelopeListenerManager extends TaskSpawner {
|
|
|
6971
6971
|
}
|
|
6972
6972
|
}
|
|
6973
6973
|
|
|
6974
|
-
const logger$
|
|
6974
|
+
const logger$16 = getLogger('naylence.fame.delivery.default_delivery_tracker');
|
|
6975
6975
|
const STREAM_END = Symbol('stream-end');
|
|
6976
6976
|
const SWEEPER_TICK = Symbol('tracker-sweeper-tick');
|
|
6977
6977
|
function createDeferred$2() {
|
|
@@ -7190,7 +7190,7 @@ class DefaultDeliveryTracker extends TaskSpawner {
|
|
|
7190
7190
|
const expectedResponseType = options.expectedResponseType;
|
|
7191
7191
|
const tracked = await this.lock.runExclusive(async () => {
|
|
7192
7192
|
if (this.ackFutures.has(envelope.id)) {
|
|
7193
|
-
logger$
|
|
7193
|
+
logger$16.debug('tracker_envelope_already_tracked', {
|
|
7194
7194
|
envp_id: envelope.id,
|
|
7195
7195
|
});
|
|
7196
7196
|
return null;
|
|
@@ -7200,7 +7200,7 @@ class DefaultDeliveryTracker extends TaskSpawner {
|
|
|
7200
7200
|
if (expectedResponseType & FameResponseType.REPLY ||
|
|
7201
7201
|
expectedResponseType & FameResponseType.STREAM) {
|
|
7202
7202
|
if (existingEnvId && existingEnvId !== envelope.id) {
|
|
7203
|
-
logger$
|
|
7203
|
+
logger$16.debug('envelope_already_tracked_for_replies', {
|
|
7204
7204
|
envp_id: envelope.id,
|
|
7205
7205
|
corr_id: corrId,
|
|
7206
7206
|
expected_response_type: expectedResponseType,
|
|
@@ -7249,7 +7249,7 @@ class DefaultDeliveryTracker extends TaskSpawner {
|
|
|
7249
7249
|
return null;
|
|
7250
7250
|
}
|
|
7251
7251
|
await this.scheduleTimer(tracked, options.retryPolicy ?? null, options.retryHandler ?? null);
|
|
7252
|
-
logger$
|
|
7252
|
+
logger$16.debug('tracker_registered_envelope', {
|
|
7253
7253
|
envp_id: envelope.id,
|
|
7254
7254
|
corr_id: tracked.originalEnvelope.corrId,
|
|
7255
7255
|
expected_response: tracked.expectedResponseType,
|
|
@@ -7273,21 +7273,21 @@ class DefaultDeliveryTracker extends TaskSpawner {
|
|
|
7273
7273
|
return this.awaitEnvelopeFuture(envelopeId, FameResponseType.REPLY | FameResponseType.STREAM, future, timeoutMs);
|
|
7274
7274
|
}
|
|
7275
7275
|
async onEnvelopeDelivered(inboxName, envelope, context) {
|
|
7276
|
-
logger$
|
|
7276
|
+
logger$16.debug('envelope_delivered', {
|
|
7277
7277
|
envp_id: envelope.id,
|
|
7278
7278
|
corr_id: envelope.corrId,
|
|
7279
7279
|
rtype: envelope.rtype ?? FameResponseType.NONE,
|
|
7280
7280
|
frame_type: envelope.frame?.type ?? 'unknown',
|
|
7281
7281
|
});
|
|
7282
7282
|
if (!envelope.corrId) {
|
|
7283
|
-
logger$
|
|
7283
|
+
logger$16.debug('envelope_delivered_no_corr_id', {
|
|
7284
7284
|
envelope_id: envelope.id,
|
|
7285
7285
|
});
|
|
7286
7286
|
return null;
|
|
7287
7287
|
}
|
|
7288
7288
|
if (this.isDeliveryAckFrame(envelope.frame)) {
|
|
7289
7289
|
if (!envelope.frame.refId) {
|
|
7290
|
-
logger$
|
|
7290
|
+
logger$16.debug('envelope_delivered_no_ref_id', {
|
|
7291
7291
|
envelope_id: envelope.id,
|
|
7292
7292
|
});
|
|
7293
7293
|
return null;
|
|
@@ -7324,7 +7324,7 @@ class DefaultDeliveryTracker extends TaskSpawner {
|
|
|
7324
7324
|
await inbox.set(envelope.id, tracked);
|
|
7325
7325
|
}
|
|
7326
7326
|
else {
|
|
7327
|
-
logger$
|
|
7327
|
+
logger$16.debug('tracker_duplicate_envelope_already_handled', {
|
|
7328
7328
|
envp_id: envelope.id,
|
|
7329
7329
|
status: tracked.status,
|
|
7330
7330
|
});
|
|
@@ -7366,7 +7366,7 @@ class DefaultDeliveryTracker extends TaskSpawner {
|
|
|
7366
7366
|
}
|
|
7367
7367
|
if (isFinalFailure) {
|
|
7368
7368
|
envelope.status = EnvelopeStatus.FAILED_TO_HANDLE;
|
|
7369
|
-
logger$
|
|
7369
|
+
logger$16.error('envelope_handle_failed_final', {
|
|
7370
7370
|
inbox_name: inboxName,
|
|
7371
7371
|
envp_id: envelope.originalEnvelope.id,
|
|
7372
7372
|
error: error?.message ?? 'unknown',
|
|
@@ -7377,7 +7377,7 @@ class DefaultDeliveryTracker extends TaskSpawner {
|
|
|
7377
7377
|
await inbox.delete(envelope.originalEnvelope.id);
|
|
7378
7378
|
return;
|
|
7379
7379
|
}
|
|
7380
|
-
logger$
|
|
7380
|
+
logger$16.warning('envelope_handle_failed_retry', {
|
|
7381
7381
|
inbox_name: inboxName,
|
|
7382
7382
|
envp_id: envelope.originalEnvelope.id,
|
|
7383
7383
|
error: error?.message ?? 'unknown',
|
|
@@ -7422,14 +7422,14 @@ class DefaultDeliveryTracker extends TaskSpawner {
|
|
|
7422
7422
|
if (handledViaFuture) {
|
|
7423
7423
|
await this.markDoneSince(this.ackFutures, refId, this.ackDoneSince);
|
|
7424
7424
|
await this.clearTimer(refId);
|
|
7425
|
-
logger$
|
|
7425
|
+
logger$16.debug('tracker_ack_resolved_without_tracked_envelope', {
|
|
7426
7426
|
envp_id: envelope.id,
|
|
7427
7427
|
ref_id: refId,
|
|
7428
7428
|
corr_id: envelope.corrId,
|
|
7429
7429
|
});
|
|
7430
7430
|
return;
|
|
7431
7431
|
}
|
|
7432
|
-
logger$
|
|
7432
|
+
logger$16.debug('tracker_ack_for_unknown_envelope', {
|
|
7433
7433
|
envp_id: envelope.id,
|
|
7434
7434
|
ref_id: refId,
|
|
7435
7435
|
corr_id: envelope.corrId,
|
|
@@ -7437,7 +7437,7 @@ class DefaultDeliveryTracker extends TaskSpawner {
|
|
|
7437
7437
|
return;
|
|
7438
7438
|
}
|
|
7439
7439
|
if (tracked.originalEnvelope.corrId !== envelope.corrId) {
|
|
7440
|
-
logger$
|
|
7440
|
+
logger$16.debug('tracker_ack_corr_id_mismatch', {
|
|
7441
7441
|
envp_id: envelope.id,
|
|
7442
7442
|
expected_corr_id: tracked.originalEnvelope.corrId,
|
|
7443
7443
|
actual_corr_id: envelope.corrId,
|
|
@@ -7462,7 +7462,7 @@ class DefaultDeliveryTracker extends TaskSpawner {
|
|
|
7462
7462
|
for (const handler of this.eventHandlers) {
|
|
7463
7463
|
await handler.onEnvelopeAcked?.(tracked);
|
|
7464
7464
|
}
|
|
7465
|
-
logger$
|
|
7465
|
+
logger$16.debug('tracker_envelope_acked', {
|
|
7466
7466
|
envp_id: tracked.originalEnvelope.id,
|
|
7467
7467
|
});
|
|
7468
7468
|
}
|
|
@@ -7479,13 +7479,13 @@ class DefaultDeliveryTracker extends TaskSpawner {
|
|
|
7479
7479
|
const outbox = this.ensureOutbox();
|
|
7480
7480
|
const tracked = await outbox.get(envelope.frame.refId);
|
|
7481
7481
|
if (!tracked) {
|
|
7482
|
-
logger$
|
|
7482
|
+
logger$16.debug('tracker_nack_for_unknown_envelope', {
|
|
7483
7483
|
envp_id: envelope.id,
|
|
7484
7484
|
});
|
|
7485
7485
|
return;
|
|
7486
7486
|
}
|
|
7487
7487
|
if (tracked.originalEnvelope.corrId !== envelope.corrId) {
|
|
7488
|
-
logger$
|
|
7488
|
+
logger$16.debug('tracker_nack_corr_id_mismatch', {
|
|
7489
7489
|
envp_id: envelope.id,
|
|
7490
7490
|
expected_corr_id: tracked.originalEnvelope.corrId,
|
|
7491
7491
|
actual_corr_id: envelope.corrId,
|
|
@@ -7527,7 +7527,7 @@ class DefaultDeliveryTracker extends TaskSpawner {
|
|
|
7527
7527
|
for (const handler of this.eventHandlers) {
|
|
7528
7528
|
await handler.onEnvelopeNacked?.(tracked, ackFrame.reason ?? null);
|
|
7529
7529
|
}
|
|
7530
|
-
logger$
|
|
7530
|
+
logger$16.debug('tracker_envelope_nacked', {
|
|
7531
7531
|
envp_id: tracked.originalEnvelope.id,
|
|
7532
7532
|
reason: ackFrame.reason,
|
|
7533
7533
|
});
|
|
@@ -7574,7 +7574,7 @@ class DefaultDeliveryTracker extends TaskSpawner {
|
|
|
7574
7574
|
for (const handler of this.eventHandlers) {
|
|
7575
7575
|
await handler.onEnvelopeReplied?.(trackedEnvelope, envelope);
|
|
7576
7576
|
}
|
|
7577
|
-
logger$
|
|
7577
|
+
logger$16.debug('tracked_envelope_replied', {
|
|
7578
7578
|
envp_id: trackedEnvelope.originalEnvelope.id,
|
|
7579
7579
|
corr_id: envelope.corrId,
|
|
7580
7580
|
});
|
|
@@ -7648,7 +7648,7 @@ class DefaultDeliveryTracker extends TaskSpawner {
|
|
|
7648
7648
|
async addToInboxDlq(trackedEnvelope, reason = null) {
|
|
7649
7649
|
const dlq = this.inboxDlq;
|
|
7650
7650
|
if (!dlq) {
|
|
7651
|
-
logger$
|
|
7651
|
+
logger$16.error('dlq_not_initialized', {
|
|
7652
7652
|
envp_id: trackedEnvelope.originalEnvelope.id,
|
|
7653
7653
|
});
|
|
7654
7654
|
return;
|
|
@@ -7663,7 +7663,7 @@ class DefaultDeliveryTracker extends TaskSpawner {
|
|
|
7663
7663
|
const deadLetteredAt = Date.now();
|
|
7664
7664
|
setMetaWithLegacy(trackedEnvelope.meta, 'deadLetteredAtMs', 'dead_lettered_at_ms', deadLetteredAt);
|
|
7665
7665
|
await dlq.set(trackedEnvelope.originalEnvelope.id, trackedEnvelope);
|
|
7666
|
-
logger$
|
|
7666
|
+
logger$16.warning('envelope_moved_to_dlq', {
|
|
7667
7667
|
envp_id: trackedEnvelope.originalEnvelope.id,
|
|
7668
7668
|
service_name: trackedEnvelope.serviceName,
|
|
7669
7669
|
});
|
|
@@ -7692,7 +7692,7 @@ class DefaultDeliveryTracker extends TaskSpawner {
|
|
|
7692
7692
|
const toDelete = Object.entries(items).filter(([, value]) => predicate ? predicate(value) : true);
|
|
7693
7693
|
await Promise.all(toDelete.map(([key]) => dlq.delete(key)));
|
|
7694
7694
|
if (toDelete.length) {
|
|
7695
|
-
logger$
|
|
7695
|
+
logger$16.debug('dlq_purged', { count: toDelete.length });
|
|
7696
7696
|
}
|
|
7697
7697
|
return toDelete.length;
|
|
7698
7698
|
}
|
|
@@ -7745,11 +7745,11 @@ class DefaultDeliveryTracker extends TaskSpawner {
|
|
|
7745
7745
|
}
|
|
7746
7746
|
this.futuresSweeper = null;
|
|
7747
7747
|
}
|
|
7748
|
-
logger$
|
|
7748
|
+
logger$16.debug('tracker_cleanup_completed');
|
|
7749
7749
|
}
|
|
7750
7750
|
async recoverPending() {
|
|
7751
7751
|
const pending = await this.listPending();
|
|
7752
|
-
logger$
|
|
7752
|
+
logger$16.debug('tracker_recovering_pending', { count: pending.length });
|
|
7753
7753
|
await this.lock.runExclusive(async () => {
|
|
7754
7754
|
for (const tracked of pending) {
|
|
7755
7755
|
if (tracked.expectedResponseType & FameResponseType.ACK) {
|
|
@@ -7775,7 +7775,7 @@ class DefaultDeliveryTracker extends TaskSpawner {
|
|
|
7775
7775
|
for (const tracked of pending) {
|
|
7776
7776
|
await this.scheduleTimer(tracked, null, null);
|
|
7777
7777
|
}
|
|
7778
|
-
logger$
|
|
7778
|
+
logger$16.debug('tracker_recovery_completed', { count: pending.length });
|
|
7779
7779
|
}
|
|
7780
7780
|
ensureOutbox() {
|
|
7781
7781
|
if (!this.outbox) {
|
|
@@ -7790,7 +7790,7 @@ class DefaultDeliveryTracker extends TaskSpawner {
|
|
|
7790
7790
|
return this.inbox;
|
|
7791
7791
|
}
|
|
7792
7792
|
async waitForPendingAcks() {
|
|
7793
|
-
logger$
|
|
7793
|
+
logger$16.debug('tracker_node_preparing_to_stop_waiting_for_pending_acks');
|
|
7794
7794
|
const outbox = this.outbox;
|
|
7795
7795
|
if (!outbox) {
|
|
7796
7796
|
return;
|
|
@@ -7802,7 +7802,7 @@ class DefaultDeliveryTracker extends TaskSpawner {
|
|
|
7802
7802
|
continue;
|
|
7803
7803
|
}
|
|
7804
7804
|
if (!future.done) {
|
|
7805
|
-
logger$
|
|
7805
|
+
logger$16.debug('tracker_pending_ack_future_detected', {
|
|
7806
7806
|
envelope_id: envelopeId,
|
|
7807
7807
|
});
|
|
7808
7808
|
pending.push({ envelopeId, future });
|
|
@@ -7810,10 +7810,10 @@ class DefaultDeliveryTracker extends TaskSpawner {
|
|
|
7810
7810
|
}
|
|
7811
7811
|
});
|
|
7812
7812
|
if (!pending.length) {
|
|
7813
|
-
logger$
|
|
7813
|
+
logger$16.debug('tracker_no_pending_acks_to_wait_for');
|
|
7814
7814
|
return;
|
|
7815
7815
|
}
|
|
7816
|
-
logger$
|
|
7816
|
+
logger$16.debug('tracker_waiting_for_pending_acks', { count: pending.length });
|
|
7817
7817
|
for (const entry of pending) {
|
|
7818
7818
|
if (!entry) {
|
|
7819
7819
|
continue;
|
|
@@ -7830,19 +7830,19 @@ class DefaultDeliveryTracker extends TaskSpawner {
|
|
|
7830
7830
|
}
|
|
7831
7831
|
try {
|
|
7832
7832
|
await this.awaitWithTimeout(entry.future.promise, remainingMs);
|
|
7833
|
-
logger$
|
|
7833
|
+
logger$16.debug('tracker_received_ack', {
|
|
7834
7834
|
envelope_id: entry.envelopeId,
|
|
7835
7835
|
});
|
|
7836
7836
|
await outbox.delete(entry.envelopeId);
|
|
7837
7837
|
}
|
|
7838
7838
|
catch (error) {
|
|
7839
7839
|
if (error instanceof Error && error.name === 'TimeoutError') {
|
|
7840
|
-
logger$
|
|
7840
|
+
logger$16.debug('tracker_ack_timeout_expired', {
|
|
7841
7841
|
envelope_id: entry.envelopeId,
|
|
7842
7842
|
});
|
|
7843
7843
|
}
|
|
7844
7844
|
else {
|
|
7845
|
-
logger$
|
|
7845
|
+
logger$16.debug('tracker_ack_wait_error', {
|
|
7846
7846
|
envelope_id: entry.envelopeId,
|
|
7847
7847
|
error: error instanceof Error ? error.message : String(error),
|
|
7848
7848
|
});
|
|
@@ -7850,13 +7850,13 @@ class DefaultDeliveryTracker extends TaskSpawner {
|
|
|
7850
7850
|
}
|
|
7851
7851
|
}
|
|
7852
7852
|
catch (error) {
|
|
7853
|
-
logger$
|
|
7853
|
+
logger$16.error('tracker_error_waiting_for_ack', {
|
|
7854
7854
|
envelope_id: entry.envelopeId,
|
|
7855
7855
|
error: error instanceof Error ? error.message : String(error),
|
|
7856
7856
|
});
|
|
7857
7857
|
}
|
|
7858
7858
|
}
|
|
7859
|
-
logger$
|
|
7859
|
+
logger$16.debug('tracker_finished_waiting_for_pending_acks');
|
|
7860
7860
|
}
|
|
7861
7861
|
async waitForPendingAckDispatches() {
|
|
7862
7862
|
while (this.pendingAckDispatches.size > 0) {
|
|
@@ -7914,7 +7914,7 @@ class DefaultDeliveryTracker extends TaskSpawner {
|
|
|
7914
7914
|
for (const handler of this.eventHandlers) {
|
|
7915
7915
|
await handler.onEnvelopeTimeout?.(currentTracked);
|
|
7916
7916
|
}
|
|
7917
|
-
logger$
|
|
7917
|
+
logger$16.debug('tracker_envelope_timed_out', {
|
|
7918
7918
|
envp_id: tracked.originalEnvelope.id,
|
|
7919
7919
|
});
|
|
7920
7920
|
return;
|
|
@@ -7927,7 +7927,7 @@ class DefaultDeliveryTracker extends TaskSpawner {
|
|
|
7927
7927
|
currentTracked.timeoutAtMs = nextTimeoutAt;
|
|
7928
7928
|
await outbox.set(tracked.originalEnvelope.id, currentTracked);
|
|
7929
7929
|
await this.scheduleTimer(currentTracked, retryPolicy, retryHandler);
|
|
7930
|
-
logger$
|
|
7930
|
+
logger$16.debug('tracker_retry_deferred_during_shutdown', {
|
|
7931
7931
|
envp_id: tracked.originalEnvelope.id,
|
|
7932
7932
|
defer_ms: shutdownDeferMs,
|
|
7933
7933
|
});
|
|
@@ -7950,7 +7950,7 @@ class DefaultDeliveryTracker extends TaskSpawner {
|
|
|
7950
7950
|
});
|
|
7951
7951
|
}
|
|
7952
7952
|
await this.scheduleTimer(currentTracked, retryPolicy, retryHandler);
|
|
7953
|
-
logger$
|
|
7953
|
+
logger$16.debug('envelope_delivery_retry_scheduled', {
|
|
7954
7954
|
envp_id: tracked.originalEnvelope.id,
|
|
7955
7955
|
attempt: currentTracked.attempt,
|
|
7956
7956
|
max_retries: retryPolicy.maxRetries,
|
|
@@ -7962,7 +7962,7 @@ class DefaultDeliveryTracker extends TaskSpawner {
|
|
|
7962
7962
|
currentTracked.timeoutAtMs = currentTracked.overallTimeoutAtMs;
|
|
7963
7963
|
await outbox.set(tracked.originalEnvelope.id, currentTracked);
|
|
7964
7964
|
await this.scheduleTimer(currentTracked, retryPolicy, retryHandler);
|
|
7965
|
-
logger$
|
|
7965
|
+
logger$16.debug('envelope_retries_exhausted_waiting_until_overall_timeout', {
|
|
7966
7966
|
envp_id: tracked.originalEnvelope.id,
|
|
7967
7967
|
attempt: currentTracked.attempt,
|
|
7968
7968
|
overall_timeout_at_ms: currentTracked.overallTimeoutAtMs,
|
|
@@ -7982,7 +7982,7 @@ class DefaultDeliveryTracker extends TaskSpawner {
|
|
|
7982
7982
|
for (const handler of this.eventHandlers) {
|
|
7983
7983
|
await handler.onEnvelopeTimeout?.(currentTracked);
|
|
7984
7984
|
}
|
|
7985
|
-
logger$
|
|
7985
|
+
logger$16.debug('tracker_envelope_timed_out', {
|
|
7986
7986
|
envp_id: tracked.originalEnvelope.id,
|
|
7987
7987
|
});
|
|
7988
7988
|
}
|
|
@@ -7990,7 +7990,7 @@ class DefaultDeliveryTracker extends TaskSpawner {
|
|
|
7990
7990
|
if (error instanceof TaskCancelledError) {
|
|
7991
7991
|
return;
|
|
7992
7992
|
}
|
|
7993
|
-
logger$
|
|
7993
|
+
logger$16.error('tracker_timer_error', {
|
|
7994
7994
|
envp_id: tracked.originalEnvelope.id,
|
|
7995
7995
|
error: error instanceof Error ? error.message : String(error),
|
|
7996
7996
|
});
|
|
@@ -8045,7 +8045,7 @@ class DefaultDeliveryTracker extends TaskSpawner {
|
|
|
8045
8045
|
if (timeoutSeconds !== null) {
|
|
8046
8046
|
return await this.awaitWithTimeout(future.promise, timeoutSeconds);
|
|
8047
8047
|
}
|
|
8048
|
-
logger$
|
|
8048
|
+
logger$16.debug('await_envelope_no_timeout_wait', {
|
|
8049
8049
|
envelope_id: envelopeId,
|
|
8050
8050
|
});
|
|
8051
8051
|
return await future.promise;
|
|
@@ -8054,7 +8054,7 @@ class DefaultDeliveryTracker extends TaskSpawner {
|
|
|
8054
8054
|
if (error instanceof Error && error.name !== 'TimeoutError') {
|
|
8055
8055
|
throw error;
|
|
8056
8056
|
}
|
|
8057
|
-
logger$
|
|
8057
|
+
logger$16.error('await_envelope_timeout_error', {
|
|
8058
8058
|
envelope_id: envelopeId,
|
|
8059
8059
|
timeout_ms: timeoutSeconds,
|
|
8060
8060
|
future_done: false,
|
|
@@ -8215,7 +8215,7 @@ class DefaultDeliveryTracker extends TaskSpawner {
|
|
|
8215
8215
|
this.replyDoneSince.delete(envId);
|
|
8216
8216
|
}
|
|
8217
8217
|
});
|
|
8218
|
-
logger$
|
|
8218
|
+
logger$16.debug('tracker_swept_completed_futures', {
|
|
8219
8219
|
ack_removed: toRemoveAck.length,
|
|
8220
8220
|
reply_removed: toRemoveReply.length,
|
|
8221
8221
|
grace_secs: this.futGcGraceSecs,
|
|
@@ -8229,7 +8229,7 @@ class DefaultDeliveryTracker extends TaskSpawner {
|
|
|
8229
8229
|
if (error instanceof Error && error.name === 'TimeoutError') {
|
|
8230
8230
|
continue;
|
|
8231
8231
|
}
|
|
8232
|
-
logger$
|
|
8232
|
+
logger$16.error('tracker_sweeper_error', {
|
|
8233
8233
|
error: error instanceof Error ? error.message : String(error),
|
|
8234
8234
|
});
|
|
8235
8235
|
}
|
|
@@ -8260,14 +8260,14 @@ class DefaultDeliveryTracker extends TaskSpawner {
|
|
|
8260
8260
|
}
|
|
8261
8261
|
const node = this.node;
|
|
8262
8262
|
if (!envelope.replyTo) {
|
|
8263
|
-
logger$
|
|
8263
|
+
logger$16.error('cannot_send_ack_no_reply_to', { envp_id: envelope.id });
|
|
8264
8264
|
return;
|
|
8265
8265
|
}
|
|
8266
8266
|
if (!envelope.corrId) {
|
|
8267
|
-
logger$
|
|
8267
|
+
logger$16.error('cannot_send_ack_no_corr_id', { envp_id: envelope.id });
|
|
8268
8268
|
return;
|
|
8269
8269
|
}
|
|
8270
|
-
logger$
|
|
8270
|
+
logger$16.debug('tracker_sending_ack', {
|
|
8271
8271
|
envp_id: envelope.id,
|
|
8272
8272
|
ref_id: envelope.id,
|
|
8273
8273
|
to: envelope.replyTo,
|
|
@@ -8287,7 +8287,7 @@ class DefaultDeliveryTracker extends TaskSpawner {
|
|
|
8287
8287
|
.send(ackEnvelope)
|
|
8288
8288
|
.then(() => undefined)
|
|
8289
8289
|
.catch((error) => {
|
|
8290
|
-
logger$
|
|
8290
|
+
logger$16.error('tracker_ack_dispatch_failed', {
|
|
8291
8291
|
envp_id: envelope.id,
|
|
8292
8292
|
error: error instanceof Error ? error.message : String(error),
|
|
8293
8293
|
});
|
|
@@ -8373,7 +8373,7 @@ class AsyncEvent {
|
|
|
8373
8373
|
}
|
|
8374
8374
|
}
|
|
8375
8375
|
|
|
8376
|
-
const logger$
|
|
8376
|
+
const logger$15 = getLogger('naylence.fame.node.root_session_manager');
|
|
8377
8377
|
function resolveOption$1(options, primary, ...aliases) {
|
|
8378
8378
|
const record = options;
|
|
8379
8379
|
const primaryKey = primary;
|
|
@@ -8454,7 +8454,7 @@ class RootSessionManager extends TaskSpawner {
|
|
|
8454
8454
|
this.onAdmissionFailed =
|
|
8455
8455
|
typeof onAdmissionFailed === 'function' ? onAdmissionFailed : undefined;
|
|
8456
8456
|
this.enableContinuousRefresh = enableContinuousRefresh ?? true;
|
|
8457
|
-
logger$
|
|
8457
|
+
logger$15.debug('created_root_session_manager');
|
|
8458
8458
|
}
|
|
8459
8459
|
get isReady() {
|
|
8460
8460
|
return this.readyEvent.isSet();
|
|
@@ -8479,7 +8479,7 @@ class RootSessionManager extends TaskSpawner {
|
|
|
8479
8479
|
if (this.admissionTask) {
|
|
8480
8480
|
return;
|
|
8481
8481
|
}
|
|
8482
|
-
logger$
|
|
8482
|
+
logger$15.debug('root_session_manager_starting');
|
|
8483
8483
|
this.stopEvent.clear();
|
|
8484
8484
|
this.readyEvent.clear();
|
|
8485
8485
|
const taskName = `root-admission-${this.admissionEpoch}`;
|
|
@@ -8499,10 +8499,10 @@ class RootSessionManager extends TaskSpawner {
|
|
|
8499
8499
|
await this.admissionTask.promise;
|
|
8500
8500
|
throw new FameConnectError('Root session manager failed to become ready');
|
|
8501
8501
|
}
|
|
8502
|
-
logger$
|
|
8502
|
+
logger$15.debug('root_session_manager_started');
|
|
8503
8503
|
}
|
|
8504
8504
|
async stop() {
|
|
8505
|
-
logger$
|
|
8505
|
+
logger$15.debug('root_session_manager_stopping');
|
|
8506
8506
|
this.stopEvent.set();
|
|
8507
8507
|
if (this.admissionTask) {
|
|
8508
8508
|
this.admissionTask.cancel();
|
|
@@ -8514,7 +8514,7 @@ class RootSessionManager extends TaskSpawner {
|
|
|
8514
8514
|
await this.consumeTask(this.expiryGuardTask);
|
|
8515
8515
|
this.expiryGuardTask = null;
|
|
8516
8516
|
}
|
|
8517
|
-
logger$
|
|
8517
|
+
logger$15.debug('root_session_manager_stopped');
|
|
8518
8518
|
}
|
|
8519
8519
|
async awaitReady(timeoutMs) {
|
|
8520
8520
|
if (this.isReady) {
|
|
@@ -8555,12 +8555,12 @@ class RootSessionManager extends TaskSpawner {
|
|
|
8555
8555
|
await this.onEpochChange(epoch);
|
|
8556
8556
|
}
|
|
8557
8557
|
else {
|
|
8558
|
-
logger$
|
|
8558
|
+
logger$15.debug('epoch_change_ignored_no_handler', { epoch });
|
|
8559
8559
|
}
|
|
8560
8560
|
}
|
|
8561
8561
|
static createForRootSentinel(node, admissionClient, requestedLogicals = [], enableContinuousRefresh = true, onEpochChange) {
|
|
8562
8562
|
const handleWelcome = async (frame) => {
|
|
8563
|
-
logger$
|
|
8563
|
+
logger$15.info('root_admission_successful', {
|
|
8564
8564
|
system_id: frame.systemId,
|
|
8565
8565
|
assigned_path: frame.assignedPath ?? null,
|
|
8566
8566
|
accepted_logicals: frame.acceptedLogicals ?? [],
|
|
@@ -8571,12 +8571,12 @@ class RootSessionManager extends TaskSpawner {
|
|
|
8571
8571
|
? grant.purpose
|
|
8572
8572
|
: undefined;
|
|
8573
8573
|
if (purpose) {
|
|
8574
|
-
logger$
|
|
8574
|
+
logger$15.debug('received_admission_grant', { purpose });
|
|
8575
8575
|
}
|
|
8576
8576
|
}
|
|
8577
8577
|
};
|
|
8578
8578
|
const handleFailure = async (error) => {
|
|
8579
|
-
logger$
|
|
8579
|
+
logger$15.error('root_admission_failed_permanently', {
|
|
8580
8580
|
error: error.message,
|
|
8581
8581
|
});
|
|
8582
8582
|
};
|
|
@@ -8605,10 +8605,10 @@ class RootSessionManager extends TaskSpawner {
|
|
|
8605
8605
|
this.readyEvent.set();
|
|
8606
8606
|
}
|
|
8607
8607
|
if (this.hadSuccessfulAdmission) {
|
|
8608
|
-
logger$
|
|
8608
|
+
logger$15.debug('root_admission_refreshed');
|
|
8609
8609
|
}
|
|
8610
8610
|
else {
|
|
8611
|
-
logger$
|
|
8611
|
+
logger$15.debug('root_admission_completed');
|
|
8612
8612
|
}
|
|
8613
8613
|
this.hadSuccessfulAdmission = true;
|
|
8614
8614
|
delay = RootSessionManager.BACKOFF_INITIAL;
|
|
@@ -8617,7 +8617,7 @@ class RootSessionManager extends TaskSpawner {
|
|
|
8617
8617
|
await this.startExpiryGuard(welcomeFrame);
|
|
8618
8618
|
const expiryTriggered = await this.waitForExpiryOrStop();
|
|
8619
8619
|
if (expiryTriggered && !this.stopEvent.isSet()) {
|
|
8620
|
-
logger$
|
|
8620
|
+
logger$15.debug('performing_scheduled_re_admission');
|
|
8621
8621
|
continue;
|
|
8622
8622
|
}
|
|
8623
8623
|
}
|
|
@@ -8629,7 +8629,7 @@ class RootSessionManager extends TaskSpawner {
|
|
|
8629
8629
|
}
|
|
8630
8630
|
const errorObject = error instanceof Error ? error : new Error(String(error));
|
|
8631
8631
|
const willRetry = attempts < RootSessionManager.RETRY_MAX_ATTEMPTS;
|
|
8632
|
-
logger$
|
|
8632
|
+
logger$15.warning('root_admission_failed', {
|
|
8633
8633
|
error: errorObject.message,
|
|
8634
8634
|
attempt: attempts,
|
|
8635
8635
|
will_retry: willRetry,
|
|
@@ -8647,7 +8647,7 @@ class RootSessionManager extends TaskSpawner {
|
|
|
8647
8647
|
}
|
|
8648
8648
|
}
|
|
8649
8649
|
if (attempts >= RootSessionManager.RETRY_MAX_ATTEMPTS) {
|
|
8650
|
-
logger$
|
|
8650
|
+
logger$15.error('root_admission_max_attempts_exceeded', {
|
|
8651
8651
|
max_attempts: RootSessionManager.RETRY_MAX_ATTEMPTS,
|
|
8652
8652
|
});
|
|
8653
8653
|
}
|
|
@@ -8724,7 +8724,7 @@ class RootSessionManager extends TaskSpawner {
|
|
|
8724
8724
|
}
|
|
8725
8725
|
async expiryGuard(welcomeFrame, signal) {
|
|
8726
8726
|
if (!welcomeFrame.expiresAt) {
|
|
8727
|
-
logger$
|
|
8727
|
+
logger$15.debug('no_admission_expiry_configured');
|
|
8728
8728
|
await Promise.race([this.stopEvent.wait(), this.waitForAbort(signal)]);
|
|
8729
8729
|
return;
|
|
8730
8730
|
}
|
|
@@ -8733,7 +8733,7 @@ class RootSessionManager extends TaskSpawner {
|
|
|
8733
8733
|
let delaySeconds = (expiresAt.getTime() - now.getTime()) / 1000 -
|
|
8734
8734
|
RootSessionManager.JWT_REFRESH_SAFETY;
|
|
8735
8735
|
delaySeconds = Math.max(delaySeconds, 0);
|
|
8736
|
-
logger$
|
|
8736
|
+
logger$15.debug('admission_expiry_guard_started', {
|
|
8737
8737
|
welcome_expires_at: expiresAt.toISOString(),
|
|
8738
8738
|
delay_seconds: delaySeconds,
|
|
8739
8739
|
refresh_safety_seconds: RootSessionManager.JWT_REFRESH_SAFETY,
|
|
@@ -8742,7 +8742,7 @@ class RootSessionManager extends TaskSpawner {
|
|
|
8742
8742
|
if (this.stopEvent.isSet() || signal?.aborted) {
|
|
8743
8743
|
return;
|
|
8744
8744
|
}
|
|
8745
|
-
logger$
|
|
8745
|
+
logger$15.debug('admission_expiry_triggered_refresh', {
|
|
8746
8746
|
expires_at: expiresAt.toISOString(),
|
|
8747
8747
|
current_time: new Date().toISOString(),
|
|
8748
8748
|
seconds_before_expiry: RootSessionManager.JWT_REFRESH_SAFETY,
|
|
@@ -8757,7 +8757,7 @@ class RootSessionManager extends TaskSpawner {
|
|
|
8757
8757
|
return;
|
|
8758
8758
|
}
|
|
8759
8759
|
const errorObject = error instanceof Error ? error : new Error(String(error));
|
|
8760
|
-
logger$
|
|
8760
|
+
logger$15.debug('background_task_error', {
|
|
8761
8761
|
task_name: task.name,
|
|
8762
8762
|
error: errorObject.message,
|
|
8763
8763
|
});
|
|
@@ -8798,7 +8798,7 @@ RootSessionManager.JWT_REFRESH_SAFETY = 60.0;
|
|
|
8798
8798
|
* Concrete implementations must define supported grant types and provide grant-to-connector
|
|
8799
8799
|
* conversion logic.
|
|
8800
8800
|
*/
|
|
8801
|
-
const logger$
|
|
8801
|
+
const logger$14 = getLogger('naylence.fame.connector.connector_factory');
|
|
8802
8802
|
const CONNECTOR_FACTORY_BASE_TYPE = 'ConnectorFactory';
|
|
8803
8803
|
/**
|
|
8804
8804
|
* Abstract base class for connector factories
|
|
@@ -8834,7 +8834,7 @@ class ConnectorFactory {
|
|
|
8834
8834
|
}
|
|
8835
8835
|
}
|
|
8836
8836
|
catch (error) {
|
|
8837
|
-
logger$
|
|
8837
|
+
logger$14.warning(`Failed to evaluate grant with factory ${factoryInfo.constructor.name}: ${error}`);
|
|
8838
8838
|
continue;
|
|
8839
8839
|
}
|
|
8840
8840
|
}
|
|
@@ -8877,7 +8877,7 @@ class ConnectorFactory {
|
|
|
8877
8877
|
}
|
|
8878
8878
|
}
|
|
8879
8879
|
catch (error) {
|
|
8880
|
-
logger$
|
|
8880
|
+
logger$14.warning(`Failed to create connector config from grant: ${error}`);
|
|
8881
8881
|
continue;
|
|
8882
8882
|
}
|
|
8883
8883
|
}
|
|
@@ -8944,20 +8944,20 @@ class ConnectorFactory {
|
|
|
8944
8944
|
return existing;
|
|
8945
8945
|
}
|
|
8946
8946
|
if (existing && !this.isGrantAware(existing)) {
|
|
8947
|
-
logger$
|
|
8947
|
+
logger$14.warning(`Factory ${factoryInfo.constructor.name} is registered under ${CONNECTOR_FACTORY_BASE_TYPE} but is missing grant conversion APIs; skipping.`);
|
|
8948
8948
|
return null;
|
|
8949
8949
|
}
|
|
8950
8950
|
try {
|
|
8951
8951
|
const instance = new factoryInfo.constructor();
|
|
8952
8952
|
if (!this.isGrantAware(instance)) {
|
|
8953
|
-
logger$
|
|
8953
|
+
logger$14.warning(`Factory ${factoryInfo.constructor.name} does not implement grant conversion APIs required by ${CONNECTOR_FACTORY_BASE_TYPE}; skipping.`);
|
|
8954
8954
|
return null;
|
|
8955
8955
|
}
|
|
8956
8956
|
factoryInfo.instance = instance;
|
|
8957
8957
|
return instance;
|
|
8958
8958
|
}
|
|
8959
8959
|
catch (error) {
|
|
8960
|
-
logger$
|
|
8960
|
+
logger$14.warning(`Failed to instantiate factory ${factoryInfo.constructor.name} while resolving grant conversion APIs: ${error}`);
|
|
8961
8961
|
return null;
|
|
8962
8962
|
}
|
|
8963
8963
|
}
|
|
@@ -9060,7 +9060,7 @@ class TaskCancellationError extends Error {
|
|
|
9060
9060
|
this.name = 'TaskCancellationError';
|
|
9061
9061
|
}
|
|
9062
9062
|
}
|
|
9063
|
-
const logger$
|
|
9063
|
+
const logger$13 = getLogger('naylence.fame.connector.base_async_connector');
|
|
9064
9064
|
// Environment variables
|
|
9065
9065
|
const ENV_VAR_FAME_FLOW_CONTROL = 'FAME_FLOW_CONTROL';
|
|
9066
9066
|
const FLOW_CONTROL_ENABLED = typeof process !== 'undefined' && process?.env
|
|
@@ -9143,7 +9143,7 @@ class BaseAsyncConnector extends TaskSpawner {
|
|
|
9143
9143
|
if (this._state !== newState) {
|
|
9144
9144
|
const oldState = this._state;
|
|
9145
9145
|
this._state = newState;
|
|
9146
|
-
logger$
|
|
9146
|
+
logger$13.debug('connector_state_transition', {
|
|
9147
9147
|
connector_id: this._connectorFlowId,
|
|
9148
9148
|
old_state: oldState,
|
|
9149
9149
|
new_state: newState,
|
|
@@ -9182,12 +9182,12 @@ class BaseAsyncConnector extends TaskSpawner {
|
|
|
9182
9182
|
* Stop the connector gracefully
|
|
9183
9183
|
*/
|
|
9184
9184
|
async stop() {
|
|
9185
|
-
logger$
|
|
9185
|
+
logger$13.debug('stopping_connector', {
|
|
9186
9186
|
current_state: this._state,
|
|
9187
9187
|
connector_id: this._connectorFlowId,
|
|
9188
9188
|
});
|
|
9189
9189
|
if (!ConnectorStateUtils.canStop(this._state)) {
|
|
9190
|
-
logger$
|
|
9190
|
+
logger$13.debug('connector_stop_already_stopped', {
|
|
9191
9191
|
current_state: this._state,
|
|
9192
9192
|
connector_id: this._connectorFlowId,
|
|
9193
9193
|
});
|
|
@@ -9198,7 +9198,7 @@ class BaseAsyncConnector extends TaskSpawner {
|
|
|
9198
9198
|
if (this._lastError) {
|
|
9199
9199
|
throw this._lastError;
|
|
9200
9200
|
}
|
|
9201
|
-
logger$
|
|
9201
|
+
logger$13.debug('connector_stopped', {
|
|
9202
9202
|
current_state: this._state,
|
|
9203
9203
|
connector_id: this._connectorFlowId,
|
|
9204
9204
|
});
|
|
@@ -9207,19 +9207,19 @@ class BaseAsyncConnector extends TaskSpawner {
|
|
|
9207
9207
|
* Pause the connector (suspends heartbeat and housekeeping, but keeps connection alive)
|
|
9208
9208
|
*/
|
|
9209
9209
|
async pause() {
|
|
9210
|
-
logger$
|
|
9210
|
+
logger$13.debug('pausing_connector', {
|
|
9211
9211
|
current_state: this._state,
|
|
9212
9212
|
connector_id: this._connectorFlowId,
|
|
9213
9213
|
});
|
|
9214
9214
|
if (this._state !== ConnectorState.STARTED) {
|
|
9215
|
-
logger$
|
|
9215
|
+
logger$13.debug('connector_pause_invalid_state', {
|
|
9216
9216
|
current_state: this._state,
|
|
9217
9217
|
connector_id: this._connectorFlowId,
|
|
9218
9218
|
});
|
|
9219
9219
|
return;
|
|
9220
9220
|
}
|
|
9221
9221
|
this._setState(ConnectorState.PAUSED);
|
|
9222
|
-
logger$
|
|
9222
|
+
logger$13.debug('connector_paused', {
|
|
9223
9223
|
current_state: this._state,
|
|
9224
9224
|
connector_id: this._connectorFlowId,
|
|
9225
9225
|
});
|
|
@@ -9228,19 +9228,19 @@ class BaseAsyncConnector extends TaskSpawner {
|
|
|
9228
9228
|
* Resume the connector from paused state
|
|
9229
9229
|
*/
|
|
9230
9230
|
async resume() {
|
|
9231
|
-
logger$
|
|
9231
|
+
logger$13.debug('resuming_connector', {
|
|
9232
9232
|
current_state: this._state,
|
|
9233
9233
|
connector_id: this._connectorFlowId,
|
|
9234
9234
|
});
|
|
9235
9235
|
if (this._state !== ConnectorState.PAUSED) {
|
|
9236
|
-
logger$
|
|
9236
|
+
logger$13.debug('connector_resume_invalid_state', {
|
|
9237
9237
|
current_state: this._state,
|
|
9238
9238
|
connector_id: this._connectorFlowId,
|
|
9239
9239
|
});
|
|
9240
9240
|
return;
|
|
9241
9241
|
}
|
|
9242
9242
|
this._setState(ConnectorState.STARTED);
|
|
9243
|
-
logger$
|
|
9243
|
+
logger$13.debug('connector_resumed', {
|
|
9244
9244
|
current_state: this._state,
|
|
9245
9245
|
connector_id: this._connectorFlowId,
|
|
9246
9246
|
});
|
|
@@ -9250,7 +9250,7 @@ class BaseAsyncConnector extends TaskSpawner {
|
|
|
9250
9250
|
*/
|
|
9251
9251
|
async close(code = 1000, reason = 'normal closure') {
|
|
9252
9252
|
if (!ConnectorStateUtils.canClose(this._state)) {
|
|
9253
|
-
logger$
|
|
9253
|
+
logger$13.warning('connector_close_invalid_state', {
|
|
9254
9254
|
current_state: this._state,
|
|
9255
9255
|
connector_id: this._connectorFlowId,
|
|
9256
9256
|
});
|
|
@@ -9331,7 +9331,7 @@ class BaseAsyncConnector extends TaskSpawner {
|
|
|
9331
9331
|
// Add to queue and notify send loop
|
|
9332
9332
|
this._sendQueue.push(raw);
|
|
9333
9333
|
// Log for debugging
|
|
9334
|
-
logger$
|
|
9334
|
+
logger$13.debug('send_envelope_queued', {
|
|
9335
9335
|
queue_length: this._sendQueue.length,
|
|
9336
9336
|
max_queue_size: this._maxQueueSize,
|
|
9337
9337
|
});
|
|
@@ -9380,14 +9380,14 @@ class BaseAsyncConnector extends TaskSpawner {
|
|
|
9380
9380
|
const item = this._sendQueue[0];
|
|
9381
9381
|
if (!item)
|
|
9382
9382
|
continue;
|
|
9383
|
-
logger$
|
|
9383
|
+
logger$13.debug('send_loop_processing_item', {
|
|
9384
9384
|
queue_length_before_send: this._sendQueue.length,
|
|
9385
9385
|
});
|
|
9386
9386
|
// Send through transport (this may block)
|
|
9387
9387
|
await this._transportSendBytes(item);
|
|
9388
9388
|
// Only remove from queue after successful send
|
|
9389
9389
|
this._sendQueue.shift();
|
|
9390
|
-
logger$
|
|
9390
|
+
logger$13.debug('send_loop_item_sent', {
|
|
9391
9391
|
queue_length_after_send: this._sendQueue.length,
|
|
9392
9392
|
});
|
|
9393
9393
|
}
|
|
@@ -9400,14 +9400,14 @@ class BaseAsyncConnector extends TaskSpawner {
|
|
|
9400
9400
|
}
|
|
9401
9401
|
else if (error instanceof TaskCancellationError) {
|
|
9402
9402
|
// Task cancellation is expected during shutdown - log as debug, not critical
|
|
9403
|
-
logger$
|
|
9403
|
+
logger$13.debug('send loop cancelled', {
|
|
9404
9404
|
connector: this.constructor.name,
|
|
9405
9405
|
reason: error.message,
|
|
9406
9406
|
});
|
|
9407
9407
|
// Don't re-throw - this is normal during shutdown
|
|
9408
9408
|
}
|
|
9409
9409
|
else {
|
|
9410
|
-
logger$
|
|
9410
|
+
logger$13.critical('unexpected exception in send loop', {
|
|
9411
9411
|
connector: this.constructor.name,
|
|
9412
9412
|
error: error instanceof Error ? error.message : String(error),
|
|
9413
9413
|
});
|
|
@@ -9448,7 +9448,7 @@ class BaseAsyncConnector extends TaskSpawner {
|
|
|
9448
9448
|
env = JSON.parse(jsonStr);
|
|
9449
9449
|
}
|
|
9450
9450
|
catch (error) {
|
|
9451
|
-
logger$
|
|
9451
|
+
logger$13.error('Invalid envelope', {
|
|
9452
9452
|
message: message.toString(),
|
|
9453
9453
|
error: error instanceof Error ? error.message : String(error),
|
|
9454
9454
|
});
|
|
@@ -9472,7 +9472,7 @@ class BaseAsyncConnector extends TaskSpawner {
|
|
|
9472
9472
|
};
|
|
9473
9473
|
await withEnvelopeContextAsync(envelopeContext, async () => {
|
|
9474
9474
|
const prettyEnvelope = prettyModel$1(env);
|
|
9475
|
-
logger$
|
|
9475
|
+
logger$13.trace('connector_received_envelope', {
|
|
9476
9476
|
envelope: env,
|
|
9477
9477
|
pretty: prettyEnvelope,
|
|
9478
9478
|
});
|
|
@@ -9501,7 +9501,7 @@ class BaseAsyncConnector extends TaskSpawner {
|
|
|
9501
9501
|
if (error instanceof TaskCancellationError) {
|
|
9502
9502
|
throw error;
|
|
9503
9503
|
}
|
|
9504
|
-
logger$
|
|
9504
|
+
logger$13.error('handler_failed', {
|
|
9505
9505
|
error: error instanceof Error ? error.message : String(error),
|
|
9506
9506
|
envelope_id: env.id ?? null,
|
|
9507
9507
|
trace_id: env.traceId ?? null,
|
|
@@ -9522,14 +9522,14 @@ class BaseAsyncConnector extends TaskSpawner {
|
|
|
9522
9522
|
}
|
|
9523
9523
|
else if (error instanceof TaskCancellationError) {
|
|
9524
9524
|
// Task cancellation is expected during shutdown - log as debug, not critical
|
|
9525
|
-
logger$
|
|
9525
|
+
logger$13.debug('receive loop cancelled', {
|
|
9526
9526
|
connector: this.constructor.name,
|
|
9527
9527
|
reason: error.message,
|
|
9528
9528
|
});
|
|
9529
9529
|
// Don't re-throw - this is normal during shutdown
|
|
9530
9530
|
}
|
|
9531
9531
|
else {
|
|
9532
|
-
logger$
|
|
9532
|
+
logger$13.critical('unexpected_error_in recv_loop', {
|
|
9533
9533
|
error: error instanceof Error ? error.message : String(error),
|
|
9534
9534
|
});
|
|
9535
9535
|
throw error;
|
|
@@ -9545,7 +9545,7 @@ class BaseAsyncConnector extends TaskSpawner {
|
|
|
9545
9545
|
async _maybeEmitCredit(flowId, traceId) {
|
|
9546
9546
|
const remainingCredits = this._flowCtrl.getCredits(flowId);
|
|
9547
9547
|
const needsRefill = this._flowCtrl.needsRefill(flowId);
|
|
9548
|
-
logger$
|
|
9548
|
+
logger$13.debug('maybe_emit_credit_check', {
|
|
9549
9549
|
connector_id: this._connectorFlowId,
|
|
9550
9550
|
flow_id: flowId,
|
|
9551
9551
|
trace_id: traceId ?? null,
|
|
@@ -9561,7 +9561,7 @@ class BaseAsyncConnector extends TaskSpawner {
|
|
|
9561
9561
|
}
|
|
9562
9562
|
const delta = this._initialWindow;
|
|
9563
9563
|
this._flowCtrl.addCredits(flowId, delta);
|
|
9564
|
-
logger$
|
|
9564
|
+
logger$13.debug('maybe_emit_credit_emit', {
|
|
9565
9565
|
connector_id: this._connectorFlowId,
|
|
9566
9566
|
flow_id: flowId,
|
|
9567
9567
|
trace_id: traceId ?? null,
|
|
@@ -9581,7 +9581,7 @@ class BaseAsyncConnector extends TaskSpawner {
|
|
|
9581
9581
|
});
|
|
9582
9582
|
try {
|
|
9583
9583
|
await this.send(ackEnv);
|
|
9584
|
-
logger$
|
|
9584
|
+
logger$13.debug('maybe_emit_credit_sent', {
|
|
9585
9585
|
connector_id: this._connectorFlowId,
|
|
9586
9586
|
flow_id: flowId,
|
|
9587
9587
|
trace_id: traceId ?? null,
|
|
@@ -9589,7 +9589,7 @@ class BaseAsyncConnector extends TaskSpawner {
|
|
|
9589
9589
|
});
|
|
9590
9590
|
}
|
|
9591
9591
|
catch (error) {
|
|
9592
|
-
logger$
|
|
9592
|
+
logger$13.error('maybe_emit_credit_send_failed', {
|
|
9593
9593
|
connector_id: this._connectorFlowId,
|
|
9594
9594
|
flow_id: flowId,
|
|
9595
9595
|
trace_id: traceId ?? null,
|
|
@@ -9614,13 +9614,13 @@ class BaseAsyncConnector extends TaskSpawner {
|
|
|
9614
9614
|
*/
|
|
9615
9615
|
async _shutdown(code, reason, gracePeriod, exc) {
|
|
9616
9616
|
if (this._closed) {
|
|
9617
|
-
logger$
|
|
9617
|
+
logger$13.debug('shutdown_already_closed', {
|
|
9618
9618
|
connector_id: this._connectorFlowId,
|
|
9619
9619
|
current_state: this._state,
|
|
9620
9620
|
});
|
|
9621
9621
|
return;
|
|
9622
9622
|
}
|
|
9623
|
-
logger$
|
|
9623
|
+
logger$13.debug('connector_shutdown_starting', {
|
|
9624
9624
|
connector_id: this._connectorFlowId,
|
|
9625
9625
|
connector_type: this.constructor.name,
|
|
9626
9626
|
code,
|
|
@@ -9650,19 +9650,19 @@ class BaseAsyncConnector extends TaskSpawner {
|
|
|
9650
9650
|
this._sendPromiseResolve = undefined;
|
|
9651
9651
|
}
|
|
9652
9652
|
// Close transport
|
|
9653
|
-
logger$
|
|
9653
|
+
logger$13.debug('connector_closing_transport', {
|
|
9654
9654
|
connector_id: this._connectorFlowId,
|
|
9655
9655
|
connector_type: this.constructor.name,
|
|
9656
9656
|
timestamp: new Date().toISOString(),
|
|
9657
9657
|
});
|
|
9658
9658
|
await this._transportClose(code, reason);
|
|
9659
|
-
logger$
|
|
9659
|
+
logger$13.debug('connector_transport_closed', {
|
|
9660
9660
|
connector_id: this._connectorFlowId,
|
|
9661
9661
|
connector_type: this.constructor.name,
|
|
9662
9662
|
timestamp: new Date().toISOString(),
|
|
9663
9663
|
});
|
|
9664
9664
|
// Shutdown spawned tasks
|
|
9665
|
-
logger$
|
|
9665
|
+
logger$13.debug('connector_shutting_down_tasks', {
|
|
9666
9666
|
connector_id: this._connectorFlowId,
|
|
9667
9667
|
connector_type: this.constructor.name,
|
|
9668
9668
|
grace_period_ms: effectiveGracePeriod * 1000,
|
|
@@ -9674,14 +9674,14 @@ class BaseAsyncConnector extends TaskSpawner {
|
|
|
9674
9674
|
gracePeriod: effectiveGracePeriod * 1000, // Convert to milliseconds
|
|
9675
9675
|
joinTimeout: this._shutdownJoinTimeout,
|
|
9676
9676
|
});
|
|
9677
|
-
logger$
|
|
9677
|
+
logger$13.debug('connector_tasks_shutdown_complete', {
|
|
9678
9678
|
connector_id: this._connectorFlowId,
|
|
9679
9679
|
connector_type: this.constructor.name,
|
|
9680
9680
|
timestamp: new Date().toISOString(),
|
|
9681
9681
|
});
|
|
9682
9682
|
}
|
|
9683
9683
|
catch (error) {
|
|
9684
|
-
logger$
|
|
9684
|
+
logger$13.warning('task_shutdown_error', {
|
|
9685
9685
|
connector_id: this._connectorFlowId,
|
|
9686
9686
|
error: error instanceof Error ? error.message : String(error),
|
|
9687
9687
|
});
|
|
@@ -9694,7 +9694,7 @@ class BaseAsyncConnector extends TaskSpawner {
|
|
|
9694
9694
|
if (this._closeResolver) {
|
|
9695
9695
|
this._closeResolver();
|
|
9696
9696
|
}
|
|
9697
|
-
logger$
|
|
9697
|
+
logger$13.debug('connector_shutdown_complete', {
|
|
9698
9698
|
connector_id: this._connectorFlowId,
|
|
9699
9699
|
connector_type: this.constructor.name,
|
|
9700
9700
|
final_state: this._state,
|
|
@@ -9770,7 +9770,7 @@ class BoundedAsyncQueue {
|
|
|
9770
9770
|
}
|
|
9771
9771
|
}
|
|
9772
9772
|
|
|
9773
|
-
const logger$
|
|
9773
|
+
const logger$12 = getLogger('naylence.fame.connector.broadcast_channel_connector');
|
|
9774
9774
|
const BROADCAST_CHANNEL_CONNECTOR_TYPE = 'broadcast-channel-connector';
|
|
9775
9775
|
const DEFAULT_CHANNEL$7 = 'naylence-fabric';
|
|
9776
9776
|
const DEFAULT_INBOX_CAPACITY$7 = 2048;
|
|
@@ -9859,7 +9859,7 @@ let BroadcastChannelConnector$2 = class BroadcastChannelConnector extends BaseAs
|
|
|
9859
9859
|
this.localNodeId = normalizedLocalNodeId;
|
|
9860
9860
|
this.targetNodeId = BroadcastChannelConnector.normalizeTargetNodeId(config.initialTargetNodeId);
|
|
9861
9861
|
this.channel = new BroadcastChannel(this.channelName);
|
|
9862
|
-
logger$
|
|
9862
|
+
logger$12.debug('broadcast_channel_connector_created', {
|
|
9863
9863
|
channel: this.channelName,
|
|
9864
9864
|
connector_id: this.connectorId,
|
|
9865
9865
|
local_node_id: this.localNodeId,
|
|
@@ -9871,7 +9871,7 @@ let BroadcastChannelConnector$2 = class BroadcastChannelConnector extends BaseAs
|
|
|
9871
9871
|
this.onMsg = (event) => {
|
|
9872
9872
|
// Guard: Don't process if listener was unregistered
|
|
9873
9873
|
if (!this.listenerRegistered) {
|
|
9874
|
-
logger$
|
|
9874
|
+
logger$12.warning('broadcast_channel_message_after_unregister', {
|
|
9875
9875
|
channel: this.channelName,
|
|
9876
9876
|
connector_id: this.connectorId,
|
|
9877
9877
|
timestamp: new Date().toISOString(),
|
|
@@ -9879,7 +9879,7 @@ let BroadcastChannelConnector$2 = class BroadcastChannelConnector extends BaseAs
|
|
|
9879
9879
|
return;
|
|
9880
9880
|
}
|
|
9881
9881
|
const message = event.data;
|
|
9882
|
-
logger$
|
|
9882
|
+
logger$12.debug('broadcast_channel_raw_event', {
|
|
9883
9883
|
channel: this.channelName,
|
|
9884
9884
|
connector_id: this.connectorId,
|
|
9885
9885
|
message_type: message && typeof message === 'object'
|
|
@@ -9895,7 +9895,7 @@ let BroadcastChannelConnector$2 = class BroadcastChannelConnector extends BaseAs
|
|
|
9895
9895
|
const busMessage = message;
|
|
9896
9896
|
const senderNodeId = BroadcastChannelConnector.normalizeNodeId(busMessage.senderNodeId);
|
|
9897
9897
|
if (!senderNodeId) {
|
|
9898
|
-
logger$
|
|
9898
|
+
logger$12.debug('broadcast_channel_message_rejected', {
|
|
9899
9899
|
channel: this.channelName,
|
|
9900
9900
|
connector_id: this.connectorId,
|
|
9901
9901
|
reason: 'missing_sender_node_id',
|
|
@@ -9903,7 +9903,7 @@ let BroadcastChannelConnector$2 = class BroadcastChannelConnector extends BaseAs
|
|
|
9903
9903
|
return;
|
|
9904
9904
|
}
|
|
9905
9905
|
if (senderNodeId === this.localNodeId) {
|
|
9906
|
-
logger$
|
|
9906
|
+
logger$12.debug('broadcast_channel_message_rejected', {
|
|
9907
9907
|
channel: this.channelName,
|
|
9908
9908
|
connector_id: this.connectorId,
|
|
9909
9909
|
reason: 'self_echo',
|
|
@@ -9917,14 +9917,14 @@ let BroadcastChannelConnector$2 = class BroadcastChannelConnector extends BaseAs
|
|
|
9917
9917
|
}
|
|
9918
9918
|
const payload = BroadcastChannelConnector.coercePayload(busMessage.payload);
|
|
9919
9919
|
if (!payload) {
|
|
9920
|
-
logger$
|
|
9920
|
+
logger$12.debug('broadcast_channel_payload_rejected', {
|
|
9921
9921
|
channel: this.channelName,
|
|
9922
9922
|
connector_id: this.connectorId,
|
|
9923
9923
|
reason: 'unrecognized_payload_type',
|
|
9924
9924
|
});
|
|
9925
9925
|
return;
|
|
9926
9926
|
}
|
|
9927
|
-
logger$
|
|
9927
|
+
logger$12.debug('broadcast_channel_message_received', {
|
|
9928
9928
|
channel: this.channelName,
|
|
9929
9929
|
sender_id: message?.senderId,
|
|
9930
9930
|
sender_node_id: senderNodeId,
|
|
@@ -9953,14 +9953,14 @@ let BroadcastChannelConnector$2 = class BroadcastChannelConnector extends BaseAs
|
|
|
9953
9953
|
}
|
|
9954
9954
|
catch (error) {
|
|
9955
9955
|
if (error instanceof QueueFullError) {
|
|
9956
|
-
logger$
|
|
9956
|
+
logger$12.warning('broadcast_channel_receive_queue_full', {
|
|
9957
9957
|
channel: this.channelName,
|
|
9958
9958
|
inbox_capacity: this.inboxCapacity,
|
|
9959
9959
|
inbox_remaining_capacity: this.inbox.remainingCapacity,
|
|
9960
9960
|
});
|
|
9961
9961
|
}
|
|
9962
9962
|
else {
|
|
9963
|
-
logger$
|
|
9963
|
+
logger$12.error('broadcast_channel_receive_error', {
|
|
9964
9964
|
channel: this.channelName,
|
|
9965
9965
|
error: error instanceof Error ? error.message : String(error),
|
|
9966
9966
|
});
|
|
@@ -9974,7 +9974,7 @@ let BroadcastChannelConnector$2 = class BroadcastChannelConnector extends BaseAs
|
|
|
9974
9974
|
// Setup visibility change monitoring
|
|
9975
9975
|
this.visibilityChangeHandler = () => {
|
|
9976
9976
|
const isHidden = document.hidden;
|
|
9977
|
-
logger$
|
|
9977
|
+
logger$12.debug('broadcast_channel_visibility_changed', {
|
|
9978
9978
|
channel: this.channelName,
|
|
9979
9979
|
connector_id: this.connectorId,
|
|
9980
9980
|
visibility: isHidden ? 'hidden' : 'visible',
|
|
@@ -9983,7 +9983,7 @@ let BroadcastChannelConnector$2 = class BroadcastChannelConnector extends BaseAs
|
|
|
9983
9983
|
// Pause/resume connector based on visibility
|
|
9984
9984
|
if (isHidden && this.state === ConnectorState.STARTED) {
|
|
9985
9985
|
this.pause().catch((err) => {
|
|
9986
|
-
logger$
|
|
9986
|
+
logger$12.warning('broadcast_channel_pause_failed', {
|
|
9987
9987
|
channel: this.channelName,
|
|
9988
9988
|
connector_id: this.connectorId,
|
|
9989
9989
|
error: err instanceof Error ? err.message : String(err),
|
|
@@ -9992,7 +9992,7 @@ let BroadcastChannelConnector$2 = class BroadcastChannelConnector extends BaseAs
|
|
|
9992
9992
|
}
|
|
9993
9993
|
else if (!isHidden && this.state === ConnectorState.PAUSED) {
|
|
9994
9994
|
this.resume().catch((err) => {
|
|
9995
|
-
logger$
|
|
9995
|
+
logger$12.warning('broadcast_channel_resume_failed', {
|
|
9996
9996
|
channel: this.channelName,
|
|
9997
9997
|
connector_id: this.connectorId,
|
|
9998
9998
|
error: err instanceof Error ? err.message : String(err),
|
|
@@ -10006,7 +10006,7 @@ let BroadcastChannelConnector$2 = class BroadcastChannelConnector extends BaseAs
|
|
|
10006
10006
|
// Track page lifecycle events to detect browser unload/discard
|
|
10007
10007
|
if (typeof window !== 'undefined') {
|
|
10008
10008
|
const lifecycleLogger = (event) => {
|
|
10009
|
-
logger$
|
|
10009
|
+
logger$12.debug('broadcast_channel_page_lifecycle', {
|
|
10010
10010
|
channel: this.channelName,
|
|
10011
10011
|
connector_id: this.connectorId,
|
|
10012
10012
|
event_type: event.type,
|
|
@@ -10022,7 +10022,7 @@ let BroadcastChannelConnector$2 = class BroadcastChannelConnector extends BaseAs
|
|
|
10022
10022
|
document.addEventListener('resume', lifecycleLogger);
|
|
10023
10023
|
}
|
|
10024
10024
|
// Log initial state with detailed visibility info
|
|
10025
|
-
logger$
|
|
10025
|
+
logger$12.debug('broadcast_channel_initial_visibility', {
|
|
10026
10026
|
channel: this.channelName,
|
|
10027
10027
|
connector_id: this.connectorId,
|
|
10028
10028
|
visibility: document.hidden ? 'hidden' : 'visible',
|
|
@@ -10054,14 +10054,14 @@ let BroadcastChannelConnector$2 = class BroadcastChannelConnector extends BaseAs
|
|
|
10054
10054
|
}
|
|
10055
10055
|
catch (error) {
|
|
10056
10056
|
if (error instanceof QueueFullError) {
|
|
10057
|
-
logger$
|
|
10057
|
+
logger$12.warning('broadcast_channel_push_queue_full', {
|
|
10058
10058
|
channel: this.channelName,
|
|
10059
10059
|
inbox_capacity: this.inboxCapacity,
|
|
10060
10060
|
inbox_remaining_capacity: this.inbox.remainingCapacity,
|
|
10061
10061
|
});
|
|
10062
10062
|
throw error;
|
|
10063
10063
|
}
|
|
10064
|
-
logger$
|
|
10064
|
+
logger$12.error('broadcast_channel_push_failed', {
|
|
10065
10065
|
channel: this.channelName,
|
|
10066
10066
|
error: error instanceof Error ? error.message : String(error),
|
|
10067
10067
|
});
|
|
@@ -10071,7 +10071,7 @@ let BroadcastChannelConnector$2 = class BroadcastChannelConnector extends BaseAs
|
|
|
10071
10071
|
async _transportSendBytes(data) {
|
|
10072
10072
|
ensureBroadcastEnvironment();
|
|
10073
10073
|
const targetNodeId = this.targetNodeId ?? '*';
|
|
10074
|
-
logger$
|
|
10074
|
+
logger$12.debug('broadcast_channel_message_sending', {
|
|
10075
10075
|
channel: this.channelName,
|
|
10076
10076
|
sender_id: this.connectorId,
|
|
10077
10077
|
sender_node_id: this.localNodeId,
|
|
@@ -10092,7 +10092,7 @@ let BroadcastChannelConnector$2 = class BroadcastChannelConnector extends BaseAs
|
|
|
10092
10092
|
return item;
|
|
10093
10093
|
}
|
|
10094
10094
|
async _transportClose(code, reason) {
|
|
10095
|
-
logger$
|
|
10095
|
+
logger$12.debug('broadcast_channel_transport_closing', {
|
|
10096
10096
|
channel: this.channelName,
|
|
10097
10097
|
connector_id: this.connectorId,
|
|
10098
10098
|
code,
|
|
@@ -10101,14 +10101,14 @@ let BroadcastChannelConnector$2 = class BroadcastChannelConnector extends BaseAs
|
|
|
10101
10101
|
timestamp: new Date().toISOString(),
|
|
10102
10102
|
});
|
|
10103
10103
|
if (this.listenerRegistered) {
|
|
10104
|
-
logger$
|
|
10104
|
+
logger$12.debug('broadcast_channel_removing_listener', {
|
|
10105
10105
|
channel: this.channelName,
|
|
10106
10106
|
connector_id: this.connectorId,
|
|
10107
10107
|
timestamp: new Date().toISOString(),
|
|
10108
10108
|
});
|
|
10109
10109
|
this.channel.removeEventListener('message', this.onMsg);
|
|
10110
10110
|
this.listenerRegistered = false;
|
|
10111
|
-
logger$
|
|
10111
|
+
logger$12.debug('broadcast_channel_listener_removed', {
|
|
10112
10112
|
channel: this.channelName,
|
|
10113
10113
|
connector_id: this.connectorId,
|
|
10114
10114
|
timestamp: new Date().toISOString(),
|
|
@@ -10121,13 +10121,13 @@ let BroadcastChannelConnector$2 = class BroadcastChannelConnector extends BaseAs
|
|
|
10121
10121
|
this.visibilityChangeListenerRegistered = false;
|
|
10122
10122
|
this.visibilityChangeHandler = undefined;
|
|
10123
10123
|
}
|
|
10124
|
-
logger$
|
|
10124
|
+
logger$12.debug('broadcast_channel_closing', {
|
|
10125
10125
|
channel: this.channelName,
|
|
10126
10126
|
connector_id: this.connectorId,
|
|
10127
10127
|
timestamp: new Date().toISOString(),
|
|
10128
10128
|
});
|
|
10129
10129
|
this.channel.close();
|
|
10130
|
-
logger$
|
|
10130
|
+
logger$12.debug('broadcast_channel_closed', {
|
|
10131
10131
|
channel: this.channelName,
|
|
10132
10132
|
connector_id: this.connectorId,
|
|
10133
10133
|
timestamp: new Date().toISOString(),
|
|
@@ -10151,7 +10151,7 @@ let BroadcastChannelConnector$2 = class BroadcastChannelConnector extends BaseAs
|
|
|
10151
10151
|
if (targetNodeId &&
|
|
10152
10152
|
targetNodeId !== '*' &&
|
|
10153
10153
|
targetNodeId !== this.localNodeId) {
|
|
10154
|
-
logger$
|
|
10154
|
+
logger$12.debug('broadcast_channel_message_rejected', {
|
|
10155
10155
|
channel: this.channelName,
|
|
10156
10156
|
connector_id: this.connectorId,
|
|
10157
10157
|
reason: 'wildcard_target_mismatch',
|
|
@@ -10167,7 +10167,7 @@ let BroadcastChannelConnector$2 = class BroadcastChannelConnector extends BaseAs
|
|
|
10167
10167
|
if (expectedSender &&
|
|
10168
10168
|
expectedSender !== '*' &&
|
|
10169
10169
|
senderNodeId !== expectedSender) {
|
|
10170
|
-
logger$
|
|
10170
|
+
logger$12.debug('broadcast_channel_message_rejected', {
|
|
10171
10171
|
channel: this.channelName,
|
|
10172
10172
|
connector_id: this.connectorId,
|
|
10173
10173
|
reason: 'unexpected_sender',
|
|
@@ -10180,7 +10180,7 @@ let BroadcastChannelConnector$2 = class BroadcastChannelConnector extends BaseAs
|
|
|
10180
10180
|
if (targetNodeId &&
|
|
10181
10181
|
targetNodeId !== '*' &&
|
|
10182
10182
|
targetNodeId !== this.localNodeId) {
|
|
10183
|
-
logger$
|
|
10183
|
+
logger$12.debug('broadcast_channel_message_rejected', {
|
|
10184
10184
|
channel: this.channelName,
|
|
10185
10185
|
connector_id: this.connectorId,
|
|
10186
10186
|
reason: 'unexpected_target',
|
|
@@ -10205,7 +10205,7 @@ let BroadcastChannelConnector$2 = class BroadcastChannelConnector extends BaseAs
|
|
|
10205
10205
|
return 'unknown';
|
|
10206
10206
|
}
|
|
10207
10207
|
logInboxSnapshot(event, extra = {}) {
|
|
10208
|
-
logger$
|
|
10208
|
+
logger$12.debug(event, {
|
|
10209
10209
|
channel: this.channelName,
|
|
10210
10210
|
connector_id: this.connectorId,
|
|
10211
10211
|
connector_state: this.state,
|
|
@@ -10221,7 +10221,7 @@ let BroadcastChannelConnector$2 = class BroadcastChannelConnector extends BaseAs
|
|
|
10221
10221
|
await super.start(inboundHandler);
|
|
10222
10222
|
// After transitioning to STARTED, check if tab is already hidden
|
|
10223
10223
|
if (typeof document !== 'undefined' && document.hidden) {
|
|
10224
|
-
logger$
|
|
10224
|
+
logger$12.debug('broadcast_channel_start_in_hidden_tab', {
|
|
10225
10225
|
channel: this.channelName,
|
|
10226
10226
|
connector_id: this.connectorId,
|
|
10227
10227
|
document_hidden: document.hidden,
|
|
@@ -10231,7 +10231,7 @@ let BroadcastChannelConnector$2 = class BroadcastChannelConnector extends BaseAs
|
|
|
10231
10231
|
});
|
|
10232
10232
|
// Immediately pause if tab is hidden at start time
|
|
10233
10233
|
await this.pause().catch((err) => {
|
|
10234
|
-
logger$
|
|
10234
|
+
logger$12.warning('broadcast_channel_initial_pause_failed', {
|
|
10235
10235
|
channel: this.channelName,
|
|
10236
10236
|
connector_id: this.connectorId,
|
|
10237
10237
|
error: err instanceof Error ? err.message : String(err),
|
|
@@ -10249,7 +10249,7 @@ let BroadcastChannelConnector$2 = class BroadcastChannelConnector extends BaseAs
|
|
|
10249
10249
|
return;
|
|
10250
10250
|
}
|
|
10251
10251
|
this.targetNodeId = normalized;
|
|
10252
|
-
logger$
|
|
10252
|
+
logger$12.debug('broadcast_channel_target_updated', {
|
|
10253
10253
|
channel: this.channelName,
|
|
10254
10254
|
connector_id: this.connectorId,
|
|
10255
10255
|
local_node_id: this.localNodeId,
|
|
@@ -10259,7 +10259,7 @@ let BroadcastChannelConnector$2 = class BroadcastChannelConnector extends BaseAs
|
|
|
10259
10259
|
}
|
|
10260
10260
|
setWildcardTarget() {
|
|
10261
10261
|
this.targetNodeId = '*';
|
|
10262
|
-
logger$
|
|
10262
|
+
logger$12.debug('broadcast_channel_target_updated', {
|
|
10263
10263
|
channel: this.channelName,
|
|
10264
10264
|
connector_id: this.connectorId,
|
|
10265
10265
|
local_node_id: this.localNodeId,
|
|
@@ -10432,7 +10432,7 @@ function broadcastChannelGrantToConnectorConfig(grant) {
|
|
|
10432
10432
|
return config;
|
|
10433
10433
|
}
|
|
10434
10434
|
|
|
10435
|
-
const logger$
|
|
10435
|
+
const logger$11 = getLogger('naylence.fame.node.upstream_session_manager');
|
|
10436
10436
|
function isPlainRecord$4(value) {
|
|
10437
10437
|
if (typeof value !== 'object' || value === null) {
|
|
10438
10438
|
return false;
|
|
@@ -10553,7 +10553,7 @@ class UpstreamSessionManager extends TaskSpawner {
|
|
|
10553
10553
|
this.wrappedHandler = this.makeHeartbeatEnabledHandler(options.inboundHandler);
|
|
10554
10554
|
// Store the connection retry policy (can be null, in which case default behavior applies)
|
|
10555
10555
|
this.connectionRetryPolicy = options.retryPolicy ?? null;
|
|
10556
|
-
logger$
|
|
10556
|
+
logger$11.debug('created_upstream_session_manager', {
|
|
10557
10557
|
target_system_id: this.targetSystemId,
|
|
10558
10558
|
has_retry_policy: this.connectionRetryPolicy !== null,
|
|
10559
10559
|
});
|
|
@@ -10562,23 +10562,23 @@ class UpstreamSessionManager extends TaskSpawner {
|
|
|
10562
10562
|
return this.targetSystemId;
|
|
10563
10563
|
}
|
|
10564
10564
|
setupVisibilityListener() {
|
|
10565
|
-
logger$
|
|
10565
|
+
logger$11.debug('setup_visibility_listener_called', {
|
|
10566
10566
|
has_document: typeof document !== 'undefined',
|
|
10567
10567
|
});
|
|
10568
10568
|
if (typeof document !== 'undefined' && document.addEventListener) {
|
|
10569
10569
|
this._visibilityHandler = () => {
|
|
10570
|
-
logger$
|
|
10570
|
+
logger$11.debug('visibility_change_event_fired', {
|
|
10571
10571
|
state: document.visibilityState,
|
|
10572
10572
|
});
|
|
10573
10573
|
if (document.visibilityState === 'visible') {
|
|
10574
|
-
logger$
|
|
10574
|
+
logger$11.debug('visibility_change_detected_waking_up');
|
|
10575
10575
|
this.wakeEvent.set();
|
|
10576
10576
|
}
|
|
10577
10577
|
};
|
|
10578
10578
|
document.addEventListener('visibilitychange', this._visibilityHandler);
|
|
10579
10579
|
}
|
|
10580
10580
|
else {
|
|
10581
|
-
logger$
|
|
10581
|
+
logger$11.debug('setup_visibility_listener_skipped_no_document');
|
|
10582
10582
|
}
|
|
10583
10583
|
}
|
|
10584
10584
|
teardownVisibilityListener() {
|
|
@@ -10611,13 +10611,13 @@ class UpstreamSessionManager extends TaskSpawner {
|
|
|
10611
10611
|
}
|
|
10612
10612
|
throw new FameConnectError('Upstream session manager failed to attach');
|
|
10613
10613
|
}
|
|
10614
|
-
logger$
|
|
10614
|
+
logger$11.debug('upstream_session_manager_started');
|
|
10615
10615
|
}
|
|
10616
10616
|
getActiveConnector() {
|
|
10617
10617
|
return this.connector;
|
|
10618
10618
|
}
|
|
10619
10619
|
async stop() {
|
|
10620
|
-
logger$
|
|
10620
|
+
logger$11.debug('upstream_session_manager_stopping');
|
|
10621
10621
|
this.teardownVisibilityListener();
|
|
10622
10622
|
this.stopEvent.set();
|
|
10623
10623
|
this.currentStopSubtasks?.set();
|
|
@@ -10628,7 +10628,7 @@ class UpstreamSessionManager extends TaskSpawner {
|
|
|
10628
10628
|
}
|
|
10629
10629
|
catch (error) {
|
|
10630
10630
|
if (!(error instanceof TaskCancelledError)) {
|
|
10631
|
-
logger$
|
|
10631
|
+
logger$11.debug('fsm_task_stopped_with_error', {
|
|
10632
10632
|
error: error.message,
|
|
10633
10633
|
});
|
|
10634
10634
|
}
|
|
@@ -10637,13 +10637,13 @@ class UpstreamSessionManager extends TaskSpawner {
|
|
|
10637
10637
|
}
|
|
10638
10638
|
if (this.connector) {
|
|
10639
10639
|
await this.connector.stop().catch((error) => {
|
|
10640
|
-
logger$
|
|
10640
|
+
logger$11.debug('connector_stop_error', {
|
|
10641
10641
|
error: error.message,
|
|
10642
10642
|
});
|
|
10643
10643
|
});
|
|
10644
10644
|
this.connector = null;
|
|
10645
10645
|
}
|
|
10646
|
-
logger$
|
|
10646
|
+
logger$11.debug('upstream_session_manager_stopped');
|
|
10647
10647
|
}
|
|
10648
10648
|
async send(envelope) {
|
|
10649
10649
|
if (this.messageQueue.length >= UpstreamSessionManager.TX_QUEUE_MAX) {
|
|
@@ -10692,7 +10692,7 @@ class UpstreamSessionManager extends TaskSpawner {
|
|
|
10692
10692
|
const shouldFailFast = this.shouldFailFastOnError(error);
|
|
10693
10693
|
if (error instanceof FameTransportClose ||
|
|
10694
10694
|
error instanceof FameConnectError) {
|
|
10695
|
-
logger$
|
|
10695
|
+
logger$11.warning('upstream_link_closed', {
|
|
10696
10696
|
error: error.message,
|
|
10697
10697
|
will_retry: !shouldFailFast,
|
|
10698
10698
|
attempt: this.initialAttempts,
|
|
@@ -10705,13 +10705,13 @@ class UpstreamSessionManager extends TaskSpawner {
|
|
|
10705
10705
|
else {
|
|
10706
10706
|
const err = error;
|
|
10707
10707
|
if (err.name === 'OAuth2PkceRedirectInitiatedError') {
|
|
10708
|
-
logger$
|
|
10708
|
+
logger$11.info('upstream_link_redirecting', {
|
|
10709
10709
|
error: err.message,
|
|
10710
10710
|
will_retry: true,
|
|
10711
10711
|
});
|
|
10712
10712
|
}
|
|
10713
10713
|
else {
|
|
10714
|
-
logger$
|
|
10714
|
+
logger$11.warning('upstream_link_closed', {
|
|
10715
10715
|
error: err.message,
|
|
10716
10716
|
will_retry: !shouldFailFast,
|
|
10717
10717
|
attempt: this.initialAttempts,
|
|
@@ -10755,7 +10755,7 @@ class UpstreamSessionManager extends TaskSpawner {
|
|
|
10755
10755
|
// If sleep was interrupted by visibility change (user returned to tab),
|
|
10756
10756
|
// reset backoff to initial delay for immediate retry with fresh backoff
|
|
10757
10757
|
if (wasWoken) {
|
|
10758
|
-
logger$
|
|
10758
|
+
logger$11.debug('backoff_reset_on_visibility_change', {
|
|
10759
10759
|
previous_delay: delay,
|
|
10760
10760
|
new_delay: UpstreamSessionManager.BACKOFF_INITIAL,
|
|
10761
10761
|
});
|
|
@@ -10774,7 +10774,7 @@ class UpstreamSessionManager extends TaskSpawner {
|
|
|
10774
10774
|
// Check if wake event is already set (e.g., visibility just changed)
|
|
10775
10775
|
if (this.wakeEvent.isSet()) {
|
|
10776
10776
|
this.wakeEvent.clear();
|
|
10777
|
-
logger$
|
|
10777
|
+
logger$11.debug('sleep_skipped_wake_event_pending');
|
|
10778
10778
|
return true;
|
|
10779
10779
|
}
|
|
10780
10780
|
let timeout;
|
|
@@ -10791,7 +10791,7 @@ class UpstreamSessionManager extends TaskSpawner {
|
|
|
10791
10791
|
]);
|
|
10792
10792
|
const wasWoken = this.wakeEvent.isSet();
|
|
10793
10793
|
if (wasWoken) {
|
|
10794
|
-
logger$
|
|
10794
|
+
logger$11.debug('sleep_interrupted_by_wake_event');
|
|
10795
10795
|
this.wakeEvent.clear();
|
|
10796
10796
|
}
|
|
10797
10797
|
if (timeout !== undefined) {
|
|
@@ -10854,7 +10854,7 @@ class UpstreamSessionManager extends TaskSpawner {
|
|
|
10854
10854
|
await connector.start(this.wrappedHandler);
|
|
10855
10855
|
this.connector = connector;
|
|
10856
10856
|
const callbackGrants = this.node.gatherSupportedCallbackGrants();
|
|
10857
|
-
logger$
|
|
10857
|
+
logger$11.debug('callback_grants_before_augmentation', {
|
|
10858
10858
|
count: callbackGrants.length,
|
|
10859
10859
|
types: callbackGrants.map((g) => g.type),
|
|
10860
10860
|
});
|
|
@@ -10864,7 +10864,7 @@ class UpstreamSessionManager extends TaskSpawner {
|
|
|
10864
10864
|
const broadcastCallbackGrant = shouldAddBroadcastGrant
|
|
10865
10865
|
? this.createBroadcastCallbackGrant(grant)
|
|
10866
10866
|
: null;
|
|
10867
|
-
logger$
|
|
10867
|
+
logger$11.debug('broadcast_callback_grant_check', {
|
|
10868
10868
|
should_add: shouldAddBroadcastGrant,
|
|
10869
10869
|
grant_created: !!broadcastCallbackGrant,
|
|
10870
10870
|
});
|
|
@@ -10883,12 +10883,12 @@ class UpstreamSessionManager extends TaskSpawner {
|
|
|
10883
10883
|
const isDuplicate = callbackGrants.some((existing) => JSON.stringify(existing) === JSON.stringify(grant));
|
|
10884
10884
|
if (!isDuplicate) {
|
|
10885
10885
|
callbackGrants.push(grant);
|
|
10886
|
-
logger$
|
|
10886
|
+
logger$11.debug('added_connection_grant_as_callback', {
|
|
10887
10887
|
type: grant.type,
|
|
10888
10888
|
});
|
|
10889
10889
|
}
|
|
10890
10890
|
else {
|
|
10891
|
-
logger$
|
|
10891
|
+
logger$11.debug('skipped_duplicate_connection_grant', {
|
|
10892
10892
|
type: grant.type,
|
|
10893
10893
|
});
|
|
10894
10894
|
}
|
|
@@ -10900,12 +10900,12 @@ class UpstreamSessionManager extends TaskSpawner {
|
|
|
10900
10900
|
if (broadcastCallbackGrant &&
|
|
10901
10901
|
this.shouldAdvertiseBroadcastGrant(grant, callbackGrants)) {
|
|
10902
10902
|
callbackGrants.push(broadcastCallbackGrant);
|
|
10903
|
-
logger$
|
|
10903
|
+
logger$11.debug('added_broadcast_callback_grant');
|
|
10904
10904
|
}
|
|
10905
10905
|
else if (broadcastCallbackGrant) {
|
|
10906
|
-
logger$
|
|
10906
|
+
logger$11.debug('skipped_duplicate_broadcast_callback_grant');
|
|
10907
10907
|
}
|
|
10908
|
-
logger$
|
|
10908
|
+
logger$11.debug('callback_grants_after_augmentation', {
|
|
10909
10909
|
count: callbackGrants.length,
|
|
10910
10910
|
types: callbackGrants.map((g) => g.type),
|
|
10911
10911
|
});
|
|
@@ -10918,7 +10918,7 @@ class UpstreamSessionManager extends TaskSpawner {
|
|
|
10918
10918
|
targetAware.setTargetNodeId(this.targetSystemId);
|
|
10919
10919
|
}
|
|
10920
10920
|
catch (error) {
|
|
10921
|
-
logger$
|
|
10921
|
+
logger$11.warning('broadcast_channel_target_apply_failed', {
|
|
10922
10922
|
error: error instanceof Error ? error.message : String(error),
|
|
10923
10923
|
target_node_id: this.targetSystemId,
|
|
10924
10924
|
});
|
|
@@ -10940,14 +10940,14 @@ class UpstreamSessionManager extends TaskSpawner {
|
|
|
10940
10940
|
});
|
|
10941
10941
|
}
|
|
10942
10942
|
else {
|
|
10943
|
-
logger$
|
|
10943
|
+
logger$11.warning('parent_epoch_changed', { epoch });
|
|
10944
10944
|
}
|
|
10945
10945
|
}
|
|
10946
10946
|
if (!this.readyEvent.isSet()) {
|
|
10947
10947
|
this.readyEvent.set();
|
|
10948
10948
|
}
|
|
10949
10949
|
if (this.messageQueue.length > 0) {
|
|
10950
|
-
logger$
|
|
10950
|
+
logger$11.debug('flushing_buffered_frames', {
|
|
10951
10951
|
queue_size: this.messageQueue.length,
|
|
10952
10952
|
});
|
|
10953
10953
|
this.queueEvent.set();
|
|
@@ -10964,12 +10964,12 @@ class UpstreamSessionManager extends TaskSpawner {
|
|
|
10964
10964
|
name: `expiry-guard-${this.connectEpoch}`,
|
|
10965
10965
|
});
|
|
10966
10966
|
if (this.hadSuccessfulAttach) {
|
|
10967
|
-
logger$
|
|
10967
|
+
logger$11.debug('reconnected_to_upstream', {
|
|
10968
10968
|
attach_expires_at: attachInfo.attachExpiresAt?.toISOString?.() ?? null,
|
|
10969
10969
|
});
|
|
10970
10970
|
}
|
|
10971
10971
|
else {
|
|
10972
|
-
logger$
|
|
10972
|
+
logger$11.debug('connected_to_upstream', {
|
|
10973
10973
|
attach_expires_at: attachInfo.attachExpiresAt?.toISOString?.() ?? null,
|
|
10974
10974
|
});
|
|
10975
10975
|
}
|
|
@@ -10987,18 +10987,18 @@ class UpstreamSessionManager extends TaskSpawner {
|
|
|
10987
10987
|
this.currentStopSubtasks = null;
|
|
10988
10988
|
await Promise.allSettled(tasks.map((task) => task.promise));
|
|
10989
10989
|
if (this.connector) {
|
|
10990
|
-
logger$
|
|
10990
|
+
logger$11.debug('upstream_stopping_old_connector', {
|
|
10991
10991
|
connect_epoch: this.connectEpoch,
|
|
10992
10992
|
target_system_id: this.targetSystemId,
|
|
10993
10993
|
timestamp: new Date().toISOString(),
|
|
10994
10994
|
});
|
|
10995
10995
|
await this.connector.stop().catch((err) => {
|
|
10996
|
-
logger$
|
|
10996
|
+
logger$11.warning('upstream_connector_stop_error', {
|
|
10997
10997
|
connect_epoch: this.connectEpoch,
|
|
10998
10998
|
error: err instanceof Error ? err.message : String(err),
|
|
10999
10999
|
});
|
|
11000
11000
|
});
|
|
11001
|
-
logger$
|
|
11001
|
+
logger$11.debug('upstream_old_connector_stopped', {
|
|
11002
11002
|
connect_epoch: this.connectEpoch,
|
|
11003
11003
|
target_system_id: this.targetSystemId,
|
|
11004
11004
|
timestamp: new Date().toISOString(),
|
|
@@ -11051,7 +11051,7 @@ class UpstreamSessionManager extends TaskSpawner {
|
|
|
11051
11051
|
});
|
|
11052
11052
|
}
|
|
11053
11053
|
catch (error) {
|
|
11054
|
-
logger$
|
|
11054
|
+
logger$11.debug('broadcast_callback_grant_generation_failed', {
|
|
11055
11055
|
error: error instanceof Error ? error.message : String(error),
|
|
11056
11056
|
});
|
|
11057
11057
|
return null;
|
|
@@ -11106,7 +11106,7 @@ class UpstreamSessionManager extends TaskSpawner {
|
|
|
11106
11106
|
}
|
|
11107
11107
|
}
|
|
11108
11108
|
async heartbeatLoop(connector, stopEvt, signal) {
|
|
11109
|
-
logger$
|
|
11109
|
+
logger$11.debug('starting_heartbeat_loop');
|
|
11110
11110
|
const intervalMs = UpstreamSessionManager.HEARTBEAT_INTERVAL * 1000;
|
|
11111
11111
|
const graceMs = intervalMs * UpstreamSessionManager.HEARTBEAT_GRACE;
|
|
11112
11112
|
this.lastHeartbeatAckTime = Date.now();
|
|
@@ -11142,7 +11142,7 @@ class UpstreamSessionManager extends TaskSpawner {
|
|
|
11142
11142
|
// Skip heartbeat if connector is paused (e.g., tab is hidden)
|
|
11143
11143
|
// Keep ack time current so we don't timeout immediately after resuming
|
|
11144
11144
|
if (currentState === ConnectorState.PAUSED) {
|
|
11145
|
-
logger$
|
|
11145
|
+
logger$11.debug('skipping_heartbeat_connector_paused', {
|
|
11146
11146
|
connector_state: currentState,
|
|
11147
11147
|
});
|
|
11148
11148
|
this.lastHeartbeatAckTime = Date.now();
|
|
@@ -11151,14 +11151,14 @@ class UpstreamSessionManager extends TaskSpawner {
|
|
|
11151
11151
|
// Reset ack time if just resumed from pause (prevents immediate timeout)
|
|
11152
11152
|
if (previousState === ConnectorState.PAUSED &&
|
|
11153
11153
|
currentState === ConnectorState.STARTED) {
|
|
11154
|
-
logger$
|
|
11154
|
+
logger$11.debug('connector_just_resumed_resetting_ack_time', {
|
|
11155
11155
|
previous_state: previousState,
|
|
11156
11156
|
current_state: currentState,
|
|
11157
11157
|
});
|
|
11158
11158
|
this.lastHeartbeatAckTime = Date.now();
|
|
11159
11159
|
}
|
|
11160
11160
|
const envelope = await this.makeHeartbeatEnvelope();
|
|
11161
|
-
logger$
|
|
11161
|
+
logger$11.debug('sending_heartbeat', {
|
|
11162
11162
|
hb_corr_id: envelope.corrId,
|
|
11163
11163
|
hb_env_id: envelope.id,
|
|
11164
11164
|
});
|
|
@@ -11184,7 +11184,7 @@ class UpstreamSessionManager extends TaskSpawner {
|
|
|
11184
11184
|
throw new FameConnectError('missed heartbeat acknowledgement');
|
|
11185
11185
|
}
|
|
11186
11186
|
}
|
|
11187
|
-
logger$
|
|
11187
|
+
logger$11.debug('completed_heartbeat_loop');
|
|
11188
11188
|
}
|
|
11189
11189
|
async messagePumpLoop(connector, stopEvt, signal) {
|
|
11190
11190
|
while (!stopEvt.isSet() && !signal?.aborted) {
|
|
@@ -11201,19 +11201,19 @@ class UpstreamSessionManager extends TaskSpawner {
|
|
|
11201
11201
|
if (!envelope) {
|
|
11202
11202
|
continue;
|
|
11203
11203
|
}
|
|
11204
|
-
logger$
|
|
11204
|
+
logger$11.debug('upstream_pump_sending_envelope', {
|
|
11205
11205
|
envelopeId: envelope.id,
|
|
11206
11206
|
type: envelope.frame?.type,
|
|
11207
11207
|
});
|
|
11208
11208
|
try {
|
|
11209
11209
|
await connector.send(envelope);
|
|
11210
|
-
logger$
|
|
11210
|
+
logger$11.debug('upstream_pump_sent_envelope', {
|
|
11211
11211
|
envelopeId: envelope.id,
|
|
11212
11212
|
});
|
|
11213
11213
|
}
|
|
11214
11214
|
catch (error) {
|
|
11215
11215
|
if (error instanceof FameMessageTooLarge) {
|
|
11216
|
-
logger$
|
|
11216
|
+
logger$11.error('failed_to_send_message', { error: error.message });
|
|
11217
11217
|
await this.handleMessageTooLarge(envelope, error.message);
|
|
11218
11218
|
}
|
|
11219
11219
|
else if (error instanceof FameTransportClose) {
|
|
@@ -11275,7 +11275,7 @@ class UpstreamSessionManager extends TaskSpawner {
|
|
|
11275
11275
|
await fabric.send(ackEnvelope);
|
|
11276
11276
|
}
|
|
11277
11277
|
catch (error) {
|
|
11278
|
-
logger$
|
|
11278
|
+
logger$11.warning('failed_to_send_nack', {
|
|
11279
11279
|
error: error.message,
|
|
11280
11280
|
});
|
|
11281
11281
|
}
|
|
@@ -11289,7 +11289,7 @@ class UpstreamSessionManager extends TaskSpawner {
|
|
|
11289
11289
|
timestamps.push(info.attachExpiresAt);
|
|
11290
11290
|
}
|
|
11291
11291
|
if (!timestamps.length) {
|
|
11292
|
-
logger$
|
|
11292
|
+
logger$11.debug('no_ttl_expiry_configured');
|
|
11293
11293
|
await this.waitEvent(stopEvt, signal);
|
|
11294
11294
|
return;
|
|
11295
11295
|
}
|
|
@@ -11298,7 +11298,7 @@ class UpstreamSessionManager extends TaskSpawner {
|
|
|
11298
11298
|
let delaySeconds = (earliest.getTime() - now.getTime()) / 1000 -
|
|
11299
11299
|
UpstreamSessionManager.JWT_REFRESH_SAFETY;
|
|
11300
11300
|
delaySeconds = Math.max(delaySeconds, UpstreamSessionManager.JWT_REFRESH_SAFETY);
|
|
11301
|
-
logger$
|
|
11301
|
+
logger$11.debug('ttl_expiry_guard_started', {
|
|
11302
11302
|
welcome_expires_at: welcome.frame.expiresAt ?? null,
|
|
11303
11303
|
attach_expires_at: info.attachExpiresAt?.toISOString?.() ?? null,
|
|
11304
11304
|
earliest_expiry: earliest.toISOString(),
|
|
@@ -11326,7 +11326,7 @@ class UpstreamSessionManager extends TaskSpawner {
|
|
|
11326
11326
|
}
|
|
11327
11327
|
}
|
|
11328
11328
|
if (!stopEvt.isSet()) {
|
|
11329
|
-
logger$
|
|
11329
|
+
logger$11.debug('ttl_expiry_triggered_reconnect', {
|
|
11330
11330
|
expires_at: earliest.toISOString(),
|
|
11331
11331
|
current_time: new Date().toISOString(),
|
|
11332
11332
|
seconds_before_expiry: UpstreamSessionManager.JWT_REFRESH_SAFETY,
|
|
@@ -11371,7 +11371,7 @@ class UpstreamSessionManager extends TaskSpawner {
|
|
|
11371
11371
|
}
|
|
11372
11372
|
await this.node.dispatchEnvelopeEvent('onEnvelopeReceived', this.node, env, context);
|
|
11373
11373
|
if (env.frame.type === 'NodeHeartbeatAck') {
|
|
11374
|
-
logger$
|
|
11374
|
+
logger$11.debug('received_heartbeat_ack', {
|
|
11375
11375
|
hb_ack_env_id: env.id,
|
|
11376
11376
|
hb_ack_corr_id: env.corrId,
|
|
11377
11377
|
hb_routing_epoch: env.frame.routingEpoch,
|
|
@@ -11385,7 +11385,7 @@ class UpstreamSessionManager extends TaskSpawner {
|
|
|
11385
11385
|
await this.onEpochChange(epoch);
|
|
11386
11386
|
}
|
|
11387
11387
|
else {
|
|
11388
|
-
logger$
|
|
11388
|
+
logger$11.warning('parent_epoch_changed', { epoch });
|
|
11389
11389
|
}
|
|
11390
11390
|
}
|
|
11391
11391
|
return;
|
|
@@ -11404,7 +11404,7 @@ UpstreamSessionManager.TX_QUEUE_MAX = 512;
|
|
|
11404
11404
|
UpstreamSessionManager.BACKOFF_INITIAL = 1; // seconds
|
|
11405
11405
|
UpstreamSessionManager.BACKOFF_CAP = 30; // seconds
|
|
11406
11406
|
|
|
11407
|
-
const logger$
|
|
11407
|
+
const logger$10 = getLogger('naylence.fame.node.admission.noop_admission_client');
|
|
11408
11408
|
class NoopAdmissionClient {
|
|
11409
11409
|
constructor(options = {}) {
|
|
11410
11410
|
this.hasUpstream = false;
|
|
@@ -11418,7 +11418,7 @@ class NoopAdmissionClient {
|
|
|
11418
11418
|
const acceptedLogicals = this.autoAcceptLogicals
|
|
11419
11419
|
? [...(requestedLogicals ?? [])]
|
|
11420
11420
|
: [];
|
|
11421
|
-
logger$
|
|
11421
|
+
logger$10.debug('noop_admission_hello', {
|
|
11422
11422
|
systemId: effectiveSystemId,
|
|
11423
11423
|
instanceId,
|
|
11424
11424
|
requestedLogicals,
|
|
@@ -11436,7 +11436,7 @@ class NoopAdmissionClient {
|
|
|
11436
11436
|
});
|
|
11437
11437
|
}
|
|
11438
11438
|
async close() {
|
|
11439
|
-
logger$
|
|
11439
|
+
logger$10.debug('noop_admission_close');
|
|
11440
11440
|
}
|
|
11441
11441
|
}
|
|
11442
11442
|
|
|
@@ -11642,7 +11642,7 @@ class DefaultServiceManager {
|
|
|
11642
11642
|
}
|
|
11643
11643
|
|
|
11644
11644
|
const SYSTEM_INBOX$1 = '__sys__';
|
|
11645
|
-
const logger
|
|
11645
|
+
const logger$$ = getLogger('naylence.fame.node.node');
|
|
11646
11646
|
function isSnakeCase(name) {
|
|
11647
11647
|
return name.includes('_');
|
|
11648
11648
|
}
|
|
@@ -11912,7 +11912,7 @@ class FameNode extends TaskSpawner {
|
|
|
11912
11912
|
confirmIdentity(systemId, source) {
|
|
11913
11913
|
if (this._confirmedId) {
|
|
11914
11914
|
if (this._confirmedId !== systemId) {
|
|
11915
|
-
logger
|
|
11915
|
+
logger$$.error('node_identity_mismatch', {
|
|
11916
11916
|
current_id: this._confirmedId,
|
|
11917
11917
|
new_id: systemId,
|
|
11918
11918
|
source,
|
|
@@ -11924,14 +11924,14 @@ class FameNode extends TaskSpawner {
|
|
|
11924
11924
|
const isReassignment = this._provisionalId !== systemId;
|
|
11925
11925
|
this._confirmedId = systemId;
|
|
11926
11926
|
if (isReassignment) {
|
|
11927
|
-
logger
|
|
11927
|
+
logger$$.debug('node_identity_reassigned', {
|
|
11928
11928
|
system_id: systemId,
|
|
11929
11929
|
previous_id: this._provisionalId,
|
|
11930
11930
|
source,
|
|
11931
11931
|
});
|
|
11932
11932
|
}
|
|
11933
11933
|
else {
|
|
11934
|
-
logger
|
|
11934
|
+
logger$$.debug('node_identity_confirmed', {
|
|
11935
11935
|
system_id: systemId,
|
|
11936
11936
|
source,
|
|
11937
11937
|
});
|
|
@@ -11999,7 +11999,7 @@ class FameNode extends TaskSpawner {
|
|
|
11999
11999
|
return;
|
|
12000
12000
|
}
|
|
12001
12001
|
if (frameType === 'NodeHeartbeat') {
|
|
12002
|
-
logger
|
|
12002
|
+
logger$$.debug('received_heartbeat_frame', {
|
|
12003
12003
|
envelopeId: envelope.id,
|
|
12004
12004
|
corrId: envelope.corrId ?? null,
|
|
12005
12005
|
});
|
|
@@ -12011,7 +12011,7 @@ class FameNode extends TaskSpawner {
|
|
|
12011
12011
|
await this.handleDeliveryAck(envelope, context);
|
|
12012
12012
|
return;
|
|
12013
12013
|
}
|
|
12014
|
-
logger
|
|
12014
|
+
logger$$.debug('unhandled_system_frame', {
|
|
12015
12015
|
envelopeId: envelope.id,
|
|
12016
12016
|
frameType,
|
|
12017
12017
|
});
|
|
@@ -12023,13 +12023,13 @@ class FameNode extends TaskSpawner {
|
|
|
12023
12023
|
}
|
|
12024
12024
|
await this._deliveryTracker.onEnvelopeDelivered(SYSTEM_INBOX$1, envelope, context);
|
|
12025
12025
|
if (frame.ok !== false) {
|
|
12026
|
-
logger
|
|
12026
|
+
logger$$.debug('delivery_ack_received', {
|
|
12027
12027
|
envelopeId: envelope.id,
|
|
12028
12028
|
corrId: envelope.corrId ?? null,
|
|
12029
12029
|
});
|
|
12030
12030
|
return;
|
|
12031
12031
|
}
|
|
12032
|
-
logger
|
|
12032
|
+
logger$$.warning('delivery_nack_received', {
|
|
12033
12033
|
envelopeId: envelope.id,
|
|
12034
12034
|
corrId: envelope.corrId ?? null,
|
|
12035
12035
|
code: frame.code ?? null,
|
|
@@ -12039,7 +12039,7 @@ class FameNode extends TaskSpawner {
|
|
|
12039
12039
|
await this.onDeliveryNack(frame, envelope, context);
|
|
12040
12040
|
}
|
|
12041
12041
|
async onDeliveryNack(frame, envelope, _context) {
|
|
12042
|
-
logger
|
|
12042
|
+
logger$$.debug('delivery_nack_processed', {
|
|
12043
12043
|
envelopeId: envelope.id,
|
|
12044
12044
|
code: frame.code ?? null,
|
|
12045
12045
|
reason: frame.reason ?? null,
|
|
@@ -12154,7 +12154,7 @@ class FameNode extends TaskSpawner {
|
|
|
12154
12154
|
await this._bindingManager.restore();
|
|
12155
12155
|
await this._envelopeListenerManager.start();
|
|
12156
12156
|
this._isStarted = true;
|
|
12157
|
-
logger
|
|
12157
|
+
logger$$.debug('node_started', {
|
|
12158
12158
|
node_id: this.id,
|
|
12159
12159
|
sid: this.sid,
|
|
12160
12160
|
path: this.physicalPath,
|
|
@@ -12186,7 +12186,7 @@ class FameNode extends TaskSpawner {
|
|
|
12186
12186
|
await this._serviceManager.stop();
|
|
12187
12187
|
await this.dispatchEvent('onNodeStopped', this);
|
|
12188
12188
|
this._isStarted = false;
|
|
12189
|
-
logger
|
|
12189
|
+
logger$$.debug('node_stopped', {
|
|
12190
12190
|
node_id: this.id,
|
|
12191
12191
|
});
|
|
12192
12192
|
}
|
|
@@ -12376,20 +12376,20 @@ class FameNode extends TaskSpawner {
|
|
|
12376
12376
|
await this.forwardUpstream(processedEnvelope, context);
|
|
12377
12377
|
}
|
|
12378
12378
|
else {
|
|
12379
|
-
logger
|
|
12379
|
+
logger$$.error('attempted_upstream_loop', {
|
|
12380
12380
|
envelopeId: processedEnvelope.id,
|
|
12381
12381
|
});
|
|
12382
12382
|
}
|
|
12383
12383
|
return;
|
|
12384
12384
|
}
|
|
12385
12385
|
if (!processedEnvelope.to) {
|
|
12386
|
-
logger
|
|
12386
|
+
logger$$.error('dropping_envelope_without_destination', {
|
|
12387
12387
|
envelopeId: processedEnvelope.id,
|
|
12388
12388
|
capabilities: processedEnvelope.capabilities ?? [],
|
|
12389
12389
|
});
|
|
12390
12390
|
return;
|
|
12391
12391
|
}
|
|
12392
|
-
logger
|
|
12392
|
+
logger$$.warning('no_local_handler_for_address', {
|
|
12393
12393
|
address: processedEnvelope.to.toString?.() ?? String(processedEnvelope.to),
|
|
12394
12394
|
originType: context?.originType ?? null,
|
|
12395
12395
|
});
|
|
@@ -12513,7 +12513,7 @@ class FameNode extends TaskSpawner {
|
|
|
12513
12513
|
}
|
|
12514
12514
|
}
|
|
12515
12515
|
catch (error) {
|
|
12516
|
-
logger
|
|
12516
|
+
logger$$.warning('callback_grant_collection_failed', {
|
|
12517
12517
|
error: error instanceof Error ? error.message : String(error),
|
|
12518
12518
|
});
|
|
12519
12519
|
}
|
|
@@ -12576,7 +12576,7 @@ class FameNode extends TaskSpawner {
|
|
|
12576
12576
|
await store.set('self', record);
|
|
12577
12577
|
}
|
|
12578
12578
|
catch (error) {
|
|
12579
|
-
logger
|
|
12579
|
+
logger$$.warning('node_meta_persist_failed', {
|
|
12580
12580
|
error: error instanceof Error ? error.message : String(error),
|
|
12581
12581
|
});
|
|
12582
12582
|
}
|
|
@@ -12714,44 +12714,12 @@ class ConnectionRetryPolicyFactory extends AbstractResourceFactory {
|
|
|
12714
12714
|
}
|
|
12715
12715
|
}
|
|
12716
12716
|
|
|
12717
|
-
|
|
12718
|
-
|
|
12719
|
-
|
|
12720
|
-
|
|
12721
|
-
|
|
12722
|
-
|
|
12723
|
-
throw new Error('Failed to create token provider from configuration');
|
|
12724
|
-
}
|
|
12725
|
-
return provider;
|
|
12726
|
-
}
|
|
12727
|
-
let provider = null;
|
|
12728
|
-
try {
|
|
12729
|
-
provider = await createDefaultResource(TOKEN_PROVIDER_FACTORY_BASE_TYPE, null, options);
|
|
12730
|
-
}
|
|
12731
|
-
catch (error) {
|
|
12732
|
-
const message = 'Failed to create default token provider' +
|
|
12733
|
-
(error instanceof Error && error.message ? `: ${error.message}` : '');
|
|
12734
|
-
throw new Error(message);
|
|
12735
|
-
}
|
|
12736
|
-
if (!provider) {
|
|
12737
|
-
throw new Error('Failed to create default token provider');
|
|
12738
|
-
}
|
|
12739
|
-
return provider;
|
|
12740
|
-
}
|
|
12741
|
-
}
|
|
12742
|
-
|
|
12743
|
-
function isTokenProvider(candidate) {
|
|
12744
|
-
return (typeof candidate === 'object' &&
|
|
12745
|
-
candidate !== null &&
|
|
12746
|
-
typeof candidate.getToken === 'function');
|
|
12747
|
-
}
|
|
12748
|
-
function isIdentityExposingTokenProvider(candidate) {
|
|
12749
|
-
return (isTokenProvider(candidate) &&
|
|
12750
|
-
typeof candidate.getIdentity ===
|
|
12751
|
-
'function');
|
|
12752
|
-
}
|
|
12753
|
-
|
|
12754
|
-
const logger$$ = getLogger('naylence.fame.node.default_node_identity_policy');
|
|
12717
|
+
/**
|
|
12718
|
+
* Default node identity policy that preserves the current node ID.
|
|
12719
|
+
*
|
|
12720
|
+
* This policy does NOT derive identity from tokens or grants.
|
|
12721
|
+
* For token-subject-based identity, use TokenSubjectNodeIdentityPolicy.
|
|
12722
|
+
*/
|
|
12755
12723
|
class DefaultNodeIdentityPolicy {
|
|
12756
12724
|
async resolveInitialNodeId(context) {
|
|
12757
12725
|
if (context.configuredId) {
|
|
@@ -12763,44 +12731,10 @@ class DefaultNodeIdentityPolicy {
|
|
|
12763
12731
|
return await generateIdAsync({ mode: 'fingerprint' });
|
|
12764
12732
|
}
|
|
12765
12733
|
async resolveAdmissionNodeId(context) {
|
|
12766
|
-
|
|
12767
|
-
|
|
12768
|
-
for (const grant of context.grants) {
|
|
12769
|
-
try {
|
|
12770
|
-
const auth = grant.auth;
|
|
12771
|
-
if (!auth) {
|
|
12772
|
-
continue;
|
|
12773
|
-
}
|
|
12774
|
-
const tokenProviderConfig = (auth.tokenProvider ??
|
|
12775
|
-
auth.token_provider);
|
|
12776
|
-
if (!tokenProviderConfig ||
|
|
12777
|
-
typeof tokenProviderConfig.type !== 'string') {
|
|
12778
|
-
continue;
|
|
12779
|
-
}
|
|
12780
|
-
const provider = await TokenProviderFactory.createTokenProvider(tokenProviderConfig);
|
|
12781
|
-
if (isIdentityExposingTokenProvider(provider)) {
|
|
12782
|
-
const identity = await provider.getIdentity();
|
|
12783
|
-
if (identity && identity.subject) {
|
|
12784
|
-
logger$$.debug('identity_extracted_from_grant', {
|
|
12785
|
-
identity_id: identity.subject,
|
|
12786
|
-
grant_type: grant.type,
|
|
12787
|
-
});
|
|
12788
|
-
return identity.subject;
|
|
12789
|
-
}
|
|
12790
|
-
}
|
|
12791
|
-
}
|
|
12792
|
-
catch (error) {
|
|
12793
|
-
logger$$.warning('identity_extraction_failed', {
|
|
12794
|
-
error: error instanceof Error ? error.message : String(error),
|
|
12795
|
-
grant_type: grant.type,
|
|
12796
|
-
});
|
|
12797
|
-
}
|
|
12798
|
-
}
|
|
12799
|
-
}
|
|
12800
|
-
if (!context.currentNodeId) {
|
|
12801
|
-
return await generateIdAsync({ mode: 'fingerprint' });
|
|
12734
|
+
if (context.currentNodeId) {
|
|
12735
|
+
return context.currentNodeId;
|
|
12802
12736
|
}
|
|
12803
|
-
return
|
|
12737
|
+
return await generateIdAsync({ mode: 'fingerprint' });
|
|
12804
12738
|
}
|
|
12805
12739
|
}
|
|
12806
12740
|
|
|
@@ -15978,6 +15912,43 @@ var defaultNodeIdentityPolicyFactory = /*#__PURE__*/Object.freeze({
|
|
|
15978
15912
|
default: DefaultNodeIdentityPolicyFactory
|
|
15979
15913
|
});
|
|
15980
15914
|
|
|
15915
|
+
const TOKEN_PROVIDER_FACTORY_BASE_TYPE = 'TokenProviderFactory';
|
|
15916
|
+
class TokenProviderFactory extends AbstractResourceFactory {
|
|
15917
|
+
static async createTokenProvider(config, options = {}) {
|
|
15918
|
+
if (config) {
|
|
15919
|
+
const provider = await createResource$1(TOKEN_PROVIDER_FACTORY_BASE_TYPE, config, options);
|
|
15920
|
+
if (!provider) {
|
|
15921
|
+
throw new Error('Failed to create token provider from configuration');
|
|
15922
|
+
}
|
|
15923
|
+
return provider;
|
|
15924
|
+
}
|
|
15925
|
+
let provider = null;
|
|
15926
|
+
try {
|
|
15927
|
+
provider = await createDefaultResource(TOKEN_PROVIDER_FACTORY_BASE_TYPE, null, options);
|
|
15928
|
+
}
|
|
15929
|
+
catch (error) {
|
|
15930
|
+
const message = 'Failed to create default token provider' +
|
|
15931
|
+
(error instanceof Error && error.message ? `: ${error.message}` : '');
|
|
15932
|
+
throw new Error(message);
|
|
15933
|
+
}
|
|
15934
|
+
if (!provider) {
|
|
15935
|
+
throw new Error('Failed to create default token provider');
|
|
15936
|
+
}
|
|
15937
|
+
return provider;
|
|
15938
|
+
}
|
|
15939
|
+
}
|
|
15940
|
+
|
|
15941
|
+
function isTokenProvider(candidate) {
|
|
15942
|
+
return (typeof candidate === 'object' &&
|
|
15943
|
+
candidate !== null &&
|
|
15944
|
+
typeof candidate.getToken === 'function');
|
|
15945
|
+
}
|
|
15946
|
+
function isIdentityExposingTokenProvider(candidate) {
|
|
15947
|
+
return (isTokenProvider(candidate) &&
|
|
15948
|
+
typeof candidate.getIdentity ===
|
|
15949
|
+
'function');
|
|
15950
|
+
}
|
|
15951
|
+
|
|
15981
15952
|
const logger$W = getLogger('naylence.fame.node.token_subject_node_identity_policy');
|
|
15982
15953
|
class TokenSubjectNodeIdentityPolicy {
|
|
15983
15954
|
async resolveInitialNodeId(context) {
|