Closed acoreyj closed 5 years ago
I'm on vacation right now, will try to look at this on Monday
Thanks, updated with very basic example on codesandbox demonstrating next() not resolving, maybe I'm misunderstanding something otherwise there is something going wrong with the pubsub implementation
Seems like next()
resolves if the publish
is called after next()
is called. But the subscription should already be done by calling .asyncIterator
in both cases I believe.
Thanks for doing some digging. It seems that this is a pretty clear consequence of https://github.com/apollographql/graphql-subscriptions/commit/c8a7f7cf4897c479d15631c9a9039dba93054a80
This change was made to avoid certain memory leaks; it's not clear to me if there's any alternative given how AsyncIterators work.
Is it possible to change your code to always call next() before calling publish?
Ah, yup that is possible. Seems like the old behavior was the wrong behavior and the new behavior makes more sense. Thanks
I believe this probably has to do with the latest changed to pubsub and asynciterator, as my code and tests work with 1.0 but not 1.1
Edit - Showing the failure in codesandbox
1.1
next()
never resolves - https://codesandbox.io/s/j4022nnm3w?fontsize=14 1.0next()
resolves - https://codesandbox.io/s/oxorqwyl59?fontsize=14 1.1next()
resolves ifpublish
called afternext()
- https://codesandbox.io/s/w70lo2qpkk?fontsize=14My code:
Essentially this takes a pubsub and adds subscription types and resolvers and sets up the publish:
https://github.com/genie-team/graphql-genie/blob/master/plugins/subscriptions/src/subscriptions.ts
Here is the test that is now failing
https://github.com/genie-team/graphql-genie/blob/master/plugins/subscriptions/tests/__tests__/subscriptions.test.ts
The AsyncIterator returned from graphql subscribe never has next resolved, even though publish is called on the pubsub
Test results in timeouts
https://circleci.com/gh/genie-team/graphql-genie/92?utm_campaign=build-failed&utm_medium=email&utm_source=notification
I even put a breakpoint in the withfilter method, next is not being called there either.