epicenter-libs 3.35.0 → 3.35.1

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "epicenter-libs",
3
- "version": "3.35.0",
3
+ "version": "3.35.1",
4
4
  "main": "dist/cjs/epicenter.js",
5
5
  "type": "module",
6
6
  "module": "dist/module/epicenter.js",
@@ -112,7 +112,8 @@ export function setLocalSession(session: Session): Session {
112
112
  */
113
113
  export async function removeLocalSession(): Promise<void> {
114
114
  identification.session = undefined;
115
- await cometdAdapter.disconnect();
115
+ // CometD disconnect is best-effort cleanup; its failure must not fail session removal
116
+ await cometdAdapter.disconnect().catch(() => undefined);
116
117
  }
117
118
 
118
119
 
@@ -20,6 +20,7 @@ const CONNECT_META_CHANNEL = '/meta/connect';
20
20
  const DISCONNECT_META_CHANNEL = '/meta/disconnect';
21
21
  const HANDSHAKE_META_CHANNEL = '/meta/handshake';
22
22
  const COMETD_RECONNECTED = 'COMETD_RECONNECTED';
23
+ const CHANNELS_NOT_ENABLED = 'CHANNELS_NOT_ENABLED';
23
24
  const DEFAULT_CHANNEL_PROTOCOL = 'cometd';
24
25
 
25
26
  type HandshakeState = 'idle' | 'handshaking' | 'succeeded' | 'failed';
@@ -85,7 +86,7 @@ class CometdAdapter {
85
86
 
86
87
  async startup(options: { logLevel: 'info' | 'debug' | 'warn' } = { logLevel: 'warn' }) {
87
88
  const project = await getProject();
88
- if (!project.channelEnabled) throw new EpicenterError('Push Channels are not enabled on this project');
89
+ if (!project.channelEnabled) throw new EpicenterError('Push Channels are not enabled on this project', CHANNELS_NOT_ENABLED);
89
90
  const channelProtocol = project.channelProtocol?.toLowerCase() || DEFAULT_CHANNEL_PROTOCOL;
90
91
  const { CometD } = await import('cometd');
91
92
  const { AckExtension } = await import('cometd');
@@ -196,7 +197,11 @@ class CometdAdapter {
196
197
 
197
198
  async init(options?: { logLevel: 'info' | 'debug' | 'warn' }) {
198
199
  if (!this.initialization) {
199
- this.initialization = this.startup(options);
200
+ // A rejected startup must not be cached, or every later init() call re-throws it
201
+ this.initialization = this.startup(options).catch((error) => {
202
+ this.initialization = undefined;
203
+ throw error;
204
+ });
200
205
  }
201
206
  return this.initialization;
202
207
  }