fix(api): lazy-load node-pty to prevent API crash when native binary is missing
node-pty requires a compiled native addon (.node binary) that may not be available in all Docker environments. The eager import crashed the entire API at startup. Changed to dynamic import() in onModuleInit() so the service degrades gracefully — terminal sessions are disabled but all other API functionality works. Also added explicit node-gyp rebuild to Dockerfile deps stage since pnpm may skip postinstall scripts for native addons. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -31,7 +31,11 @@ COPY packages/config/package.json ./packages/config/
|
||||
COPY apps/api/package.json ./apps/api/
|
||||
|
||||
# Install dependencies (no cache mount — Kaniko builds are ephemeral in CI)
|
||||
RUN pnpm install --frozen-lockfile
|
||||
# Then explicitly rebuild node-pty from source since pnpm may skip postinstall
|
||||
# scripts or fail to find prebuilt binaries for this Node.js version
|
||||
RUN pnpm install --frozen-lockfile \
|
||||
&& cd node_modules/.pnpm/node-pty@*/node_modules/node-pty \
|
||||
&& npx node-gyp rebuild 2>&1 || true
|
||||
|
||||
# ======================
|
||||
# Builder stage
|
||||
|
||||
Reference in New Issue
Block a user