Skip to content

Comments

🎁 Suggested improvements: BullMQ n8n queue, media security, graceful shutdown#1

Open
kobie3717 wants to merge 1 commit intoNaude555:mainfrom
kobie3717:improvements/claw-suggestions
Open

🎁 Suggested improvements: BullMQ n8n queue, media security, graceful shutdown#1
kobie3717 wants to merge 1 commit intoNaude555:mainfrom
kobie3717:improvements/claw-suggestions

Conversation

@kobie3717
Copy link

Hey! 👋 Love what you've built with Watson — clean and practical.

I was poking around and noticed a few small things that might help as the project grows. Wanted to contribute back rather than just fork, so here are 4 suggestions in one clean commit:

1. 🔄 n8n forward queue → BullMQ (crash-safe)

The in-memory n8nQueue = [] works great, but if the process restarts mid-forward you lose queued events. This swaps it for a BullMQ queue (you already have the pattern for the outbound send queue) so n8n forwards survive restarts and get proper exponential backoff retries.

2. 🔒 Media endpoint security fix

The express.static middleware on /media was serving files before the signature verification route could run. Removed the static middleware so all media requests go through your existing signed URL check — no more bypassing the signature.

3. 🛑 Enhanced graceful shutdown

Extended your existing shutdown handler to also:

  • Stop accepting new HTTP connections
  • Close the n8n BullMQ worker/queue
  • Cleanly close the Baileys socket
  • Log what's happening during shutdown

4. 📝 SQLite migration breadcrumbs (comments only)

Added TODO comments at readMessagesStore/writeMessagesStore suggesting a future SQLite migration path. No code changes — just notes for when the JSON store starts feeling heavy.

All changes are in server.js, matching your existing style. Take what's useful, ignore what's not! 🙂

… notes

- Replace in-memory n8n forward queue with BullMQ (crash-safe, retries)
- Fix media endpoint: remove express.static bypass, all media goes through signature verification
- Enhance graceful shutdown: drain queues, close Baileys socket, stop HTTP server
- Add TODO comments suggesting SQLite migration path for message store
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant