CI/CD Troubleshooting Guide
Overview
This guide documents common CI/CD issues, their root causes, and solutions based on recent fixes to the Hyperscape build pipeline.Database Migration Issues
Issue: Migration 0050 Duplicate Table Errors
Symptom:- Migration 0050 duplicated CREATE TABLE statements from earlier migrations
- Example:
agent_duel_statswas created in migration 0039 and again in 0050 - On fresh databases, running all migrations sequentially caused duplicate table errors
IF NOT EXISTS to all CREATE TABLE and CREATE INDEX statements in migration 0050:
- Always use
IF NOT EXISTSfor CREATE TABLE in migrations - Check migration history before adding new tables
- Test migrations on fresh database before committing
Issue: FK Ordering in Sequential Migrations
Symptom:- Migration 0050 references tables from older migrations (e.g., arena_rounds)
- On fresh databases, FK constraints may fail if tables aren’t created in dependency order
- Sequential migration execution doesn’t guarantee FK ordering
drizzle-kit push for declarative schema creation + SKIP_MIGRATIONS=true:
drizzle-kit pushcreates schema declaratively (no ordering issues)SKIP_MIGRATIONS=truetells server to skip built-in migration execution- Server starts with pre-created schema
Issue: drizzle-kit push + Server Migration Conflict
Symptom:- Running
drizzle-kit pushcreates tables without populating migration journal - Server’s built-in migration code tries to create tables again
- Results in duplicate table errors
drizzle-kit push separately in CI. Let server handle migrations:
SKIP_MIGRATIONS Environment Variable
Purpose: Skip server migration when schema is created externally When to Use:- CI/testing environments using
drizzle-kit push - External schema management tools
- Integration tests that create schema before server startup
- Built-in migration execution
hasRequiredPublicTablesvalidation check- Migration recovery loop
SKIP_MIGRATIONS=true.
Example:
Dependency Issues
Issue: ESLint ajv TypeError
Symptom:- Root package.json forced ajv@8 via overrides
- @eslint/eslintrc requires ajv@6 for Draft-04 schema support
- Version conflict caused constructor chain to break
- Don’t force major version upgrades via overrides
- Check package peer dependencies before overriding
- Test ESLint after adding overrides
Issue: Missing hls.js Dependency
Symptom:- StreamPlayer.tsx imports hls.js but it was not declared in package.json
- Works locally due to workspace hoisting
- Fails in CI where bun resolves dependencies strictly
- Run
bun install --frozen-lockfileto catch missing deps - Test builds in clean environment (Docker)
- Use
bun run buildbefore committing
Issue: Foundry/Anvil Not Available in CI
Symptom:- Integration tests require anvil binary for local Ethereum node
- Foundry toolchain not installed in CI environment
Package Exclusions
Excluded from CI Tests
Packages:@hyperscape/contracts(commit 99dec96)@hyperscape/gold-betting-demo(commit 93f9633)@hyperscape/evm-contracts(commit 034f9c9)
contracts: MUD CLI + @trpc/server compatibility issuegold-betting-demo: hls.js dependency resolution issue (fixed in cfdabf3, but still excluded)evm-contracts: Foundry/anvil not available in CI
Chain Setup Issues
Issue: Chain Setup Fails in CI
Symptom:setup-chain.mjstries to start anvil and deploy MUD contracts- Anvil binary not available in CI environment
- MUD CLI has compatibility issues
CI=true:
Asset Management
Issue: Assets Directory Already Exists
Symptom:- CI workflow clones assets repo
- Previous run left assets directory
- Git clone fails on non-empty directory
- Always clean up in CI workflows
- Use
rm -rfbefore git clone - Consider using
git clone --depth 1for faster clones
Security Audit
Issue: Build Fails on High Severity Vulnerabilities
Symptom:- bigint-buffer has high severity vulnerability
- No upstream patch available
- CI audit threshold set to
high
critical:
- Allows builds to pass while waiting for upstream fixes
- Critical vulnerabilities still block builds
- High/moderate vulnerabilities logged but don’t fail CI
- bigint-buffer (high) - no patched version available
- elliptic (moderate) - no patched version available
Recent Security Fixes (commit a390b79)
Resolved:- ✅ Playwright ^1.55.1 (fixes GHSA-7mvr-c777-76hp, high)
- ✅ Vite ^6.4.1 (fixes GHSA-g4jq-h2w9-997c, GHSA-jqfw-vq24-v9c3, GHSA-93m4-6634-74q7)
- ✅ ajv ^8.18.0 (fixes GHSA-2g4f-4pwh-qvx6)
- ✅ Root overrides for: @trpc/server, minimatch, cookie, undici, jsondiffpatch, tmp, diff, bn.js, ai
Documentation Updates
Issue: Mintlify API Failures Block CI
Symptom:- Mintlify service outages
- API rate limits
- Network issues
continue-on-error to docs update step:
- Documentation updates are not critical for build success
- Allows CI to continue even if docs API is down
- Docs can be updated manually if needed
Build Resilience
Issue: Circular Dependencies Break Clean Builds
Symptom:- Circular dependencies between packages
@hyperscape/sharedimports from@hyperscape/procgen@hyperscape/procgenpeer-depends on@hyperscape/shared- When turbo runs clean build, tsc fails because the other package’s dist/ doesn’t exist yet
tsc || echo pattern for resilient builds:
- Build exits 0 even with circular dep errors
- Packages produce partial output sufficient for downstream consumers
- Turbo can continue build pipeline
- Avoid circular dependencies when possible
- Use peer dependencies carefully
- Test clean builds:
bun run clean && bun run build
TypeScript Errors
Issue: Type Errors Block CI
Symptom:- Type mismatches after refactoring
- Missing type casts
- Private methods called from tests
Test Infrastructure
WebGPU Mocks for Three.js
Issue: Three.js WebGPU renderer requires browser globals Symptom:vitest.setup.ts with WebGPU mocks:
ArenaService Test Helpers
Issue: Cannot spy on private methods Solution (commit 25ba63c): Add protected passthrough methods:Streaming Infrastructure
Issue: WebGPU Crashes on RTX 5060 Ti
Symptom:- RTX 5060 Ti has broken Vulkan ICD on Vast.ai
- WebGPU defaults to Vulkan backend
- Vulkan initialization crashes Chrome
Issue: RTX 4090 WebGPU Performance
Symptom:- WebGPU works but performance is suboptimal
- GL backend used instead of Vulkan
Issue: Static FFmpeg Build SIGSEGV
Symptom:- Static FFmpeg builds have compatibility issues
- SIGSEGV during H.264 encoding
Vast.ai Deployment
Issue: vastai CLI Not on PATH
Symptom:- vastai installed via pip but not on PATH
- Python venv not activated
Issue: Python Version Too Old
Symptom:- Debian bullseye-slim has Python 3.9
- vastai-sdk requires Python 3.10+
Issue: PEP 668 Externally Managed Environment
Symptom:- Debian 12 enforces PEP 668
- System Python is externally managed
- pip install blocked by default
--break-system-packages flag:
Playwright Issues
Issue: Chromium Not Installed
Symptom:- Playwright browsers not installed
- CI environment missing browser binaries
Docker Issues
Issue: DNS Resolution Fails in Container
Symptom:- Container DNS not configured
- Default resolv.conf doesn’t work
> for first line (overwrite), >> for subsequent lines (append)
Issue: Build Context Too Large
Symptom:.dockerignore:
CI Workflow Best Practices
Graceful Degradation
Principle: Non-critical steps should not fail the entire build Examples: Documentation Updates:Conditional Execution
Skip Steps in CI:Caching Strategies
Bun Dependencies:Debugging CI Failures
Enable Debug Logging
GitHub Actions:Reproduce Locally
Use CI Environment:Inspect Artifacts
Save Logs:Common Error Patterns
Pattern: “Cannot find module”
Causes:- Missing dependency in package.json
- Incorrect import path
- Build order issue (dependency not built yet)
- Add to dependencies:
bun add <package> - Fix import path
- Check turbo.json dependsOn
Pattern: “ECONNREFUSED”
Causes:- Service not started
- Wrong port
- Service crashed
- Check service startup logs
- Verify port in .env
- Check for port conflicts:
lsof -ti:5555
Pattern: “Timeout”
Causes:- Service slow to start
- Network latency
- Deadlock
- Increase timeout
- Add retry logic
- Check for circular waits
Monitoring & Alerts
CI Failure Notifications
Slack Integration:Health Checks
Server Health Endpoint:Performance Optimization
Parallel Builds
Turbo Configuration:- Builds packages in parallel when possible
- Respects dependency order
- Caches outputs for incremental builds
Incremental Testing
Run Only Changed Tests:Rollback Procedures
Revert Failed Deployment
Railway:Database Rollback
Drizzle Migrations:References
- Commit e4b6489: Migration 0050 IF NOT EXISTS fix
- Commit eb8652a: drizzle-kit push + SKIP_MIGRATIONS
- Commit b344d9e: ESLint ajv fix + Foundry toolchain
- Commit 25ba63c: WebGPU mocks + test helpers
- Commit 034f9c9: Chain setup skip + docs continue-on-error
- Commit 5666ece: Circular dependency resilience
- Commit a390b79: Security audit fixes
- CI Workflows:
.github/workflows/