Skip to content

Commit be8bd9b

Browse files
committed
test: add SSE notification regression coverage
1 parent d0c7410 commit be8bd9b

2 files changed

Lines changed: 322 additions & 167 deletions

File tree

src/server/sse_server.cpp

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -511,22 +511,19 @@ bool SseServerWrapper::start()
511511
return;
512512
}
513513

514-
// Check if this is a notification (no "id" field means notification)
515-
// JSON-RPC 2.0 spec: server MUST NOT reply to notifications
516-
bool is_notification = !message.contains("id") || message["id"].is_null();
517-
514+
// JSON-RPC notifications (missing/null id) must not receive responses.
515+
const bool is_notification = !message.contains("id") || message["id"].is_null();
518516
if (is_notification)
519517
{
520-
// For notifications, call handler but don't send response body
521518
try
522519
{
523-
handler_(message); // Process but ignore result
520+
(void)handler_(message); // process side effects only
524521
}
525522
catch (...)
526523
{
527-
// Silently ignore errors for notifications
524+
// Ignore notification errors by design.
528525
}
529-
res.status = 202; // Accepted, no content
526+
res.status = 202;
530527
return;
531528
}
532529

0 commit comments

Comments
 (0)