Skip to content

Harden yjs container readiness and shutdown behavior - #3247

Merged
AlexAndBear merged 3 commits into
mainfrom
feat/yjs-production-grade-service
Sep 1, 2026
Merged

AlexAndBear merged 3 commits into
mainfrom
feat/yjs-production-grade-service

Conversation

@AlexAndBear

@AlexAndBear AlexAndBear commented Aug 27, 2026 •

Copy link
Copy Markdown
Member

Description

This change upgrades the services/yjs container behavior for production-style operation.

It adds:

  • container image HEALTHCHECK based on actual readiness (/healthz/ready) and WebSocket reachability
  • graceful signal handling (SIGTERM/SIGINT/SIGQUIT) with a documented grace period
  • shutdown draining behavior: readiness flips to unhealthy, new upgrades are rejected, then active connections are closed and document unload/flush paths run
  • compose-level stop_grace_period for yjs, aligned with graceful shutdown behavior
  • administrator documentation for restart policy, grace period, health semantics, and logging

Related Issue

How Has This Been Tested?

  • test environment: local development on macOS
  • test case 1: pnpm --filter opencloud-yjs-server check:types
  • test case 2: pnpm exec eslint services/yjs/src/server.ts services/yjs/src/healthcheck.ts
  • test case 3: pnpm exec prettier --check services/yjs/src/server.ts services/yjs/src/healthcheck.ts services/yjs/README.md docker-compose.yml
  • test case 4: docker compose config >/tmp/docker-compose.resolved.yml

Types of changes

  • Bugfix
  • Enhancement (a change that does not break existing code or deployments)
  • Breaking change (a modification that affects current functionality)
  • Technical debt (addressing code that needs refactoring or improvements)
  • Tests (adding or improving tests)
  • Documentation (updates or additions to documentation)
  • Maintenance (like dependency updates or tooling adjustments)

@AlexAndBear AlexAndBear self-assigned this Aug 27, 2026
@AlexAndBear
AlexAndBear force-pushed the feat/yjs-production-grade-service branch from 8cd0eca to fcfa099 Compare August 27, 2026 13:23
@AlexAndBear
AlexAndBear force-pushed the feat/yjs-production-grade-service branch from fcfa099 to a926a8f Compare August 29, 2026 15:47
@AlexAndBear
AlexAndBear requested review from JammingBen and kulmann and a lite review from Copilot August 31, 2026 11:53

This comment was marked as outdated.

@AlexAndBear
AlexAndBear force-pushed the feat/yjs-production-grade-service branch from 617bb8a to 94485f0 Compare August 31, 2026 13:04
Comment thread services/yjs/src/server.ts Outdated
Comment thread services/yjs/Dockerfile Outdated
@AlexAndBear
AlexAndBear force-pushed the feat/yjs-production-grade-service branch from 0d5cd8d to a79b14d Compare August 31, 2026 14:58

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

馃煛 Changes recommended

There is a shutdown-grace configuration edge case that can produce unreliable shutdown behavior, and the PR description currently claims Compose health-gating changes that aren鈥檛 present in the diff.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Review details

Suppressed comments (1)

services/yjs/src/server.ts:6

  • SHUTDOWN_GRACE_PERIOD_MS is parsed without validation. If the env var is unset/mistyped (e.g. "15s"), parseInt can yield NaN or a non-positive value, which makes the grace timer behavior unpredictable (including an immediate forced exit). Validate and fail fast (or clamp to a safe default) so shutdown semantics are reliable.
const SHUTDOWN_GRACE_PERIOD_MS = parseInt(process.env.SHUTDOWN_GRACE_PERIOD_MS ?? '15000', 10)
  • Files reviewed: 5/5 changed files
  • Comments generated: 1
  • Review effort level: Lite

Comment thread docker-compose.yml
@AlexAndBear
AlexAndBear merged commit 3bbd399 into main Sep 1, 2026
31 checks passed
@AlexAndBear
AlexAndBear deleted the feat/yjs-production-grade-service branch September 1, 2026 07:12
@openclouders openclouders mentioned this pull request Sep 1, 2026
1 task
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants