Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛 Bug Report — Runtime APIs - EventSource missing EventTarget interface #2698

Closed
aron opened this issue Sep 12, 2024 · 0 comments · Fixed by #2703
Closed

🐛 Bug Report — Runtime APIs - EventSource missing EventTarget interface #2698

aron opened this issue Sep 12, 2024 · 0 comments · Fixed by #2703

Comments

@aron
Copy link

aron commented Sep 12, 2024

Tested with wrangler@3.76.0 on macOS.

It doesn't appear that the EventSource implementation conforms to the EventTarget interface and only provides the onmessage handler.

This appears to mean that streams where events use a named event field are not consumable as these are not passed to onmessage.

event: output
data: hello world
id: 1

According to MDN the addEventListener("output", fn) interface is used to consume these named events.

Example:

const source = new EventSource("http://example.com");
source.addEventListener("output", function (evt) {});

Output:

TypeError: source.addEventListener is not a function

If I try and consume the above stream with just onmessage:

source.onerror evt => console.error(evt)
source.onmessage = evt => console.log(evt)

I get an error logged:

Error: The server disconnected.
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 a pull request may close this issue.

1 participant