fix(core): Improve heartbeat handling and transport routing; forward heartbeat timeout events; include clientId routing and probe improvements
This commit is contained in:
21
ts/index.ts
21
ts/index.ts
@@ -29,20 +29,27 @@ export class SmartIpc {
|
||||
|
||||
while (Date.now() - startTime < timeout) {
|
||||
try {
|
||||
// Try to connect as a temporary client
|
||||
const testClient = new IpcClient({
|
||||
id: `test-probe-${Date.now()}`,
|
||||
// Create a temporary client with proper options
|
||||
const testClient = SmartIpc.createClient({
|
||||
id: 'test-probe',
|
||||
socketPath: options.socketPath,
|
||||
autoReconnect: false,
|
||||
heartbeat: false
|
||||
clientId: `probe-${process.pid}-${Date.now()}`,
|
||||
heartbeat: false,
|
||||
connectRetry: {
|
||||
enabled: false // Don't retry, we're handling retries here
|
||||
},
|
||||
registerTimeoutMs: 2000 // Short timeout for quick probing
|
||||
});
|
||||
|
||||
// Try to connect and register with the server
|
||||
await testClient.connect();
|
||||
|
||||
// Success! Clean up and return
|
||||
await testClient.disconnect();
|
||||
return; // Server is ready
|
||||
return;
|
||||
} catch (error) {
|
||||
// Server not ready yet, wait and retry
|
||||
await new Promise(resolve => setTimeout(resolve, 100));
|
||||
await new Promise(resolve => setTimeout(resolve, 200));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user