davidyaha / graphql-redis-subscriptions

A graphql subscriptions implementation using redis and apollo's graphql-subscriptions
MIT License
1.11k stars 126 forks source link

[ioredis] Unhandled error event: TypeError: net_1.createConnection is not a function #488

Open devfromfinland opened 2 years ago

devfromfinland commented 2 years ago

Hi, I have setup the graphql server as instructed, and have redis server running in the background. For the front-end, I use React with Typescript, and init the connection when the app is loaded as below.

const REDIS_DOMAIN_NAME = 'localhost';
const REDIS_PORT = 6379;

const options = {
  host: REDIS_DOMAIN_NAME,
  port: REDIS_PORT,
  retryStrategy: (times: number) => Math.min(times * 50, 2000),
};

const pubsub = new RedisPubSub({
  publisher: new Redis(options),
  subscriber: new Redis(options),
});

function App(): JSX.Element {
  return (
    // app component
  )
}

However, some errors were logged in the console.

[ioredis] Unhandled error event: TypeError: net_1.createConnection is not a function
    at http://localhost:3000/static/js/vendors~main.chunk.js:64650:33
    at Item.push.../node_modules/process/browser.js.Item.run (http://localhost:3000/static/js/vendors~main.chunk.js:78287:12)
    at drainQueue (http://localhost:3000/static/js/vendors~main.chunk.js:78251:34)

Did I do something wrong? or is it actually a bug? I have installed ioredis v4.28.2, @type/ioredis v4.28.7