sguiheux / EventSource

EventSource "polyfill" with custom headers
20 stars 10 forks source link

Feature Request - No timeout #22

Open hghammoud opened 5 years ago

hghammoud commented 5 years ago

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.

sguiheux commented 5 years ago

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

hghammoud commented 5 years ago

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 commented 5 years ago

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

mucer commented 5 years ago

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.