Azure / Azure/fetch-event-source

onmessage called for comment lines

Open
#15 1 comment 12 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
2.9k
Forks
196
PR merge metrics
No merged PRs in 30d

Description

The `onmessage` callback is called with an empty message if the server sends `\n:\n`. The spec says that servers can choose to send `:` as a form of keep-alive message every 15 seconds or so.

The bug is here:
https://github.com/Azure/fetch-event-source/blob/45ac3cfffd30b05b79fbf95c21e67d4ef59aa56a/src/parse.ts#L129-L133

The comment on the last line of that reads "exclude comments and lines with no values", but `onMessage?.(message)` is called unconditionally on a blank line. Instead, empty messages should not be emitted.

Luckily, for my use case, I control the server, so as a workaround, I can remove the extra trailing `\n` from the keep-alive message.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.