Skip to content

Commit 47b8cdd

Browse files
authored
Merge pull request #7288 from 0xSolace/fix/cloud-cache-and-jwt-secret-preference
fix(cloud): re-apply auth fixes lost in cloud → eliza migration
2 parents fcf91d3 + 2c512f6 commit 47b8cdd

3 files changed

Lines changed: 29 additions & 10 deletions

File tree

cloud/apps/api/wrangler.toml

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,9 @@ DATABASE_REGION = "na"
104104
PAYOUT_TESTNET = "false"
105105
ENABLE_X402_PAYMENTS = "true"
106106
X402_NETWORK = "base"
107-
CACHE_ENABLED = "true"
108-
REDIS_RATE_LIMITING = "true"
107+
CACHE_ENABLED = "false"
108+
CACHE_DISABLE_REASON = "CF Workers cross-request I/O isolation: CacheClient module-level singleton is incompatible until refactored to per-request scope"
109+
REDIS_RATE_LIMITING = "false"
109110
FORCE_REDIS_EVENTS = "false"
110111
R2_PUBLIC_HOST = "blob.elizacloud.ai"
111112
SQL_HEAVY_PAYLOAD_STORAGE = "r2"
@@ -202,8 +203,9 @@ DATABASE_REGION = "na"
202203
PAYOUT_TESTNET = "true"
203204
ENABLE_X402_PAYMENTS = "true"
204205
X402_NETWORK = "base"
205-
CACHE_ENABLED = "true"
206-
REDIS_RATE_LIMITING = "true"
206+
CACHE_ENABLED = "false"
207+
CACHE_DISABLE_REASON = "CF Workers cross-request I/O isolation: CacheClient module-level singleton is incompatible until refactored to per-request scope"
208+
REDIS_RATE_LIMITING = "false"
207209
FORCE_REDIS_EVENTS = "false"
208210
R2_PUBLIC_HOST = "blob.elizacloud.ai"
209211
SQL_HEAVY_PAYLOAD_STORAGE = "r2"
@@ -245,8 +247,9 @@ DATABASE_REGION = "na"
245247
PAYOUT_TESTNET = "false"
246248
ENABLE_X402_PAYMENTS = "true"
247249
X402_NETWORK = "base"
248-
CACHE_ENABLED = "true"
249-
REDIS_RATE_LIMITING = "true"
250+
CACHE_ENABLED = "false"
251+
CACHE_DISABLE_REASON = "CF Workers cross-request I/O isolation: CacheClient module-level singleton is incompatible until refactored to per-request scope"
252+
REDIS_RATE_LIMITING = "false"
250253
FORCE_REDIS_EVENTS = "false"
251254
R2_PUBLIC_HOST = "blob.elizacloud.ai"
252255
SQL_HEAVY_PAYLOAD_STORAGE = "r2"

cloud/packages/lib/auth/steward-client.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,10 +79,15 @@ export interface StewardVerifyEnv {
7979
let _jwtSecretCache: { raw: string; key: Uint8Array } | null = null;
8080

8181
function resolveJwtSecret(env: StewardVerifyEnv): Uint8Array | null {
82-
const raw = env.STEWARD_SESSION_SECRET || env.STEWARD_JWT_SECRET || "";
82+
// Mirror @stwd/auth getJwtSecret() preference order:
83+
// STEWARD_JWT_SECRET is canonical, STEWARD_SESSION_SECRET is the deprecated
84+
// backwards-compat fallback. Reading them in the wrong order causes silent
85+
// verify failures when a deployment sets both (signer uses JWT_SECRET,
86+
// verifier ends up using SESSION_SECRET). See steward-fi/auth/src/jwt.ts.
87+
const raw = env.STEWARD_JWT_SECRET || env.STEWARD_SESSION_SECRET || "";
8388

8489
if (!raw) {
85-
logger.warn("[StewardClient] No STEWARD_SESSION_SECRET or STEWARD_JWT_SECRET configured");
90+
logger.warn("[StewardClient] No STEWARD_JWT_SECRET or STEWARD_SESSION_SECRET configured");
8691
return null;
8792
}
8893

cloud/packages/lib/cache/client.ts

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -646,11 +646,22 @@ export class CacheClient {
646646
this.enabled = env.CACHE_ENABLED !== "false";
647647

648648
if (!this.enabled) {
649-
if (env.NODE_ENV === "production") {
649+
// CACHE_DISABLE_REASON acknowledges an intentional disable
650+
// (e.g. CF Workers cross-request I/O isolation incompatibility while
651+
// CacheClient remains a module-level singleton). When set, downgrade
652+
// the production log to warn so monitoring dashboards do not
653+
// alert on every cold start.
654+
const disableReason = env.CACHE_DISABLE_REASON;
655+
if (env.NODE_ENV === "production" && !disableReason) {
650656
logger.error(
651657
"🚨 [Cache] CRITICAL: Caching disabled in production! " +
652658
"This will cause severe performance degradation. " +
653-
"Set CACHE_ENABLED=true and configure Redis credentials.",
659+
"Set CACHE_ENABLED=true and configure Redis credentials, " +
660+
"or set CACHE_DISABLE_REASON to acknowledge the disable.",
661+
);
662+
} else if (disableReason) {
663+
logger.warn(
664+
`[Cache] Caching is disabled (acknowledged): ${disableReason}`,
654665
);
655666
} else {
656667
logger.warn("[Cache] Caching is disabled via CACHE_ENABLED flag");

0 commit comments

Comments
 (0)