Skip to content

Commit 3f07188

Browse files
committed
Fix catalog service startup race condition
- Use npm run dev instead of npx nodemon to ensure local dependencies - Add dependency installation check in automations - Configure nodemon to properly use ts-node - Add nodemon configuration in package.json
1 parent cbf482b commit 3f07188

File tree

2 files changed

+29
-4
lines changed

2 files changed

+29
-4
lines changed

.gitpod/automations.yaml

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,27 @@ services:
4747
commands:
4848
start: |
4949
cd /workspaces/gitpodflix-demo/backend/catalog
50-
PORT=3001 npx nodemon src/index.ts
50+
51+
# Ensure dependencies are installed
52+
echo "Ensuring dependencies are installed..."
53+
npm install
54+
55+
# Wait for ts-node to be available
56+
echo "Waiting for ts-node to be available..."
57+
for i in {1..30}; do
58+
if [ -f "node_modules/.bin/ts-node" ]; then
59+
echo "✓ ts-node is available"
60+
break
61+
fi
62+
if [ $i -eq 30 ]; then
63+
echo "✗ Timeout waiting for ts-node"
64+
exit 1
65+
fi
66+
echo "Waiting for ts-node... attempt $i/30"
67+
sleep 1
68+
done
69+
70+
PORT=3001 npm run dev
5171
ready: |
5272
if curl -s http://localhost:3001/health > /dev/null; then
5373
echo "Catalog service is ready"

backend/catalog/package.json

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"main": "src/index.ts",
66
"scripts": {
77
"start": "ts-node src/index.ts",
8-
"dev": "nodemon src/index.ts",
8+
"dev": "nodemon --exec ts-node src/index.ts",
99
"build": "tsc",
1010
"test": "jest",
1111
"setup": "./scripts/setup.sh"
@@ -26,6 +26,11 @@
2626
"nodemon": "^3.0.2",
2727
"jest": "^29.7.0",
2828
"@types/jest": "^29.5.11",
29-
"ts-jest": "^29.1.1"
29+
"ts-jest": "^29.1.1"
30+
},
31+
"nodemonConfig": {
32+
"watch": ["src"],
33+
"ext": "ts,json",
34+
"exec": "ts-node src/index.ts"
3035
}
31-
}
36+
}

0 commit comments

Comments
 (0)