fix(core): Improve heartbeat handling and transport routing; forward heartbeat timeout events; include clientId routing and probe improvements
This commit is contained in:
@@ -75,7 +75,10 @@ export class IpcClient extends plugins.EventEmitter {
|
||||
clientId: this.clientId,
|
||||
metadata: this.options.metadata
|
||||
},
|
||||
{ timeout: registerTimeoutMs }
|
||||
{
|
||||
timeout: registerTimeoutMs,
|
||||
headers: { clientId: this.clientId } // Include clientId in headers for proper routing
|
||||
}
|
||||
);
|
||||
|
||||
if (!response.success) {
|
||||
@@ -194,10 +197,20 @@ export class IpcClient extends plugins.EventEmitter {
|
||||
this.emit('disconnect', reason);
|
||||
});
|
||||
|
||||
this.channel.on('error', (error) => {
|
||||
this.channel.on('error', (error: any) => {
|
||||
// If heartbeat timeout and configured not to throw, convert to heartbeatTimeout event
|
||||
if (error && error.message === 'Heartbeat timeout' && this.options.heartbeatThrowOnTimeout === false) {
|
||||
this.emit('heartbeatTimeout', error);
|
||||
return;
|
||||
}
|
||||
this.emit('error', error);
|
||||
});
|
||||
|
||||
this.channel.on('heartbeatTimeout', (error) => {
|
||||
// Forward heartbeatTimeout event (when heartbeatThrowOnTimeout is false)
|
||||
this.emit('heartbeatTimeout', error);
|
||||
});
|
||||
|
||||
this.channel.on('reconnecting', (info) => {
|
||||
this.emit('reconnecting', info);
|
||||
});
|
||||
|
Reference in New Issue
Block a user