@naylence/runtime 0.3.5-test.931 → 0.3.5-test.934
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 +1896 -1767
- package/dist/browser/index.mjs +1896 -1767
- package/dist/cjs/naylence/fame/connector/base-async-connector.js +50 -0
- package/dist/cjs/naylence/fame/connector/broadcast-channel-connector.browser.js +65 -1
- package/dist/cjs/naylence/fame/node/upstream-session-manager.js +16 -1
- package/dist/cjs/naylence/fame/telemetry/trace-emitter-factory.js +4 -37
- package/dist/cjs/version.js +2 -2
- package/dist/esm/naylence/fame/connector/base-async-connector.js +50 -0
- package/dist/esm/naylence/fame/connector/broadcast-channel-connector.browser.js +65 -1
- package/dist/esm/naylence/fame/node/upstream-session-manager.js +16 -1
- package/dist/esm/naylence/fame/telemetry/trace-emitter-factory.js +4 -4
- package/dist/esm/version.js +2 -2
- package/dist/node/index.cjs +1955 -1826
- package/dist/node/index.mjs +1955 -1826
- package/dist/node/node.cjs +1620 -1491
- package/dist/node/node.mjs +1620 -1491
- package/dist/types/naylence/fame/connector/broadcast-channel-connector.browser.d.ts +2 -0
- package/dist/types/version.d.ts +1 -1
- package/package.json +1 -1
|
@@ -148,6 +148,10 @@ class BaseAsyncConnector extends task_spawner_js_1.TaskSpawner {
|
|
|
148
148
|
* Stop the connector gracefully
|
|
149
149
|
*/
|
|
150
150
|
async stop() {
|
|
151
|
+
logger.debug('stopping_connector', {
|
|
152
|
+
current_state: this._state,
|
|
153
|
+
connector_id: this._connectorFlowId,
|
|
154
|
+
});
|
|
151
155
|
if (!core_1.ConnectorStateUtils.canStop(this._state)) {
|
|
152
156
|
logger.debug('connector_stop_already_stopped', {
|
|
153
157
|
current_state: this._state,
|
|
@@ -160,6 +164,10 @@ class BaseAsyncConnector extends task_spawner_js_1.TaskSpawner {
|
|
|
160
164
|
if (this._lastError) {
|
|
161
165
|
throw this._lastError;
|
|
162
166
|
}
|
|
167
|
+
logger.debug('connector_stopped', {
|
|
168
|
+
current_state: this._state,
|
|
169
|
+
connector_id: this._connectorFlowId,
|
|
170
|
+
});
|
|
163
171
|
}
|
|
164
172
|
/**
|
|
165
173
|
* Close the connector with optional code and reason
|
|
@@ -490,8 +498,21 @@ class BaseAsyncConnector extends task_spawner_js_1.TaskSpawner {
|
|
|
490
498
|
*/
|
|
491
499
|
async _shutdown(code, reason, gracePeriod, exc) {
|
|
492
500
|
if (this._closed) {
|
|
501
|
+
logger.debug('shutdown_already_closed', {
|
|
502
|
+
connector_id: this._connectorFlowId,
|
|
503
|
+
current_state: this._state,
|
|
504
|
+
});
|
|
493
505
|
return;
|
|
494
506
|
}
|
|
507
|
+
logger.info('connector_shutdown_starting', {
|
|
508
|
+
connector_id: this._connectorFlowId,
|
|
509
|
+
connector_type: this.constructor.name,
|
|
510
|
+
code,
|
|
511
|
+
reason,
|
|
512
|
+
current_state: this._state,
|
|
513
|
+
has_error: !!exc,
|
|
514
|
+
timestamp: new Date().toISOString(),
|
|
515
|
+
});
|
|
495
516
|
this._closed = true;
|
|
496
517
|
this._closeCode = code;
|
|
497
518
|
this._closeReason = reason;
|
|
@@ -513,16 +534,39 @@ class BaseAsyncConnector extends task_spawner_js_1.TaskSpawner {
|
|
|
513
534
|
this._sendPromiseResolve = undefined;
|
|
514
535
|
}
|
|
515
536
|
// Close transport
|
|
537
|
+
logger.info('connector_closing_transport', {
|
|
538
|
+
connector_id: this._connectorFlowId,
|
|
539
|
+
connector_type: this.constructor.name,
|
|
540
|
+
timestamp: new Date().toISOString(),
|
|
541
|
+
});
|
|
516
542
|
await this._transportClose(code, reason);
|
|
543
|
+
logger.info('connector_transport_closed', {
|
|
544
|
+
connector_id: this._connectorFlowId,
|
|
545
|
+
connector_type: this.constructor.name,
|
|
546
|
+
timestamp: new Date().toISOString(),
|
|
547
|
+
});
|
|
517
548
|
// Shutdown spawned tasks
|
|
549
|
+
logger.info('connector_shutting_down_tasks', {
|
|
550
|
+
connector_id: this._connectorFlowId,
|
|
551
|
+
connector_type: this.constructor.name,
|
|
552
|
+
grace_period_ms: effectiveGracePeriod * 1000,
|
|
553
|
+
join_timeout_ms: this._shutdownJoinTimeout,
|
|
554
|
+
timestamp: new Date().toISOString(),
|
|
555
|
+
});
|
|
518
556
|
try {
|
|
519
557
|
await this.shutdownTasks({
|
|
520
558
|
gracePeriod: effectiveGracePeriod * 1000, // Convert to milliseconds
|
|
521
559
|
joinTimeout: this._shutdownJoinTimeout,
|
|
522
560
|
});
|
|
561
|
+
logger.info('connector_tasks_shutdown_complete', {
|
|
562
|
+
connector_id: this._connectorFlowId,
|
|
563
|
+
connector_type: this.constructor.name,
|
|
564
|
+
timestamp: new Date().toISOString(),
|
|
565
|
+
});
|
|
523
566
|
}
|
|
524
567
|
catch (error) {
|
|
525
568
|
logger.warning('task_shutdown_error', {
|
|
569
|
+
connector_id: this._connectorFlowId,
|
|
526
570
|
error: error instanceof Error ? error.message : String(error),
|
|
527
571
|
});
|
|
528
572
|
}
|
|
@@ -534,6 +578,12 @@ class BaseAsyncConnector extends task_spawner_js_1.TaskSpawner {
|
|
|
534
578
|
if (this._closeResolver) {
|
|
535
579
|
this._closeResolver();
|
|
536
580
|
}
|
|
581
|
+
logger.info('connector_shutdown_complete', {
|
|
582
|
+
connector_id: this._connectorFlowId,
|
|
583
|
+
connector_type: this.constructor.name,
|
|
584
|
+
final_state: this._state,
|
|
585
|
+
timestamp: new Date().toISOString(),
|
|
586
|
+
});
|
|
537
587
|
}
|
|
538
588
|
/**
|
|
539
589
|
* Close the underlying transport
|
|
@@ -57,6 +57,7 @@ class BroadcastChannelConnector extends base_async_connector_js_1.BaseAsyncConne
|
|
|
57
57
|
this.ackDedupTtlMs = 30000;
|
|
58
58
|
this.ackDedupMaxEntries = 4096;
|
|
59
59
|
this.textDecoder = new TextDecoder();
|
|
60
|
+
this.visibilityChangeListenerRegistered = false;
|
|
60
61
|
this.channelName =
|
|
61
62
|
typeof config.channelName === 'string' && config.channelName.trim().length > 0
|
|
62
63
|
? config.channelName.trim()
|
|
@@ -69,12 +70,22 @@ class BroadcastChannelConnector extends base_async_connector_js_1.BaseAsyncConne
|
|
|
69
70
|
this.inbox = new bounded_async_queue_js_1.BoundedAsyncQueue(preferredCapacity);
|
|
70
71
|
this.connectorId = BroadcastChannelConnector.generateConnectorId();
|
|
71
72
|
this.channel = new BroadcastChannel(this.channelName);
|
|
72
|
-
logger.
|
|
73
|
+
logger.info('broadcast_channel_connector_created', {
|
|
73
74
|
channel: this.channelName,
|
|
74
75
|
connector_id: this.connectorId,
|
|
75
76
|
inbox_capacity: preferredCapacity,
|
|
77
|
+
timestamp: new Date().toISOString(),
|
|
76
78
|
});
|
|
77
79
|
this.onMsg = (event) => {
|
|
80
|
+
// Guard: Don't process if listener was unregistered
|
|
81
|
+
if (!this.listenerRegistered) {
|
|
82
|
+
logger.warning('broadcast_channel_message_after_unregister', {
|
|
83
|
+
channel: this.channelName,
|
|
84
|
+
connector_id: this.connectorId,
|
|
85
|
+
timestamp: new Date().toISOString(),
|
|
86
|
+
});
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
78
89
|
const message = event.data;
|
|
79
90
|
logger.debug('broadcast_channel_raw_event', {
|
|
80
91
|
channel: this.channelName,
|
|
@@ -137,6 +148,26 @@ class BroadcastChannelConnector extends base_async_connector_js_1.BaseAsyncConne
|
|
|
137
148
|
};
|
|
138
149
|
this.channel.addEventListener('message', this.onMsg);
|
|
139
150
|
this.listenerRegistered = true;
|
|
151
|
+
// Setup visibility change monitoring
|
|
152
|
+
this.visibilityChangeHandler = () => {
|
|
153
|
+
const isHidden = document.hidden;
|
|
154
|
+
logger.info('broadcast_channel_visibility_changed', {
|
|
155
|
+
channel: this.channelName,
|
|
156
|
+
connector_id: this.connectorId,
|
|
157
|
+
visibility: isHidden ? 'hidden' : 'visible',
|
|
158
|
+
timestamp: new Date().toISOString(),
|
|
159
|
+
});
|
|
160
|
+
};
|
|
161
|
+
if (typeof document !== 'undefined') {
|
|
162
|
+
document.addEventListener('visibilitychange', this.visibilityChangeHandler);
|
|
163
|
+
this.visibilityChangeListenerRegistered = true;
|
|
164
|
+
// Log initial state
|
|
165
|
+
logger.info('broadcast_channel_initial_visibility', {
|
|
166
|
+
channel: this.channelName,
|
|
167
|
+
connector_id: this.connectorId,
|
|
168
|
+
visibility: document.hidden ? 'hidden' : 'visible',
|
|
169
|
+
});
|
|
170
|
+
}
|
|
140
171
|
}
|
|
141
172
|
async pushToReceive(rawOrEnvelope) {
|
|
142
173
|
const item = this._normalizeInboxItem(rawOrEnvelope);
|
|
@@ -181,11 +212,44 @@ class BroadcastChannelConnector extends base_async_connector_js_1.BaseAsyncConne
|
|
|
181
212
|
return await this.inbox.dequeue();
|
|
182
213
|
}
|
|
183
214
|
async _transportClose(code, reason) {
|
|
215
|
+
logger.info('broadcast_channel_transport_closing', {
|
|
216
|
+
channel: this.channelName,
|
|
217
|
+
connector_id: this.connectorId,
|
|
218
|
+
code,
|
|
219
|
+
reason,
|
|
220
|
+
listener_registered: this.listenerRegistered,
|
|
221
|
+
timestamp: new Date().toISOString(),
|
|
222
|
+
});
|
|
184
223
|
if (this.listenerRegistered) {
|
|
224
|
+
logger.info('broadcast_channel_removing_listener', {
|
|
225
|
+
channel: this.channelName,
|
|
226
|
+
connector_id: this.connectorId,
|
|
227
|
+
timestamp: new Date().toISOString(),
|
|
228
|
+
});
|
|
185
229
|
this.channel.removeEventListener('message', this.onMsg);
|
|
186
230
|
this.listenerRegistered = false;
|
|
231
|
+
logger.info('broadcast_channel_listener_removed', {
|
|
232
|
+
channel: this.channelName,
|
|
233
|
+
connector_id: this.connectorId,
|
|
234
|
+
timestamp: new Date().toISOString(),
|
|
235
|
+
});
|
|
187
236
|
}
|
|
237
|
+
if (this.visibilityChangeListenerRegistered && this.visibilityChangeHandler && typeof document !== 'undefined') {
|
|
238
|
+
document.removeEventListener('visibilitychange', this.visibilityChangeHandler);
|
|
239
|
+
this.visibilityChangeListenerRegistered = false;
|
|
240
|
+
this.visibilityChangeHandler = undefined;
|
|
241
|
+
}
|
|
242
|
+
logger.info('broadcast_channel_closing', {
|
|
243
|
+
channel: this.channelName,
|
|
244
|
+
connector_id: this.connectorId,
|
|
245
|
+
timestamp: new Date().toISOString(),
|
|
246
|
+
});
|
|
188
247
|
this.channel.close();
|
|
248
|
+
logger.info('broadcast_channel_closed', {
|
|
249
|
+
channel: this.channelName,
|
|
250
|
+
connector_id: this.connectorId,
|
|
251
|
+
timestamp: new Date().toISOString(),
|
|
252
|
+
});
|
|
189
253
|
const closeCode = typeof code === 'number' ? code : 1000;
|
|
190
254
|
const closeReason = typeof reason === 'string' && reason.length > 0 ? reason : 'closed';
|
|
191
255
|
const shutdownError = new errors_js_1.FameTransportClose(closeReason, closeCode);
|
|
@@ -387,7 +387,22 @@ class UpstreamSessionManager extends task_spawner_js_1.TaskSpawner {
|
|
|
387
387
|
this.currentStopSubtasks = null;
|
|
388
388
|
await Promise.allSettled(tasks.map((task) => task.promise));
|
|
389
389
|
if (this.connector) {
|
|
390
|
-
|
|
390
|
+
logger.info('upstream_stopping_old_connector', {
|
|
391
|
+
connect_epoch: this.connectEpoch,
|
|
392
|
+
target_system_id: this.targetSystemId,
|
|
393
|
+
timestamp: new Date().toISOString(),
|
|
394
|
+
});
|
|
395
|
+
await this.connector.stop().catch((err) => {
|
|
396
|
+
logger.warning('upstream_connector_stop_error', {
|
|
397
|
+
connect_epoch: this.connectEpoch,
|
|
398
|
+
error: err instanceof Error ? err.message : String(err),
|
|
399
|
+
});
|
|
400
|
+
});
|
|
401
|
+
logger.info('upstream_old_connector_stopped', {
|
|
402
|
+
connect_epoch: this.connectEpoch,
|
|
403
|
+
target_system_id: this.targetSystemId,
|
|
404
|
+
timestamp: new Date().toISOString(),
|
|
405
|
+
});
|
|
391
406
|
this.connector = null;
|
|
392
407
|
}
|
|
393
408
|
}
|
|
@@ -1,37 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
-
var ownKeys = function(o) {
|
|
20
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
-
var ar = [];
|
|
22
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
-
return ar;
|
|
24
|
-
};
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
35
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
3
|
exports.TraceEmitterFactory = exports.TRACE_EMITTER_FACTORY_BASE_TYPE = void 0;
|
|
37
4
|
const factory_1 = require("@naylence/factory");
|
|
@@ -48,7 +15,7 @@ class TraceEmitterFactory extends factory_1.AbstractResourceFactory {
|
|
|
48
15
|
}
|
|
49
16
|
}
|
|
50
17
|
exports.TraceEmitterFactory = TraceEmitterFactory;
|
|
51
|
-
// Ensure default factories are registered lazily to avoid circular ESM initialization issues
|
|
52
|
-
void
|
|
53
|
-
void
|
|
54
|
-
void
|
|
18
|
+
// // Ensure default factories are registered lazily to avoid circular ESM initialization issues
|
|
19
|
+
// void import('./noop-trace-emitter-factory.js');
|
|
20
|
+
// void import('./open-telemetry-trace-emitter-factory.js');
|
|
21
|
+
// void import('./trace-emitter-profile-factory.js');
|
package/dist/cjs/version.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
// This file is auto-generated during build - do not edit manually
|
|
3
|
-
// Generated from package.json version: 0.3.5-test.
|
|
3
|
+
// Generated from package.json version: 0.3.5-test.934
|
|
4
4
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
5
|
exports.VERSION = void 0;
|
|
6
6
|
/**
|
|
7
7
|
* The package version, injected at build time.
|
|
8
8
|
* @internal
|
|
9
9
|
*/
|
|
10
|
-
exports.VERSION = '0.3.5-test.
|
|
10
|
+
exports.VERSION = '0.3.5-test.934';
|
|
@@ -144,6 +144,10 @@ export class BaseAsyncConnector extends TaskSpawner {
|
|
|
144
144
|
* Stop the connector gracefully
|
|
145
145
|
*/
|
|
146
146
|
async stop() {
|
|
147
|
+
logger.debug('stopping_connector', {
|
|
148
|
+
current_state: this._state,
|
|
149
|
+
connector_id: this._connectorFlowId,
|
|
150
|
+
});
|
|
147
151
|
if (!ConnectorStateUtils.canStop(this._state)) {
|
|
148
152
|
logger.debug('connector_stop_already_stopped', {
|
|
149
153
|
current_state: this._state,
|
|
@@ -156,6 +160,10 @@ export class BaseAsyncConnector extends TaskSpawner {
|
|
|
156
160
|
if (this._lastError) {
|
|
157
161
|
throw this._lastError;
|
|
158
162
|
}
|
|
163
|
+
logger.debug('connector_stopped', {
|
|
164
|
+
current_state: this._state,
|
|
165
|
+
connector_id: this._connectorFlowId,
|
|
166
|
+
});
|
|
159
167
|
}
|
|
160
168
|
/**
|
|
161
169
|
* Close the connector with optional code and reason
|
|
@@ -486,8 +494,21 @@ export class BaseAsyncConnector extends TaskSpawner {
|
|
|
486
494
|
*/
|
|
487
495
|
async _shutdown(code, reason, gracePeriod, exc) {
|
|
488
496
|
if (this._closed) {
|
|
497
|
+
logger.debug('shutdown_already_closed', {
|
|
498
|
+
connector_id: this._connectorFlowId,
|
|
499
|
+
current_state: this._state,
|
|
500
|
+
});
|
|
489
501
|
return;
|
|
490
502
|
}
|
|
503
|
+
logger.info('connector_shutdown_starting', {
|
|
504
|
+
connector_id: this._connectorFlowId,
|
|
505
|
+
connector_type: this.constructor.name,
|
|
506
|
+
code,
|
|
507
|
+
reason,
|
|
508
|
+
current_state: this._state,
|
|
509
|
+
has_error: !!exc,
|
|
510
|
+
timestamp: new Date().toISOString(),
|
|
511
|
+
});
|
|
491
512
|
this._closed = true;
|
|
492
513
|
this._closeCode = code;
|
|
493
514
|
this._closeReason = reason;
|
|
@@ -509,16 +530,39 @@ export class BaseAsyncConnector extends TaskSpawner {
|
|
|
509
530
|
this._sendPromiseResolve = undefined;
|
|
510
531
|
}
|
|
511
532
|
// Close transport
|
|
533
|
+
logger.info('connector_closing_transport', {
|
|
534
|
+
connector_id: this._connectorFlowId,
|
|
535
|
+
connector_type: this.constructor.name,
|
|
536
|
+
timestamp: new Date().toISOString(),
|
|
537
|
+
});
|
|
512
538
|
await this._transportClose(code, reason);
|
|
539
|
+
logger.info('connector_transport_closed', {
|
|
540
|
+
connector_id: this._connectorFlowId,
|
|
541
|
+
connector_type: this.constructor.name,
|
|
542
|
+
timestamp: new Date().toISOString(),
|
|
543
|
+
});
|
|
513
544
|
// Shutdown spawned tasks
|
|
545
|
+
logger.info('connector_shutting_down_tasks', {
|
|
546
|
+
connector_id: this._connectorFlowId,
|
|
547
|
+
connector_type: this.constructor.name,
|
|
548
|
+
grace_period_ms: effectiveGracePeriod * 1000,
|
|
549
|
+
join_timeout_ms: this._shutdownJoinTimeout,
|
|
550
|
+
timestamp: new Date().toISOString(),
|
|
551
|
+
});
|
|
514
552
|
try {
|
|
515
553
|
await this.shutdownTasks({
|
|
516
554
|
gracePeriod: effectiveGracePeriod * 1000, // Convert to milliseconds
|
|
517
555
|
joinTimeout: this._shutdownJoinTimeout,
|
|
518
556
|
});
|
|
557
|
+
logger.info('connector_tasks_shutdown_complete', {
|
|
558
|
+
connector_id: this._connectorFlowId,
|
|
559
|
+
connector_type: this.constructor.name,
|
|
560
|
+
timestamp: new Date().toISOString(),
|
|
561
|
+
});
|
|
519
562
|
}
|
|
520
563
|
catch (error) {
|
|
521
564
|
logger.warning('task_shutdown_error', {
|
|
565
|
+
connector_id: this._connectorFlowId,
|
|
522
566
|
error: error instanceof Error ? error.message : String(error),
|
|
523
567
|
});
|
|
524
568
|
}
|
|
@@ -530,6 +574,12 @@ export class BaseAsyncConnector extends TaskSpawner {
|
|
|
530
574
|
if (this._closeResolver) {
|
|
531
575
|
this._closeResolver();
|
|
532
576
|
}
|
|
577
|
+
logger.info('connector_shutdown_complete', {
|
|
578
|
+
connector_id: this._connectorFlowId,
|
|
579
|
+
connector_type: this.constructor.name,
|
|
580
|
+
final_state: this._state,
|
|
581
|
+
timestamp: new Date().toISOString(),
|
|
582
|
+
});
|
|
533
583
|
}
|
|
534
584
|
/**
|
|
535
585
|
* Close the underlying transport
|
|
@@ -54,6 +54,7 @@ export class BroadcastChannelConnector extends BaseAsyncConnector {
|
|
|
54
54
|
this.ackDedupTtlMs = 30000;
|
|
55
55
|
this.ackDedupMaxEntries = 4096;
|
|
56
56
|
this.textDecoder = new TextDecoder();
|
|
57
|
+
this.visibilityChangeListenerRegistered = false;
|
|
57
58
|
this.channelName =
|
|
58
59
|
typeof config.channelName === 'string' && config.channelName.trim().length > 0
|
|
59
60
|
? config.channelName.trim()
|
|
@@ -66,12 +67,22 @@ export class BroadcastChannelConnector extends BaseAsyncConnector {
|
|
|
66
67
|
this.inbox = new BoundedAsyncQueue(preferredCapacity);
|
|
67
68
|
this.connectorId = BroadcastChannelConnector.generateConnectorId();
|
|
68
69
|
this.channel = new BroadcastChannel(this.channelName);
|
|
69
|
-
logger.
|
|
70
|
+
logger.info('broadcast_channel_connector_created', {
|
|
70
71
|
channel: this.channelName,
|
|
71
72
|
connector_id: this.connectorId,
|
|
72
73
|
inbox_capacity: preferredCapacity,
|
|
74
|
+
timestamp: new Date().toISOString(),
|
|
73
75
|
});
|
|
74
76
|
this.onMsg = (event) => {
|
|
77
|
+
// Guard: Don't process if listener was unregistered
|
|
78
|
+
if (!this.listenerRegistered) {
|
|
79
|
+
logger.warning('broadcast_channel_message_after_unregister', {
|
|
80
|
+
channel: this.channelName,
|
|
81
|
+
connector_id: this.connectorId,
|
|
82
|
+
timestamp: new Date().toISOString(),
|
|
83
|
+
});
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
75
86
|
const message = event.data;
|
|
76
87
|
logger.debug('broadcast_channel_raw_event', {
|
|
77
88
|
channel: this.channelName,
|
|
@@ -134,6 +145,26 @@ export class BroadcastChannelConnector extends BaseAsyncConnector {
|
|
|
134
145
|
};
|
|
135
146
|
this.channel.addEventListener('message', this.onMsg);
|
|
136
147
|
this.listenerRegistered = true;
|
|
148
|
+
// Setup visibility change monitoring
|
|
149
|
+
this.visibilityChangeHandler = () => {
|
|
150
|
+
const isHidden = document.hidden;
|
|
151
|
+
logger.info('broadcast_channel_visibility_changed', {
|
|
152
|
+
channel: this.channelName,
|
|
153
|
+
connector_id: this.connectorId,
|
|
154
|
+
visibility: isHidden ? 'hidden' : 'visible',
|
|
155
|
+
timestamp: new Date().toISOString(),
|
|
156
|
+
});
|
|
157
|
+
};
|
|
158
|
+
if (typeof document !== 'undefined') {
|
|
159
|
+
document.addEventListener('visibilitychange', this.visibilityChangeHandler);
|
|
160
|
+
this.visibilityChangeListenerRegistered = true;
|
|
161
|
+
// Log initial state
|
|
162
|
+
logger.info('broadcast_channel_initial_visibility', {
|
|
163
|
+
channel: this.channelName,
|
|
164
|
+
connector_id: this.connectorId,
|
|
165
|
+
visibility: document.hidden ? 'hidden' : 'visible',
|
|
166
|
+
});
|
|
167
|
+
}
|
|
137
168
|
}
|
|
138
169
|
async pushToReceive(rawOrEnvelope) {
|
|
139
170
|
const item = this._normalizeInboxItem(rawOrEnvelope);
|
|
@@ -178,11 +209,44 @@ export class BroadcastChannelConnector extends BaseAsyncConnector {
|
|
|
178
209
|
return await this.inbox.dequeue();
|
|
179
210
|
}
|
|
180
211
|
async _transportClose(code, reason) {
|
|
212
|
+
logger.info('broadcast_channel_transport_closing', {
|
|
213
|
+
channel: this.channelName,
|
|
214
|
+
connector_id: this.connectorId,
|
|
215
|
+
code,
|
|
216
|
+
reason,
|
|
217
|
+
listener_registered: this.listenerRegistered,
|
|
218
|
+
timestamp: new Date().toISOString(),
|
|
219
|
+
});
|
|
181
220
|
if (this.listenerRegistered) {
|
|
221
|
+
logger.info('broadcast_channel_removing_listener', {
|
|
222
|
+
channel: this.channelName,
|
|
223
|
+
connector_id: this.connectorId,
|
|
224
|
+
timestamp: new Date().toISOString(),
|
|
225
|
+
});
|
|
182
226
|
this.channel.removeEventListener('message', this.onMsg);
|
|
183
227
|
this.listenerRegistered = false;
|
|
228
|
+
logger.info('broadcast_channel_listener_removed', {
|
|
229
|
+
channel: this.channelName,
|
|
230
|
+
connector_id: this.connectorId,
|
|
231
|
+
timestamp: new Date().toISOString(),
|
|
232
|
+
});
|
|
184
233
|
}
|
|
234
|
+
if (this.visibilityChangeListenerRegistered && this.visibilityChangeHandler && typeof document !== 'undefined') {
|
|
235
|
+
document.removeEventListener('visibilitychange', this.visibilityChangeHandler);
|
|
236
|
+
this.visibilityChangeListenerRegistered = false;
|
|
237
|
+
this.visibilityChangeHandler = undefined;
|
|
238
|
+
}
|
|
239
|
+
logger.info('broadcast_channel_closing', {
|
|
240
|
+
channel: this.channelName,
|
|
241
|
+
connector_id: this.connectorId,
|
|
242
|
+
timestamp: new Date().toISOString(),
|
|
243
|
+
});
|
|
185
244
|
this.channel.close();
|
|
245
|
+
logger.info('broadcast_channel_closed', {
|
|
246
|
+
channel: this.channelName,
|
|
247
|
+
connector_id: this.connectorId,
|
|
248
|
+
timestamp: new Date().toISOString(),
|
|
249
|
+
});
|
|
186
250
|
const closeCode = typeof code === 'number' ? code : 1000;
|
|
187
251
|
const closeReason = typeof reason === 'string' && reason.length > 0 ? reason : 'closed';
|
|
188
252
|
const shutdownError = new FameTransportClose(closeReason, closeCode);
|
|
@@ -384,7 +384,22 @@ export class UpstreamSessionManager extends TaskSpawner {
|
|
|
384
384
|
this.currentStopSubtasks = null;
|
|
385
385
|
await Promise.allSettled(tasks.map((task) => task.promise));
|
|
386
386
|
if (this.connector) {
|
|
387
|
-
|
|
387
|
+
logger.info('upstream_stopping_old_connector', {
|
|
388
|
+
connect_epoch: this.connectEpoch,
|
|
389
|
+
target_system_id: this.targetSystemId,
|
|
390
|
+
timestamp: new Date().toISOString(),
|
|
391
|
+
});
|
|
392
|
+
await this.connector.stop().catch((err) => {
|
|
393
|
+
logger.warning('upstream_connector_stop_error', {
|
|
394
|
+
connect_epoch: this.connectEpoch,
|
|
395
|
+
error: err instanceof Error ? err.message : String(err),
|
|
396
|
+
});
|
|
397
|
+
});
|
|
398
|
+
logger.info('upstream_old_connector_stopped', {
|
|
399
|
+
connect_epoch: this.connectEpoch,
|
|
400
|
+
target_system_id: this.targetSystemId,
|
|
401
|
+
timestamp: new Date().toISOString(),
|
|
402
|
+
});
|
|
388
403
|
this.connector = null;
|
|
389
404
|
}
|
|
390
405
|
}
|
|
@@ -11,7 +11,7 @@ export class TraceEmitterFactory extends AbstractResourceFactory {
|
|
|
11
11
|
return traceEmitter;
|
|
12
12
|
}
|
|
13
13
|
}
|
|
14
|
-
// Ensure default factories are registered lazily to avoid circular ESM initialization issues
|
|
15
|
-
void import('./noop-trace-emitter-factory.js');
|
|
16
|
-
void import('./open-telemetry-trace-emitter-factory.js');
|
|
17
|
-
void import('./trace-emitter-profile-factory.js');
|
|
14
|
+
// // Ensure default factories are registered lazily to avoid circular ESM initialization issues
|
|
15
|
+
// void import('./noop-trace-emitter-factory.js');
|
|
16
|
+
// void import('./open-telemetry-trace-emitter-factory.js');
|
|
17
|
+
// void import('./trace-emitter-profile-factory.js');
|
package/dist/esm/version.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// This file is auto-generated during build - do not edit manually
|
|
2
|
-
// Generated from package.json version: 0.3.5-test.
|
|
2
|
+
// Generated from package.json version: 0.3.5-test.934
|
|
3
3
|
/**
|
|
4
4
|
* The package version, injected at build time.
|
|
5
5
|
* @internal
|
|
6
6
|
*/
|
|
7
|
-
export const VERSION = '0.3.5-test.
|
|
7
|
+
export const VERSION = '0.3.5-test.934';
|