test: add test case to reproduce REDIS_URL config inconsistency bug (#14962)#14978
test: add test case to reproduce REDIS_URL config inconsistency bug (#14962)#14978yangbobo2021 wants to merge 1 commit intomedusajs:developfrom
Conversation
…issue-14962) This test reproduces the inconsistency where the CLI adds REDIS_URL to .env but defineConfig() does not automatically read it in non-cloud mode. The test simulates the default medusa-config.ts template and verifies that redisUrl is undefined even when REDIS_URL is set in the environment. Related Issue: medusajs#14962
|
|
Someone is attempting to deploy a commit to the medusajs Team on Vercel. A member of the Team first needs to authorize it. |
|
Thank you for your contribution! After reviewing this PR, we need a few things addressed before we can move forward: Required changes:
Notes: The test itself correctly reproduces the bug — the approach of verifying |
Summary
What — Add test case to reproduce the inconsistency between CLI behavior and
defineConfig()regardingREDIS_URL.Why — The CLI adds
REDIS_URLto the.envfile when creating a new project, but thedefineConfig()function does not automatically readREDIS_URLin non-cloud mode. This creates confusion as users expect the configuration to work automatically.How — Added a unit test
define-config.issue-14962.spec.tsthat simulates the defaultmedusa-config.tstemplate withREDIS_URLset in the environment, and verifies thatredisUrlremainsundefinedin the config.Testing — Run the test to verify the bug:
```bash
cd packages/core/utils
npx jest src/common/tests/define-config.issue-14962.spec.ts
```
Root Cause
The issue is in
packages/core/utils/src/common/define-config.ts:417:```typescript
...(isCloud ? { redisUrl: process.env.REDIS_URL } : {}),
```
The
REDIS_URLis only read whenisCloudis true. For regular projects, it's ignored.Suggested Fix
Option A: Make
defineConfig()always readREDIS_URL(recommended)```typescript
redisUrl: process.env.REDIS_URL,
```
Option B: Remove
REDIS_URLfrom CLI's.envtemplateRelated Issue: #14962
Would you like me to submit a separate PR with the fix for this issue?