Proposal: handle SIGTERM by default to initiate graceful worker shutdown
Maintainers usually reply within 1 day
@eamsden is already working on this.
Since Oct 8, 2026.
Assessment
This issue has not been assessed yet.
Description
Summary
A Temporal Java worker installs no graceful-shutdown signal handling by default. The JVM runs shutdown hooks on SIGTERM, but the SDK registers none that drain the worker, so a bare worker exits without stopping polling or draining in-flight work. In-flight activities are abandoned and retried server-side after their timeouts.
Proposal: consider a built-in option to initiate WorkerFactory shutdown on SIGTERM by default (opt-out-able), so the common containerized case — stop polling → drain → cancel — works without extra wiring.
Current workaround
A JVM shutdown hook calling WorkerFactory.shutdown() → awaitTermination(timeout) → shutdownNow() (plus WorkerOptions.setAllowActivityHeartbeatDuringShutdown(true) to let a heartbeating activity finish during the drain); or run under the Spring Boot starter, which wires it.
Precedent
The TypeScript SDK already does this: its Runtime installs handlers for SIGINT/SIGTERM/SIGQUIT/SIGUSR2 by default and calls shutdown() on every worker.
Trade-offs / open questions (why it is not already the default)
- A worker usually runs inside a larger process (HTTP server, DI host, other lifecycle). A library installing a process-global signal handler can conflict with the host application's own signal handling, so any default must be clearly opt-out-able and should no-op when a host framework already owns the signal.
- Default-on vs. an explicit opt-in flag?
- If added, match the TypeScript semantics and honor the existing grace/drain config.
Why this comes up
SIGTERM-before-SIGKILL is the standard stop protocol for Kubernetes, Cloud Run, ECS, docker stop, and systemd. Users commonly expect a worker to drain on SIGTERM without extra wiring, and it is a recurring support question (e.g. https://community.temporal.io/t/proper-way-to-shutdown-on-sigterm-sigint/5485).
Related: #2026.
One of a set of sibling issues on default SIGTERM handling across the SDKs that do not auto-handle it today (Go, Python, Java, .NET, Ruby, Rust). TypeScript already does; PHP delegates process lifecycle to RoadRunner.
- Dominant language
- Java
- Stars
- 434
- Forks
- 260
- Avg merge
- 2d 11h
- Merged PRs (30d)
- 19
Getting set up
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from temporalio/sdk-java
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
temporalio/sdk-java#3134 ·
Maintainers usually reply within 1 day
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
temporalio/sdk-java#1825 ·
Maintainers usually reply within 1 day
-
enhancement
Difficulty 4/5 3-5 days Newbie friendliness 54/100
temporalio/sdk-java#3125 · 2 comments ·
Maintainers usually reply within 1 day
-
enhancement
Difficulty 3/5 1-2 days Newbie friendliness 55/100
temporalio/sdk-java#3124 ·
Maintainers usually reply within 1 day
-
enhancement
Difficulty 5/5 Over a week Newbie friendliness 35/100
temporalio/sdk-java#3122 ·
Maintainers usually reply within 1 day
All issues in temporalio/sdk-java
Similar issues
-
`RedisList.reversed()` view returns an empty `range` and `trim` removes all elementsPossibly taken @CCCLL claimed this today. Openstatus: waiting-for-triage
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
spring-projects/spring-data-redis#3461 ·
Maintainers usually reply within 2 days
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
devops-thiago/ThrillhouseBot#1093 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 67/100
wimdeblauwe/htmx-spring-boot#205 ·
-
[BUG] 增量 SSE 解析器未识别单独 CR 换行,导致事件无法及时交付Possibly taken @king-wwwhhh claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
langchain4j/langchain4j#6669 ·
Maintainers usually reply within 1 day
-
enhancement tech-debt
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Albertinesilva/backend-engineering-journey-java-springboot#41 ·