All Posts
February 26, 20260.1.23Jugg.ai

v0.1.23 — perf: replace SSE 3s polling with Postgres LISTEN/NOTIFY + 10s fallback

Release v0.1.24: SSE Pipeline Monitoring Now Uses Postgres LISTEN/NOTIFY

What changed

  • Replaced 3-second polling with Postgres LISTEN/NOTIFY — Pipeline SSE connections now receive real-time updates via database triggers instead of continuous polling.
  • 10-second fallback poll — A coarse fallback continues running in parallel as a safety net for missed notifications or LISTEN setup failures.
  • Added database triggers — Two triggers on pipeline_runs and agent_jobs tables automatically fire NOTIFY on insert or update, with zero code changes required to existing agents.
  • Improved SSE stream route — Rewritten to establish a WebSocket-backed LISTEN connection and gracefully degrade to polling if needed.

Why it matters

SSE connections were generating ~2,000 database queries per minute per 100 idle users. LISTEN/NOTIFY reduces that by ~90% during active pipeline runs — down to 1–2 queries per actual state change instead of every 3 seconds. Update latency drops from up to 3 seconds to sub-second.

Technical notes

  • New file: src/lib/pipeline-notify.ts — utilities for creating a LISTEN client and firing NOTIFYs
  • New migration: 0018_pipeline_notify_triggers.sql — creates the trigger function and two event triggers
  • The LISTEN connection uses Node 22's native globalThis.WebSocket via Neon's serverless Client
  • If LISTEN setup fails, the stream continues via fallback polling — no user-facing degradation

Release Notes

The tag v0.1.23 already exists in the repository. The PR has been successfully merged (commit 70bb63e), but a release with that tag was already created previously — trying to create a duplicate tag will always be rejected by GitHub.

Here's a summary of what happened and your options:


✅ Merge — Succeeded

  • PR #432 (perf: replace SSE 3s polling with Postgres LISTEN/NOTIFY + 10s fallback) was squash-merged into main.
  • Merge commit: 70bb63e4afc27a20f2b39a19bfb1c3736aa06a48

❌ Release — Tag v0.1.23 Already Exists

GitHub rejected the release creation because the tag v0.1.23 is already present in the repo. This could mean:

  1. A prior release v0.1.23 was already published (possibly in error, or for a different set of changes).
  2. The tag was created manually on a previous commit.

What You Can Do Next

Please choose one of the following:

OptionDescription
Use v0.1.24Bump to the next patch version and I'll create the release immediately.
Delete the existing v0.1.23 tagIf the old tag was created in error, delete it from GitHub first, then I can re-create it.
Attach to existing releaseIf v0.1.23 was already drafted/published, the PR changes can be noted in its release body manually.

Would you like me to proceed with v0.1.24 as the release tag?

v0.1.23 — perf: replace SSE 3s polling with Postgres LISTEN/NOTIFY + 10s fallback — Jugg.ai Blog