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

Crashes upon failing to connect to Redis even though Redis isn't configured #1516

Closed
Hedova928 opened this issue Dec 26, 2020 · 7 comments
Closed

Comments

@Hedova928
Copy link

Commit #1390 seems to have added some functionality that expects a Redis server to be available by default.

[8:10:11 PM] info :: ℹ selected stores: amazon
[8:10:11 PM] info :: ℹ selected series: 3080, sonyps5c
INFO: Could not find files for the given pattern(s).
INFO: Could not find files for the given pattern(s).
INFO: Could not find files for the given pattern(s).
INFO: Could not find files for the given pattern(s).
INFO: Could not find files for the given pattern(s).
INFO: Could not find files for the given pattern(s).
INFO: Could not find files for the given pattern(s).
[8:10:13 PM] info :: ✔ sound player found: cmdmp3
[8:10:14 PM] info :: ℹ puppeteer config:  {
  "0": "--no-sandbox",
  "1": "--disable-setuid-sandbox"
}
node:events:353
      throw er; // Unhandled 'error' event
      ^

Error: connect ECONNREFUSED 127.0.0.1:6379
    at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1133:16)
Emitted 'error' event on RedisClient instance at:
    at RedisClient.on_error (C:\Users\Hedova\Desktop\Programs\streetmerchant\node_modules\redis\index.js:341:14)
    at Socket.<anonymous> (C:\Users\Hedova\Desktop\Programs\streetmerchant\node_modules\redis\index.js:222:14)
    at Socket.emit (node:events:376:20)
    at emitErrorNT (node:internal/streams/destroy:188:8)
    at emitErrorCloseNT (node:internal/streams/destroy:153:3)
    at processTicksAndRejections (node:internal/process/task_queues:80:21) {
  errno: -4078,
  code: 'ECONNREFUSED',
  syscall: 'connect',
  address: '127.0.0.1',
  port: 6379
}
npm ERR! code 1
npm ERR! path C:\Users\Hedova\Desktop\Programs\streetmerchant
npm ERR! command failed
npm ERR! command C:\WINDOWS\system32\cmd.exe /d /s /c npm run build && node build/index.js

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\Hedova\AppData\Local\npm-cache\_logs\2020-12-26T04_10_15_017Z-debug.log
@msakallah
Copy link

I also have received an error, and once I reverted back the redis change #1390, I was able to run the project without any errors (see screenshot beow)

image

@imtn
Copy link

imtn commented Dec 26, 2020

I also receive this error, and if I also revert back the redis change mentioned earlier, then it runs fine again.

@gigi2006
Copy link

gigi2006 commented Dec 26, 2020

I also receive this error, and if I also revert back the redis change mentioned earlier, then it runs fine again.

can you explain how you discarded the redis change?

//edit: ok i fix it for me whit install this one https://github.com/microsoftarchive/redis/releases/latest

//edit2: Maybe next time i must read better :)
I have Not read that i must this Here to Put in the dotenv
REDIS_URL="redis://localhost:6379/1"

But @jef and @BaileyMillerSSI you have forgot to Put example in the dotenv-example

@gianmarcotoso
Copy link

gianmarcotoso commented Dec 26, 2020

The issue is due to the Redis client being initialized within the module scope, while it should be initialized separately and only on-demand. You can hotfix this by changing the first few lines of the notification/redis.ts file to this:

//...
const { url } = config.notifications.redis;

let client: redis.RedisClient;

const updateRedis = (link: Link, store: Store) => {
    if (!url || url.trim?.().length === 0) {
	return;
    }

    if (!client) {
	client = redis.createClient({
		url,
	});
    }

    try {
    //...

(where //... means that you should leave the rest of the code before/after the comment as is). This is not the most elegant solution but I haven't delved into the codebase deep enough to see if there is an init method, an IoC container or something else where to initialize the Redis client "properly" :)

Edit: I've added a check to terminate immediately if the Redis client URL is not set or empty, again this can probably be done better, I've just pasted a quick fix!

@carrierfry
Copy link
Contributor

For Linux users: Just install redis via your package manager. That did the trick for me!

@jef
Copy link
Owner

jef commented Dec 26, 2020

Damn.. I don't know why this was going through. I will fix. Thanks.

@tech-degenerate
Copy link

tech-degenerate commented Dec 26, 2020

I was having the same problem on windows but just updated code and now it's working

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants