#Hook plugins stop receiving events after WhatsApp reconnect

1 messages · Page 1 of 1 (latest)

polar arch
#

Hook plugins stop receiving events after WhatsApp reconnect (bug)

We identified a consistent issue in OpenClaw affecting hook plugins using definePluginEntry.

Behavior

  • api.on("message_received") works on cold start
  • After WhatsApp reconnect (status 428), zero events are delivered
  • Plugin stays ready, no errors, but becomes deaf

api.on("message_received", ...)
api.on("message_sending", ...)

Key finding

The built-in whatsapp-group-jsonl hook also stops after reconnect → not a plugin bug.

Root cause (analysis)

On reconnect:

  • WhatsApp channel recreates its internal client
  • Event bridge to dispatcher is lost
  • Hook listeners are not rebound
  • No lifecycle event is exposed for plugins to re-register

Conclusion

Hooks are lost after reconnect and cannot be restored from plugin side.

Suggested fix

Ensure listeners are rebound after reconnect:

function attach(client) {
client.on("message", (m) =>
dispatcher.emit("message_received", m)
);
}

async function reconnect() {
client = await newClient();
attach(client); // critical
}

Question

Is there a planned fix or recommended way to keep hooks alive after reconnect?

ebon saddleBOT
#

To help others find answers, you can mark your question as solved via Right click solution message -> Apps -> ✅ Mark Solution