question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Messages are delayed in IE 11

See original GitHub issue

Hi, I’m trying to use this library with IE 11 but I get a weird behaviour: the messages are delayed and they are received by the client all at once after a certain period of time (around 2 minutes!). To test this I have a simple server in Express that emits messages every 2 secs.

In my express server, the headers I set are these:

// set timeout as high as possible
req.socket.setTimeout(0);

// send headers for event-stream connection
// see spec for more information
resp.writeHead(200, {
	'Content-Type': 'text/event-stream',
	'Cache-Control': 'no-cache',
	'Connection': 'keep-alive',
	'Access-Control-Allow-Origin': '*'
});
resp.write('\n');

The messages are created like this:

var d = new Date();
resp.write('id: ' + d.getMilliseconds() + '\n');
resp.write('event:' + 'message') + '\n');
resp.write('data:' + createMsg(d) + '\n\n'); // Note the extra newline

Finally, in the client I use it as suggested:

let eventSource = new EventSource("http://localhost:4000/sse");
eventSource.addEventListener("message", (event) => console.log("message received:", event), false);
eventSource.addEventListener("open", (event) => console.log("onopen:", event), false);
eventSource.addEventListener("error", (event) => console.log("onerror:", event), false);

As I said, the messages are delayed in IE 11 and they arrive all together after 2 mins aprox.

However, if I use this other EventSource polyfill which is a fork of Yaffle/EventSource, IE11 receives the messages immediately as soon as the server sends them.

I’m wondering if your polyfill is supposed to work in IE11 or is not supported? If it is supported, do you happen to know what the issue could be?

Issue Analytics

  • State:open
  • Created 6 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
aslakhellesoycommented, Sep 21, 2017

I wouldn’t trust any server side hacks to make this work. There is a bug in the code that needs to be fixed, period.

0reactions
X-Ryl669commented, Jan 7, 2019

The “server side hack” is also present on other polyfills. I wonder if the issue is the id: d.getMilliseconds() that would return the same id since it only gives the the current number of milliseconds (from 0 to 999) for the current second. So, it’d be much better to use a increasing unique identifier.

Both IE and Edge buffers the data from the network layer, and that’s why you need the padding hack, so the JS callback are called when the buffer is full. If the id fix above doesn’t work, I wonder if you should make your event larger so the buffer hits the JS’s callback. Typically, it’s likely the AJAX connection underneath (in the polyfill implementation) times out, and tries to reconnect. In that case, you’d need to pad the connection again. That’s a real PITA, but since it’s bug in the browser, there nothing you can do against.

Please notice that IE/Edge’s polyfill emulate a streaming connection with a non-streaming based technology. So it reconnects much more frequently (you can increase the timeout on the browser’s library).

Read more comments on GitHub >

github_iconTop Results From Across the Web

What's the reason of delay on sending a message when ...
Hi,. I would like to ask what's the reason behind the delay on sending messages when internet was good per checking and even...
Read more >
Windows 10: Fix for slow Internet Explorer 11 start - BornCity
The following entry in the Windows 10 message center from August 16, 2019 has more details: Resolved: Delays starting Internet Explorer 11.
Read more >
JIRA Admins seeing page load pauses in IE11
JIRA Admin users are seeing delays in page load times while accessing JIRA on IE11 web browser. The delay is not specific to...
Read more >
Troubleshooting message delay issues using API Explorer
If you encounter SMS delivery delays, an important first step is to rule out any latency occurring within your application, or between...
Read more >
How to set delay in vbscript - Stack Overflow
Run it, notice the delay before the message box is shown. ... such as Internet Explorer's (and you might be without realising it...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found