Skip to content
This repository has been archived by the owner on Sep 2, 2022. It is now read-only.

Get an error in subscription #2920

Closed
SilencerWeb opened this issue Aug 14, 2018 · 10 comments
Closed

Get an error in subscription #2920

SilencerWeb opened this issue Aug 14, 2018 · 10 comments
Labels
bug/1-repro-available A reproduction exists and needs to be confirmed.

Comments

@SilencerWeb
Copy link

SilencerWeb commented Aug 14, 2018

Describe the bug
On frontend I get an error Cannot read property 'task' of undefined in the subscription. I didn't get it before, I guess it started to behave like that after I upgraded dependencies or added new subscriptions for another type (same error - Cannot read property 'user' of undefined). I tried to downgrade dependencies, revert commits both on frontend and backend - it didn't help.

Here is an example of subscription and I think the error is here because somehow subscription is undefined:

const taskCreated = {
  subscribe: (_, args, context, info) => {
    return context.prisma.subscription.task({ where: { mutation_in: ['CREATED'] } }, info);
  },
};

To Reproduce
Steps to reproduce the behavior:

  1. git clone https://gitlab.com/SilencerWeb/dailyq-api.git
  2. cd dailyq-api && git checkout development && yarn install && yarn start

To make this example work, you need to provide variables DEVELOPMENT_PRISMA_ENDPOINT(url to prisma endpoint), DEVELOPMENT_PRISMA_SECRET(any string) and DEVELOPMENT_APP_SECRET(any string) in .env and then run prisma deploy.

Expected behavior
Shouldn't throw an error Cannot read property 'task' of undefined and I should recieve data in the subscription on frontend

Screenshots
Screenshot of the error on frontend:
image

Versions (please complete the following information):

  • OS: macOS High Sierra 10.13.6
  • "graphql-yoga": "^1.16.0"
  • "prisma-binding": "^2.1.4"
  • "graphql-cli": "^2.16.5"
  • "prisma": "^1.13.7"
    package.json before and after upgrade, doesn't work in both cases.

UPDATE:
Here is another repository with the same structure and same versions of packages. Subscriptions defined identically in both repositories, but in this one they work.

Also, when I make console.log(context) inside the subscription, I get such message: (node:12649) [DEP0079] DeprecationWarning: Custom inspection function on Objects via .inspect() is deprecated in the first repository but I do not get it in the second repository.

@SilencerWeb SilencerWeb changed the title Get an error in subscripton Get an error in subscription Aug 14, 2018
@marktani marktani added the bug/1-repro-available A reproduction exists and needs to be confirmed. label Aug 14, 2018
@SilencerWeb
Copy link
Author

SilencerWeb commented Aug 18, 2018

Okay, it is very very weird.

I COPIED node_modules from the second repository where subscriptions work to the first one and they started working (even that versions in package.json are same!). But after removing node_modules and running yarn install they stopped working again because was installed dependencies with other versions. Wtf?

Commit with COPIED node_modules
Commit after re-installing node_modules

P.S. I don't think it is because of my laptop, it works like that even on Heroku

@frankdugan3
Copy link

I am having the same issue. Wiping yarn.lock and node_modules made no difference for me.

I'm running prisma@1.14.1 and the matching container on Ubuntu 18.04.

@SilencerWeb
Copy link
Author

@frankdugan3 do you use graphql-yoga for the server? If yes, could you try to clone my repository, copy node_modules and try to test your subscriptions without installing/deleting other dependencies? Only subscriptions.

Here is a single command to clone repository and checkout to certain branch:
git clone https://gitlab.com/SilencerWeb/dailyq-api.git && cd dailyq-api && git checkout node_modules && git checkout b55ed0ba0c4b61d9. After this copy node_modules and paste them in your project.

Also, a little bit more explanation of this behavior: dotansimha/graphql-yoga#432

@frankdugan3
Copy link

@SilencerWeb I'm using apollo-server-express, so I think our situation is a little different. Probably narrows it down to prisma-binding or prisma.

@andreasenberg
Copy link

I've been experiencing similar problems myself using prisma-binding 2.1.4 and apollo-server 2.0.4. 
I happened to have another test project I've been playing around with running apollo-server 2.0.0 and prisma 2.1.3 and using those I was not getting this error.

So I tried downgrading prisma-binding and apollo-server to the same versions as in my test project and doing so I was not getting this error anymore.
Then I again upgraded apollo-server to 2.0.4 and it seems to be working as expected. So from my end this seems to be an issue introduced in prisma-binding 2.1.4.

Would be interesting to know if you are able to reproduce this if you've downgraded to "prisma-binding": "2.1.3".

@frankdugan3
Copy link

Downgrading to prisma-binding@2.1.3 solves the issue for me.

@SilencerWeb
Copy link
Author

Downgrading to prisma-binding@2.1.3 solves the issue for me too. @andreasenberg thank you so much, I had been trying to solve this issue for a week :)))

But note this: if your prisma-binding version in package.json is like that "prisma-binding": "^2.1.3", issue will still exist, but if it is like that "prisma-binding": "2.1.3", issue will be solved :)

@maury91
Copy link

maury91 commented Aug 20, 2018

I already found the root cause of this issue in prisma-labs/prisma-binding#229 (comment) , will be good if a contributor of this project (like @marktani ) can point what fix implement

@marktani
Copy link
Contributor

This should be fixed now, as prisma-labs/prisma-binding#229 is fixed.

@divyenduz
Copy link
Contributor

divyenduz commented Aug 28, 2018

This is fixed and released in prisma-binding 2.1.5 🎉

@pantharshit00 pantharshit00 added the bug/1-repro-available A reproduction exists and needs to be confirmed. label Jan 10, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug/1-repro-available A reproduction exists and needs to be confirmed.
Projects
None yet
Development

No branches or pull requests

7 participants