fix(classes.ipcchannel): Normalize heartbeatThrowOnTimeout option parsing and allow registering heartbeatTimeout via IpcChannel.on
This commit is contained in:
@@ -1,5 +1,11 @@
|
|||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
|
## 2025-08-28 - 2.1.3 - fix(classes.ipcchannel)
|
||||||
|
Normalize heartbeatThrowOnTimeout option parsing and allow registering 'heartbeatTimeout' via IpcChannel.on
|
||||||
|
|
||||||
|
- Normalize heartbeatThrowOnTimeout to boolean (accepts 'true'/'false' strings and other truthy/falsey values) to be defensive for JS consumers
|
||||||
|
- Expose 'heartbeatTimeout' as a special channel event so handlers registered via IpcChannel.on('heartbeatTimeout', ...) will be called
|
||||||
|
|
||||||
## 2025-08-26 - 2.1.2 - fix(core)
|
## 2025-08-26 - 2.1.2 - fix(core)
|
||||||
Improve heartbeat handling and transport routing; forward heartbeat timeout events; include clientId routing and probe improvements
|
Improve heartbeat handling and transport routing; forward heartbeat timeout events; include clientId routing and probe improvements
|
||||||
|
|
||||||
|
@@ -3,6 +3,6 @@
|
|||||||
*/
|
*/
|
||||||
export const commitinfo = {
|
export const commitinfo = {
|
||||||
name: '@push.rocks/smartipc',
|
name: '@push.rocks/smartipc',
|
||||||
version: '2.1.2',
|
version: '2.1.3',
|
||||||
description: 'A library for node inter process communication, providing an easy-to-use API for IPC.'
|
description: 'A library for node inter process communication, providing an easy-to-use API for IPC.'
|
||||||
}
|
}
|
||||||
|
@@ -82,6 +82,18 @@ export class IpcChannel<TRequest = any, TResponse = any> extends plugins.EventEm
|
|||||||
...options
|
...options
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Normalize heartbeatThrowOnTimeout to boolean (defensive for JS consumers)
|
||||||
|
const throwOnTimeout = (this.options as any).heartbeatThrowOnTimeout;
|
||||||
|
if (throwOnTimeout !== undefined) {
|
||||||
|
if (throwOnTimeout === 'false') {
|
||||||
|
this.options.heartbeatThrowOnTimeout = false;
|
||||||
|
} else if (throwOnTimeout === 'true') {
|
||||||
|
this.options.heartbeatThrowOnTimeout = true;
|
||||||
|
} else if (typeof throwOnTimeout !== 'boolean') {
|
||||||
|
this.options.heartbeatThrowOnTimeout = Boolean(throwOnTimeout);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
this.transport = createTransport(this.options);
|
this.transport = createTransport(this.options);
|
||||||
this.setupTransportHandlers();
|
this.setupTransportHandlers();
|
||||||
}
|
}
|
||||||
@@ -449,7 +461,7 @@ export class IpcChannel<TRequest = any, TResponse = any> extends plugins.EventEm
|
|||||||
* Register a message handler
|
* Register a message handler
|
||||||
*/
|
*/
|
||||||
public on(event: string, handler: (payload: any) => any | Promise<any>): this {
|
public on(event: string, handler: (payload: any) => any | Promise<any>): this {
|
||||||
if (event === 'message' || event === 'connect' || event === 'disconnect' || event === 'error' || event === 'reconnecting' || event === 'drain') {
|
if (event === 'message' || event === 'connect' || event === 'disconnect' || event === 'error' || event === 'reconnecting' || event === 'drain' || event === 'heartbeatTimeout') {
|
||||||
// Special handling for channel events
|
// Special handling for channel events
|
||||||
super.on(event, handler);
|
super.on(event, handler);
|
||||||
} else {
|
} else {
|
||||||
|
Reference in New Issue
Block a user