fix(redis): skip missing-REDIS_URL warning during production build
CI / check (push) Successful in 40s
CI / tests-integration (push) Successful in 2m15s
CI / tests-unit (push) Successful in 3m7s
CI / tests-quality (push) Successful in 1m14s
CI / tests-imaging-browsers (push) Successful in 1m36s
CI / tests-ui (push) Failing after 6m56s
CI / preflight (push) Skipped
CI / deploy (push) Skipped
CI / check (push) Successful in 40s
CI / tests-integration (push) Successful in 2m15s
CI / tests-unit (push) Successful in 3m7s
CI / tests-quality (push) Successful in 1m14s
CI / tests-imaging-browsers (push) Successful in 1m36s
CI / tests-ui (push) Failing after 6m56s
CI / preflight (push) Skipped
CI / deploy (push) Skipped
This commit is contained in:
1 parent
8d3263a8fe
commit
ef0c425598
1 file changed
+6
-1
+6
-1
@@ -1,3 +1,4 @@
|
|||||||
|
import { PHASE_PRODUCTION_BUILD } from "next/constants";
|
||||||
import "server-only";
|
import "server-only";
|
||||||
|
|
||||||
import Redis from "ioredis";
|
import Redis from "ioredis";
|
||||||
@@ -12,7 +13,11 @@ const globalForRedis = globalThis as unknown as {
|
|||||||
function createRedis(): Redis | null {
|
function createRedis(): Redis | null {
|
||||||
const url = env.REDIS_URL;
|
const url = env.REDIS_URL;
|
||||||
if (!url) {
|
if (!url) {
|
||||||
if (env.NODE_ENV === "production" && !globalForRedis.redisMissingWarned) {
|
if (
|
||||||
|
env.NODE_ENV === "production" &&
|
||||||
|
process.env.NEXT_PHASE !== PHASE_PRODUCTION_BUILD &&
|
||||||
|
!globalForRedis.redisMissingWarned
|
||||||
|
) {
|
||||||
globalForRedis.redisMissingWarned = true;
|
globalForRedis.redisMissingWarned = true;
|
||||||
logger.error(
|
logger.error(
|
||||||
"[redis] REDIS_URL is unset in production. Rate limits, site-settings cache, and JWT session invalidation fall back to in-process memory and will not work correctly across multiple instances or restarts. Set REDIS_URL in .env.",
|
"[redis] REDIS_URL is unset in production. Rate limits, site-settings cache, and JWT session invalidation fall back to in-process memory and will not work correctly across multiple instances or restarts. Set REDIS_URL in .env.",
|
||||||
|
|||||||
Reference in new issue
Block a user