fix(api-service): run seed script API from build folder instead of dev mode#10415
fix(api-service): run seed script API from build folder instead of dev mode#10415
Conversation
…v mode - Replace 'pnpm start:api:dev' (nest start --watch) with 'node dist/main.js' to avoid double-build restarts that caused 'fetch failed' during seeding - Add build output validation before starting the API - Copy src/.env to dist/.env when missing to ensure env config is available - Add stability checks (3 consecutive health checks) after initial readiness to confirm the API won't restart mid-seeding Co-authored-by: Paweł Tymczuk <LetItRock@users.noreply.github.com>
❌ Deploy Preview for dashboard-v2-novu-staging failed. Why did it fail? →
|
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
📝 Coding Plan
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
Hey there and thank you for opening this pull request! 👋 We require pull request titles to follow specific formatting rules and it looks like your proposed title needs to be adjusted. Your PR title is: Requirements:
Expected format: Details: PR title must end with 'fixes TICKET-ID' (e.g., 'fixes NOV-123') or include ticket ID in branch name |
What changed? Why was the change needed?
The
seed-agent-data.mjsscript was usingpnpm start:api:dev(which runsnest start --watch) to start the API server temporarily for seeding. This caused intermittent failures because the dev server triggers a double build on startup, and the API could restart mid-seeding — leading tofetch failederrors (specifically during the "set active organization" step).Changes:
pnpm start:api:devwithnode dist/main.jsto run the API directly from the pre-built output, eliminating file watching and rebuild-related restartsdist/main.jsexists and throws a clear error if the API hasn't been built yetensureDistEnvFile()to copysrc/.envtodist/.envwhen missing, since the NestJS env loader resolves.envrelative to the dist directoryScreenshots
N/A — script-only change, no visual impact.
Expand for optional sections
Special notes for your reviewer
This was identified from a cloud agent environment setup failure where the API restarted between the first and second build triggered by
nest start --watch, causing the seed to fail at the "set active organization" step. Running from the build folder avoids this entirely since there's no file watching or recompilation.Slack Thread