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

[Feauter] async WebSocket queries #49

Open
mpoeter opened this issue Dec 5, 2018 · 0 comments
Open

[Feauter] async WebSocket queries #49

mpoeter opened this issue Dec 5, 2018 · 0 comments

Comments

@mpoeter
Copy link

mpoeter commented Dec 5, 2018

For various reasons we run all our queries (and mutations) via WebSocket and found that all requests are handled sequentially in Absinthe.Phoenix.Channel. It would be great if we could execute queries asynchronously. As part of this we could also add some error handling for better stability, because when a query/mutation raises/throws an exception that is not caught in the resolver, the channel process simply dies. In the frontend we use apollo-socket-link which then rejoins the channel and restarts all pending queries/mutations (including the one that caused the exception). If the error persists, we end up in an infinite loop.

I have sketched out a proof of concept implementation here: https://gist.github.com/mpoeter/d18885caa3b46d47f031f6d913c93208

It spawns a monitored process for every single request. Requests that contain mutations are executed sequentially (i.e., we wait for the task to finish), other queries simply run in the background. Since the processes are not linked, the channel process does not die in case of an exception. But since it is monitored we can send a proper error reply (similar to what happens if a HTTP request dies due to an exception).

I would like to use this issue to discuss pros/cons of this approach and if/how this could be implemented as part of Absinthe.Phoenix.Channel.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant