@raevon/n8n-nodes-whatsapp 2.0.9 → 2.0.10
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.
|
@@ -345,20 +345,20 @@ async function startServer(cfg) {
|
|
|
345
345
|
}
|
|
346
346
|
async function ensureServerRunning(cfg) {
|
|
347
347
|
const port = getPort(cfg);
|
|
348
|
-
//
|
|
349
|
-
if (await isPortOpen(port)) {
|
|
350
|
-
await startServer(cfg);
|
|
351
|
-
return;
|
|
352
|
-
}
|
|
353
|
-
// Port is in use — check if server responds
|
|
348
|
+
// Try to connect to existing server first
|
|
354
349
|
try {
|
|
355
|
-
const res = await fetch(`http://127.0.0.1:${port}/health`, { signal: AbortSignal.timeout(
|
|
350
|
+
const res = await fetch(`http://127.0.0.1:${port}/health`, { signal: AbortSignal.timeout(5000) });
|
|
356
351
|
if (res.ok)
|
|
357
|
-
return; // Server alive
|
|
352
|
+
return; // Server alive
|
|
358
353
|
}
|
|
359
354
|
catch { }
|
|
360
|
-
//
|
|
361
|
-
|
|
355
|
+
// Server not running — start it
|
|
356
|
+
if (await isPortOpen(port)) {
|
|
357
|
+
await startServer(cfg);
|
|
358
|
+
return;
|
|
359
|
+
}
|
|
360
|
+
// Port occupied by something else
|
|
361
|
+
throw new Error(`Port ${port} occupied by another process. Restart n8n container to clear.`);
|
|
362
362
|
}
|
|
363
363
|
async function stopServer(cfg) {
|
|
364
364
|
const port = getPort(cfg);
|
|
@@ -79,13 +79,14 @@ class WhatsAppConnect {
|
|
|
79
79
|
continue;
|
|
80
80
|
}
|
|
81
81
|
try {
|
|
82
|
-
const
|
|
82
|
+
const serverUrl = (0, WhatsAppApiHelper_1.getServerUrl)(cfg);
|
|
83
|
+
const response = await fetch(`${serverUrl}/connect`, { method: 'POST', signal: AbortSignal.timeout(60000) });
|
|
83
84
|
const result = await response.json();
|
|
84
85
|
returnData.push({ json: { ...result, sessionPath: cfg.sessionPath }, pairedItem: { item: i } });
|
|
85
86
|
}
|
|
86
87
|
catch (err) {
|
|
87
88
|
returnData.push({
|
|
88
|
-
json: { connected: false, error: `
|
|
89
|
+
json: { connected: false, error: `Connect failed: ${err.message}`, sessionPath: cfg.sessionPath },
|
|
89
90
|
pairedItem: { item: i },
|
|
90
91
|
});
|
|
91
92
|
}
|
package/package.json
CHANGED