Skip to content

fix: type EventSource error callbacks as Event - #6079

Open
blueDaydreaming725 wants to merge 1 commit into
nodejs:mainfrom
blueDaydreaming725:fix/eventsource-error-event-type
Open

blueDaydreaming725 wants to merge 1 commit into
nodejs:mainfrom
blueDaydreaming725:fix/eventsource-error-event-type

Conversation

@blueDaydreaming725

Copy link
Copy Markdown

This relates to...

EventSource error events: https://html.spec.whatwg.org/multipage/server-sent-events.html

Rationale

EventSource dispatches a plain Event on failure, but its declaration currently supplies ErrorEvent to both onerror and addEventListener('error', ...). This lets callers access fields such as event.message that are absent at runtime.

Changes

Use Event for both error callback declarations and remove the unused ErrorEvent import. No runtime behaviour changes.

Features

N/A

Bug Fixes

Error callbacks now have the type of the event actually dispatched.

Breaking Changes and Deprecations

Code relying on ErrorEvent-only fields or explicitly annotating these callbacks as ErrorEvent will need to use Event instead. Those fields were not provided at runtime.

Status

  • I have read and agreed to the Developer's Certificate of Origin
  • Tested: the new type assertions fail against the old declaration; all 154 EventSource tests, complete TypeScript checks and changed-file lint pass. A local HTTP 404 test verifies that onerror and addEventListener receive the same plain Event without a message field.
  • Benchmarked (optional; types only)
  • Documented: declarations corrected
  • Review ready
  • In review
  • Merge ready

Full JavaScript and WPT suites were not run.

Implemented, tested and reviewed with OpenAI Codex assistance.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant