Monorepo for Aesthetic.Computer aesthetic.computer
4
fork

Configure Feed

Select the types of activity you want to include in your feed.

fix: make Redis optional in session server

Skip Redis client creation when REDIS_CONNECTION_STRING is unset.
Prevents crash on servers without Redis (chat + WS still work).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

+25 -22
+25 -22
session-server/session.mjs
··· 519 519 } 520 520 521 521 // *** Start up two `redis` clients. (One for subscribing, and for publishing) 522 - const sub = !dev 523 - ? createClient({ url: redisConnectionString }) 524 - : createClient(); 525 - sub.on("error", (err) => { 522 + const redisEnabled = !!redisConnectionString; 523 + const sub = redisEnabled 524 + ? (!dev ? createClient({ url: redisConnectionString }) : createClient()) 525 + : null; 526 + if (sub) sub.on("error", (err) => { 526 527 log("🔴 Redis subscriber client error!", err); 527 528 logError('error', `Redis sub: ${err.message}`); 528 529 }); 529 530 530 - const pub = !dev 531 - ? createClient({ url: redisConnectionString }) 532 - : createClient(); 533 - pub.on("error", (err) => { 531 + const pub = redisEnabled 532 + ? (!dev ? createClient({ url: redisConnectionString }) : createClient()) 533 + : null; 534 + if (pub) pub.on("error", (err) => { 534 535 log("🔴 Redis publisher client error!", err); 535 536 logError('error', `Redis pub: ${err.message}`); 536 537 }); 537 538 538 539 try { 539 - await sub.connect(); 540 - await pub.connect(); 540 + if (sub && pub) { 541 + await sub.connect(); 542 + await pub.connect(); 541 543 542 - // TODO: This needs to be sent only for a specific user or needs 543 - // some kind of special ID. 544 - await sub.subscribe("code", (message) => { 545 - const parsed = JSON.parse(message); 546 - if (codeChannels[parsed.codeChannel]) { 547 - const msg = pack("code", message, "development"); 548 - subscribers(codeChannels[parsed.codeChannel], msg); 549 - } 550 - }); 544 + await sub.subscribe("code", (message) => { 545 + const parsed = JSON.parse(message); 546 + if (codeChannels[parsed.codeChannel]) { 547 + const msg = pack("code", message, "development"); 548 + subscribers(codeChannels[parsed.codeChannel], msg); 549 + } 550 + }); 551 551 552 - await sub.subscribe("scream", (message) => { 553 - everyone(pack("scream", message, "screamer")); // Socket back to everyone. 554 - }); 552 + await sub.subscribe("scream", (message) => { 553 + everyone(pack("scream", message, "screamer")); // Socket back to everyone. 554 + }); 555 + } else { 556 + log("⚠️ Redis disabled — code/scream channels unavailable"); 557 + } 555 558 } catch (err) { 556 559 error("🔴 Could not connect to `redis` instance."); 557 560 }