You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit be66a84
Browse filesBrowse the repository at this point in the historyBrowse files
## Summary
Hardens the `worker_threads` cluster lifecycle on top of the bundle and
startup-snapshot support merged in #6042:
- add an explicit master-to-worker graceful-exit message instead of
attempting asynchronous cleanup from the worker `exit` event;
- wait for app/agent cleanup and fall back to `Worker.terminate()` after
the configured timeout;
- consume and log worker `error` events during graceful shutdown, then
continue with the termination fallback without exposing an unhandled
EventEmitter error;
- reject `sticky: true` with `startMode: worker_threads`, because sticky
socket handoff requires process IPC;
- preserve the existing master-port and `reusePort` listen semantics,
with focused server-error and hostname regression coverage.
## Why
A worker thread's `exit` event is emitted after the thread has already
stopped, so cleanup cannot reliably be initiated from that event. The
new protocol asks the worker to close while it is still alive and keeps
forced termination as a bounded fallback.
Sticky mode is rejected explicitly because its socket handoff mechanism
is only available to process workers.
## Validation
- `ut run test --workspace @eggjs/cluster --
test/worker-thread-utils.test.ts test/worker-protocol.test.ts
test/worker-protocol-io.test.ts` — 24 passed
- `vitest run test/options.test.ts -t 'should reject sticky mode with
worker_threads'` — 1 passed
- `ut run typecheck --workspace @eggjs/cluster` — passed
The full cross-platform suite is covered by CI.
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit
* **New Features**
* Worker threads now wait for application and agent cleanup to finish
during shutdown.
* If cleanup fails or exceeds the configured timeout, workers are
terminated.
* **Bug Fixes**
* Workers are no longer started or restarted after shutdown begins.
* Sticky-session mode now rejects unsupported worker-thread
configurations.
* Workers use the application’s configured port when the master port is
set to zero.
* **Documentation**
* Clarified worker-thread shutdown behavior and supported startup
configurations.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
---------
Co-authored-by: killagu <killa07071201@gmail.com>
0 commit comments