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

An error has occured for subscription 'chatMessageAdded' # #528

Closed
akaNightmare opened this issue Aug 27, 2017 · 13 comments
Closed

An error has occured for subscription 'chatMessageAdded' # #528

akaNightmare opened this issue Aug 27, 2017 · 13 comments

Comments

@akaNightmare
Copy link

Hello, I receive next error message from backend
{message: "Cannot read property 'then' of undefined"}

I believe the issue related to https://github.com/graphql/graphql-js/releases/tag/v0.11.0

Thanks.

@kachkaev
Copy link
Contributor

kachkaev commented Aug 28, 2017

Looks like I'm also facing this – the subscriptions stopped working after a recent upgrade. Rolling back to "graphql": "0.10.5" helped. How about downgrading this dependency until a proper bugfix has been found?

It is likely that this breaking change causes the issue: graphql/graphql-js#918 I guess that things like withFilter in graphql-subscriptions need an upgrade too, because subscribe is now expected to be a Promise.

@nowzig
Copy link

nowzig commented Aug 29, 2017

I can confirm this problem. It works with "graphql": "0.10.5" but not with "graphql": "0.11.*"

@dangerdespain
Copy link

+1 I'm experience this issue with 0.11.* as well. Downgrading to 0.10.5 resolves the issue.

@luizstacio
Copy link

luizstacio commented Sep 1, 2017

+1 I'm experience this issue too. Downgrading resolves.

@kachkaev
Copy link
Contributor

kachkaev commented Sep 1, 2017

Ping @stubailo @martijnwalraven. It is likely that all the apollo newcomers are installing a broken version – might be crucial to fix ASAP.

@AkimaLunar
Copy link

This is still an issue for me and downgrading to 0.10.5 resolves it. Ideally, I'd like to use 0.11.

@martijnwalraven
Copy link
Contributor

@AkimaLunar: What version of graphql-subscriptions are you using?

@AkimaLunar
Copy link

@martijnwalraven It's "graphql-subscriptions": "^0.4.4"

@martijnwalraven
Copy link
Contributor

@AkimaLunar: The latest version of graphql-subscriptions is 0.5.5, so I believe upgrading that should solve this.

@perrosnk
Copy link

perrosnk commented Dec 7, 2017

Any updates on this?
I am getting an error: Subscription must return Async Iterable. Received: [object Object]

@martijnwalraven
Copy link
Contributor

@perrosnk This seems unrelated to this issue (which should be solved in recent versions of graphql-subscriptions). Are you in fact returning an AsyncIterable from the subscribe function in your schema?

@perrosnk
Copy link

perrosnk commented Dec 7, 2017

Yes:

    subscribe: withFilter(
      () => pubsub.asyncIterator(ON_NEW_ROUND),
      (roundData, args, { userOnDB }) => {
        if (!userOnDB || !userOnDB.complete) {
          return false;
        }
        return _.some(roundData.data, userOnDB.id);
      },
    ),

Although I am not sure about it it might be related to this: graphql/graphql-js#918 (comment)

I am starting the server like this:

new SubscriptionServer({
          schema: executableSchema,
          execute,
          subscribe,
          onConnect,
          // onOperation: (message, params) => {
          //   console.log('onOperation');
          // },
          onDisconnect: (a) => {
            console.log('Disconnecting');
          },
        }, {
          server: ws,
          path: GRAPHQL_PATH,
        });

I am pulling the subscribe from graphql
Where should I call this?

try {
  const result = await subscribe(...);
  if (result.errors) {
    // errors are informative and can be sent to the client
  } else {
    // result is guaranteed to be an AsyncIterable at this point
    return result;
  }
} catch (error) {
  // system error, log the problem and send a failure response to the client.
}

@abernix
Copy link
Member

abernix commented Feb 20, 2019

I suspect this problem has been resolved quite some time ago, so I'll close this. If anyone is still experiencing the problem, please feel free to open a new issue with a reproduction using a recent version of Apollo Server. Thanks!

@abernix abernix closed this as completed Feb 20, 2019
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 21, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants