Skip to content

[Bug]: Do not use new Date().getTime() for generating SSE events IDs #174

@ishymko

Description

@ishymko

Extracted from code review comment:

medium

Using new Date().getTime() for Server-Sent Event (SSE) IDs is not guaranteed to produce unique IDs, especially if multiple events are generated within the same millisecond. This could lead to issues with clients that rely on unique event IDs. According to the SSE specification, the id field should uniquely identify the event, which is crucial for features like resuming connections.

A more robust approach would be to use a counter initialized before the try block (e.g., let eventId = 0;) and increment it for each event. This change should also be applied on line 63.

Originally posted by @gemini-code-assist[bot] in #162 (comment)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions