fetch-event-source icon indicating copy to clipboard operation
fetch-event-source copied to clipboard

Should abort trigger onclose?

Open gyzerok opened this issue 2 years ago • 1 comments

Hello!

While I was working with server-sent events I've discovered similar shortcomings as you. Glad your library exists to fix them!

One issue I've discovered with your library is that calling ctrl.abort() won't result in either onclose or onerror calls. This makes it difficult to collocate code which is responsible of handling connection closing, be it by a server or manual.

Is there something I am missing? Would it make sense as a feature?

gyzerok avatar Jun 02 '22 17:06 gyzerok

@gyzerok did you get any fixes for this, I am having the same kind of scenario where I need to stop the connection on a particular condition.

yuvraj88 avatar Sep 23 '22 06:09 yuvraj88

Please change to reject({ aborted:true }) here

https://github.com/Azure/fetch-event-source/blob/6fb7115ebacb90600b54383ea32f799f6f647203/src/fetch.ts#L97

haug1 avatar Oct 11 '22 17:10 haug1

Please change to reject({ aborted:true }) here

https://github.com/Azure/fetch-event-source/blob/6fb7115ebacb90600b54383ea32f799f6f647203/src/fetch.ts#L97

Has anyone tested this does fix the issue without other regressions? Should we create a PR?

lucrus73 avatar Jun 05 '23 08:06 lucrus73

As the same. I call thectrl.abort(), but it is trigger neither onclose or onerror.

terryokay avatar Jun 06 '23 01:06 terryokay

Is this fixed? Why is this closed?

CharlesHGong avatar Aug 16 '23 00:08 CharlesHGong

Please change to reject({ aborted:true }) here https://github.com/Azure/fetch-event-source/blob/6fb7115ebacb90600b54383ea32f799f6f647203/src/fetch.ts#L97

Has anyone tested this does fix the issue without other regressions? Should we create a PR?

I think we can create a PR for this, let's see if I can have time for this. Of course need to keep an eye on the regressions, and I think maintainers can see if that can happen.

omer-pon avatar Apr 03 '24 07:04 omer-pon