You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* fix: avoid throwing error if process variable is not defined in the default client
* fix: improve error message for when env is missing in cloudflare
---------
Co-authored-by: CahidArda <[email protected]>
// @ts-expect-error These will be defined by cloudflare
138
+
(typeofUPSTASH_REDIS_REST_TOKEN==="string"
139
+
? // @ts-expect-error These will be defined by cloudflare
140
+
UPSTASH_REDIS_REST_TOKEN
141
+
: undefined);
132
142
133
-
if(!url){
134
-
console.warn(
135
-
"[Upstash Redis] Unable to find environment variable: `UPSTASH_REDIS_REST_URL`. Please add it via `wrangler secret put UPSTASH_REDIS_REST_URL`"
136
-
);
137
-
}
138
-
if(!token){
143
+
constmessageInfo=
144
+
!url&&!token
145
+
? "Unable to find environment variables: `UPSTASH_REDIS_REST_URL` and `UPSTASH_REDIS_REST_TOKEN`"
146
+
: url
147
+
? token
148
+
? undefined
149
+
: "Unable to find environment variable: `UPSTASH_REDIS_REST_TOKEN`"
150
+
: "Unable to find environment variable: `UPSTASH_REDIS_REST_URL`";
151
+
152
+
if(messageInfo){
139
153
console.warn(
140
-
"[Upstash Redis] Unable to find environment variable: `UPSTASH_REDIS_REST_TOKEN`. Please add it via `wrangler secret put UPSTASH_REDIS_REST_TOKEN`"
154
+
`[Upstash Redis] ${messageInfo}. Please add it via \`wrangler secret put ${url ? "UPSTASH_REDIS_REST_TOKEN" : "UPSTASH_REDIS_REST_URL"}\` and provide it as an argument to the \`Redis.fromEnv\` function`
'[Upstash Redis] Unable to get environment variables, `process.env` is undefined. If you are deploying to cloudflare, please import from "@upstash/redis/cloudflare" instead'
0 commit comments