fix(relay): switch from pub/sub SSE to LPUSH/RPOP list queue (#2581)

* fix(relay): switch from pub/sub SSE to LPUSH/RPOP list queue

The Upstash REST pub/sub subscribe endpoint returns SSE in a format
that is difficult to verify without live debugging (comma-separated
vs JSON, streaming vs immediate-close). Switch to a list-based queue:

- Publishers: PUBLISH /wm:events:notify -> LPUSH /wm:events:queue
- Relay: SSE subscribe loop -> 1s-interval RPOP poll

Benefits: well-defined JSON response {result: '<msg>'|null}, messages
survive relay restarts (not lost if relay is down), no SSE format
ambiguity, simpler code.

* fix(relay): add missing User-Agent headers to LPUSH calls in notify and slack callback
This commit is contained in:
Elie Habib
2026-03-31 20:48:47 +04:00
committed by GitHub
parent cc7a7e9475
commit 6cdcb375bb
4 changed files with 22 additions and 56 deletions

View File

@@ -77,8 +77,8 @@ export default async function handler(req: Request): Promise<Response> {
});
const res = await fetch(
`${upstashUrl}/publish/wm:events:notify/${encodeURIComponent(msg)}`,
{ method: 'POST', headers: { Authorization: `Bearer ${upstashToken}` } },
`${upstashUrl}/lpush/wm:events:queue/${encodeURIComponent(msg)}`,
{ method: 'POST', headers: { Authorization: `Bearer ${upstashToken}`, 'User-Agent': 'worldmonitor-edge/1.0' } },
);
if (!res.ok) {