EventSource doesn't fire 'open' events until some data is received

NEW
Unassigned

Status

()

Core
DOM
6 years ago
5 years ago

People

(Reporter: Luca Wehrstedt, Unassigned)

Tracking

22 Branch
x86_64
Linux
Points:
---

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(2 attachments)

(Reporter)

Description

6 years ago
It seems to me that EventSource doesn't fire 'open' events when the connection is opened. Instead, it fires them as soon as some data is received from the server. I'm using these events to update a "connection status indicator" and I'd like to show that the connection has been correctly established even if no events have been received yet.

I'm attaching a demo that clearly shows this behavior. It includes a HTML page and a sample server written in Python, using Tornado, that allows you to easily tweak what is sent on the event stream. Just put them both in the same directory and start the Python script.

You'll notice that, when the demo starts, nothing is printed on the Firebug console. You can also check that es.readyState is 0 (i.e. CONNECTING). Yet, when a message is received, it'll preceded by the open event, and the state will also be correctly set. The same happens also if the server sends a 'retry' command or just a comment.

Other browser (like Chromium) send the open event as soon as the connection is established. I think their behavior is the "correct" one.
(Reporter)

Comment 1

6 years ago
Created attachment 649008 [details]
demo HTML page
(Reporter)

Comment 2

6 years ago
Created attachment 649009 [details]
demo Python server

Updated

6 years ago
Attachment #649008 - Attachment mime type: text/plain → text/html

Updated

5 years ago
Status: UNCONFIRMED → NEW
Component: General → DOM
Ever confirmed: true
Product: Firefox → Core
Version: 14 Branch → 22 Branch
You need to log in before you can comment on or make changes to this bug.