Skip to content

Commit 75ff638

Browse files
committed
feat: emit disconnection reason
1 parent 25dab7b commit 75ff638

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

packages/core/src/lib/lit-core.ts

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -359,17 +359,16 @@ export class LitCore extends EventEmitter {
359359
message
360360
);
361361

362-
// Signal to any listeners that we've encountered a fatal error
363-
this.emit(
364-
'error',
365-
new Error(
366-
'Error while attempting to reconnect to nodes after epoch transition:' +
362+
const handshakeError = new Error(
363+
'Error while attempting to reconnect to nodes after epoch transition:' +
367364
message
368-
)
369365
);
370366

367+
// Signal to any listeners that we've encountered a fatal error
368+
this.emit('error', handshakeError);
369+
371370
// Signal to any listeners that we're 'disconnected' from LIT network
372-
this.emit('disconnected', true);
371+
this.emit('disconnected', { reason: 'error', error: handshakeError });
373372
}
374373
}
375374

@@ -414,7 +413,7 @@ export class LitCore extends EventEmitter {
414413
this._stopListeningForNewEpoch();
415414
// this._stopNetworkPolling();
416415
setMiscLitConfig(undefined);
417-
this.emit('disconnected', true);
416+
this.emit('disconnected', { reason: 'disconnect' });
418417
}
419418

420419
// _stopNetworkPolling() {

0 commit comments

Comments
 (0)