Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pass abort function to eventStream callback and accept headers option #210

Merged
merged 1 commit into from
Jul 3, 2023

Conversation

tugrul
Copy link
Contributor

@tugrul tugrul commented Jun 21, 2023

I needed to finalize the response in some cases like "job done" or "unauthorized access". I consider to access abort callback from from setup callback is good idea.

Nginx is waiting for buffer to fill and It not send events immediately. It disables buffering when response headers has X-Accel-Buffering: no field. I put an options field to control this case.

@sergiodxa
Copy link
Owner

I would prefer to give you a way to pass a Headers object so you can set custom headers instead of adding an option for every custom header a proxy may need.

For the close function, you can create a custom AbortController before sending the response, see https://sergiodxa.com/tutorials/close-sse-connection-from-the-server-in-remix

I needed to finalize the response in some cases like "job done" or "unauthorized access". I consider to access abort callback from from setup callback is good idea.

Option parameter to add headers
@tugrul tugrul force-pushed the event-stream-abort-callback branch from 867bf8e to 32b7e9e Compare June 22, 2023 20:37
@tugrul
Copy link
Contributor Author

tugrul commented Jun 22, 2023

I changed to use optional headers more generic way as you mentioned.

I already use AbortController as a wrapper as you mentioned for workaround. But I think this is more common requirements and abort callback must have.

if it was necessary to use it due to an unusual situation then I wouldn't think about it.

@sergiodxa sergiodxa added the enhancement New feature or request label Jun 28, 2023
@sergiodxa sergiodxa changed the title eventStream abort callback and options Pass abort function to eventStream callback and accept headers option Jul 3, 2023
@sergiodxa sergiodxa merged commit 85b5e30 into sergiodxa:main Jul 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants