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

Subscriptions: TypeError: Cannot set property 'close' of undefined #772

Open
artmarydotir opened this issue Apr 14, 2022 · 2 comments
Open

Comments

@artmarydotir
Copy link

artmarydotir commented Apr 14, 2022

nodejs version: v16.7.0
os version: nodejs official docker image debian 11.2
fastify version: 3.20
mercurius : 8.12.2
mqemitter-redis": 4.1.0
ioredis: 4.0.0


Hi, im using [Subscription support (with redis)], but getting this error at subscribing. im not implemented the publish yet , bcuz at first i can not subscribe.

type Subscription {
  SubSetting: String
}

module.exports = async (_, __, { pubsub }) => {
  // console.log(pubsub);
  pubsub
    .subscribe('NOTIFICATION_ADDED')
    .then((a) => {
      console.log(a);
    })
    .catch((e) => {
      console.log(e);
    });
};

the pubsub object console log result:


PubSub {
  emitter: MQEmitterRedis {
    _opts: {
      port: 6379,
      host: 
      username: 
      password: 

      , ..........
      , ..........
      . ..........
       _topics: {},
    _cache: LRUCache {
      [Symbol(max)]: 10000,
      [Symbol(lengthCalculator)]: [Function: naiveLength],
      [Symbol(allowStale)]: false,
      [Symbol(maxAge)]: 60000,
      [Symbol(dispose)]: undefined,
      [Symbol(noDisposeOnSet)]: false,
      [Symbol(updateAgeOnGet)]: false,
      [Symbol(cache)]: Map(0) {},
      [Symbol(lruList)]: [Yallist],
      [Symbol(length)]: 0
    },
    state: EventEmitter {
      _events: [Object: null prototype] {},
      _eventsCount: 0,
      _maxListeners: undefined,
      [Symbol(kCapture)]: false
    },
    _onError: [Function: onError],
    _messageQueue: [],
    _messageCallbacks: [],
    _parallel: [Function: parallel],
    concurrency: 0,
    current: 0,
    _matcher: Qlobber {
      _separator: '/',
      _wildcard_one: '+',
      _wildcard_some: '#',
      _max_words: 100,
      _max_wildcard_somes: 3,
      _match_empty_levels: true,
      _trie: Map(0) {}
    },
    closed: false,
    _released: [Function: released]
  }

And the error im getting:

TypeError: Cannot set property 'close' of undefined
    at /app/api/node_modules/mercurius/lib/subscriber.js:28:19
    at new Promise (<anonymous>)
    at PubSub.subscribe (/app/api/node_modules/mercurius/lib/subscriber.js:11:12)
    at Object.module.exports [as SubSetting] (/app/api/src/GraphQL/Subscribe/SubSetting.js:17:6)
    at resolveField (/app/api/node_modules/graphql/execution/execute.js:464:18)
    at executeFields (/app/api/node_modules/graphql/execution/execute.js:292:18)
    at executeOperation (/app/api/node_modules/graphql/execution/execute.js:236:122)
    at executeImpl (/app/api/node_modules/graphql/execution/execute.js:116:14)
    at execute (/app/api/node_modules/graphql/execution/execute.js:60:63)
    at Object.fastifyGraphQl [as graphql] (/app/api/node_modules/mercurius/index.js:569:29)
@mcollina
Copy link
Collaborator

Can you provide steps to reproduce? We often need a reproducible example, e.g. some code that allows someone else to recreate your problem by just copying and pasting it. If it involves more than a couple of different file, create a new repository on GitHub and add a link to that.

@artmarydotir
Copy link
Author

Can you provide steps to reproduce? We often need a reproducible example, e.g. some code that allows someone else to recreate your problem by just copying and pasting it. If it involves more than a couple of different file, create a new repository on GitHub and add a link to that.

ِYes, I understand. I thought to myself, maybe this is a common mistake.
this problem is currently running on a project that I can not publish.
but thank you for your answer and in the next few days I will publish a small repository of my problem again. 🌷

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

2 participants