Root cause: When mpc-service restarts, the old Kafka consumer doesn't properly disconnect, causing the broker to wait for sessionTimeout (~5 minutes) before completing rebalance. This blocks app startup. Solution: Enable NestJS shutdown hooks with app.enableShutdownHooks(). This ensures onModuleDestroy() is called on SIGTERM/SIGINT, which calls consumer.disconnect() and allows immediate rebalance on next startup. Also reverted the "don't await consumer.run()" workaround since the proper fix is graceful shutdown. Sources: - https://github.com/tulios/kafkajs/issues/807 - https://kafka.js.org/docs/consuming 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> |
||
|---|---|---|
| .. | ||
| config | ||
| docs | ||
| prisma | ||
| src | ||
| tests | ||
| .env.example | ||
| .gitignore | ||
| Context(微服务)架构.jpg | ||
| Dockerfile | ||
| MPC-Service-Context-Complete-Specification.md | ||
| deploy.sh | ||
| docker-compose.yml | ||
| docker-entrypoint.sh | ||
| nest-cli.json | ||
| package-lock.json | ||
| package.json | ||
| tsconfig.json | ||
| 项目目录架构.jpg | ||