EventSource icon indicating copy to clipboard operation
EventSource copied to clipboard

Feature Request - No timeout

Open hghammoud opened this issue 6 years ago • 4 comments

Is it possible to provide a way to disable timeout. This is essential for continuous streams such as notifications.

Currently if I set the heartbeatTimeout to 0 it's still being set to 45000 ms. Which doesnt allow to push from the server beyond that 45 s window.

hghammoud avatar Nov 16 '18 18:11 hghammoud

With heartbeatTimeout to 0 it works, you can try with the example provide in the source code.

sguiheux avatar Nov 18 '18 07:11 sguiheux

I did try it with heartbeatTimeout in the option of the constructor still its being set to 45000ms.

const eventSourceInitDict = {
                        headers: { 'Authorization': 'Bearer ' + jwt },
                        heartbeatTimeout: 0
                    };
const eventSource = new EventSourcePolyfill(url + params.toString(), eventSourceInitDict);

This is because a value of 0 is false. i.e options.heartbeatTimeout || 45000 always gives 45000 if heartbeatTimeout =0

getDuration(options.heartbeatTimeout || 45000, 0);

it needs to be

getDuration(options.heartbeatTimeout !== null ?  options.heartbeatTimeout : 45000, 0)

hghammoud avatar Nov 18 '18 12:11 hghammoud

Hello Steve. Any news whether you are going to implement this or not?

hghammoud avatar Nov 23 '18 08:11 hghammoud

There is a setting called checkActivity. If this is set to false this should disable the activity check. But it is buggy. If this is the intentional use for this setting, I would fix it. Can somebody please confirm? Thanks.

mucer avatar Dec 20 '18 13:12 mucer