Production server doesn't handle SIGTERM

Open Beginner friendly
#4,588 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
70/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Active
Tech stack
kubernetes, node.js, typescript
Domain
backend, devops

Research direction

Find the startProdServer implementation and trace how it returns the server; compare it with the signal handling in next start and the standalone server.js mentioned in the issue. Add SIGTERM and SIGINT handling that closes the returned server and lets in-flight requests finish. Confirm both signals trigger graceful shutdown without dropping active requests.

Written by the indexing model from the issue text.

Description

next start and Next's standalone server.js close the server on SIGTERM/SIGINT and let in-flight requests finish. startProdServer doesn't register any signal handlers, so on Kubernetes Node either dies right away and drops in-flight requests, or, running as PID 1, ignores SIGTERM until it's SIGKILLed at the end of the grace period.

We work around it with our own entry that calls startProdServer and closes the returned server on both signals. Would be nice to have it built in like Next.

Dominant language
TypeScript
Stars
9.3k
Forks
463
Avg merge
22h 22m
Merged PRs (30d)
502

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from cloudflare/vinext

All issues in cloudflare/vinext

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.