mirror of
https://github.com/different-ai/openwork
synced 2026-05-12 10:06:26 +02:00
fix: handle whatsapp stream restart
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "owpenwork",
|
||||
"version": "0.1.4",
|
||||
"version": "0.1.5",
|
||||
"description": "WhatsApp bridge for a running OpenCode server",
|
||||
"private": false,
|
||||
"type": "module",
|
||||
|
||||
@@ -23,7 +23,7 @@ const program = new Command();
|
||||
|
||||
program
|
||||
.name("owpenbot")
|
||||
.version("0.1.3")
|
||||
.version("0.1.5")
|
||||
.description("OpenCode WhatsApp + Telegram bridge")
|
||||
.argument("[path]")
|
||||
.option("--non-interactive", "Run setup defaults and exit", false)
|
||||
@@ -333,4 +333,7 @@ program
|
||||
console.log("If replies fail, ensure OpenCode server is running at OPENCODE_URL.");
|
||||
});
|
||||
|
||||
await program.parseAsync(process.argv);
|
||||
program.parseAsync(process.argv).catch((error) => {
|
||||
console.error(error);
|
||||
process.exitCode = 1;
|
||||
});
|
||||
|
||||
@@ -98,6 +98,13 @@ export function createWhatsAppAdapter(
|
||||
| { error?: { output?: { statusCode?: number } } }
|
||||
| undefined;
|
||||
const statusCode = lastDisconnect?.error?.output?.statusCode;
|
||||
if (statusCode === 515 && !stopped) {
|
||||
log.warn("whatsapp stream error; restarting connection");
|
||||
setTimeout(() => {
|
||||
void connect();
|
||||
}, 1000);
|
||||
return;
|
||||
}
|
||||
const shouldReconnect = statusCode !== DisconnectReason.loggedOut;
|
||||
if (shouldReconnect && !stopped) {
|
||||
log.warn("whatsapp connection closed, reconnecting");
|
||||
|
||||
Reference in New Issue
Block a user