Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

spanner: requiring @google-cloud/spanner stops the process from exiting on SIGTERM/SIGINT

Aperta Adatta ai principianti
#9,513 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
78/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
nodejs, typescript
Ambito
backend

Direzione di ricerca

Inizia da handwritten/spanner/src/index.ts, dove vengono registrati i listener SIGINT e SIGTERM, ed esegui la riproduzione minima collegata con npm install && npm test. Conferma il comportamento del processo con e senza @google-cloud/spanner; il lavoro è completo quando il caricamento della libreria non impedisce più il comportamento previsto di arresto in seguito a un segnale.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

api: spanner
Please make sure you have searched for information in the following guides.
Library Name

@google-cloud/spanner

A screenshot that you have tested with "Try this API".

Not API related

Link to the code that reproduces this issue. A link to a public Github Repository or gist with a minimal reproduction.

https://gist.github.com/wildan2711/1630361a07bd531792be280519d8e3fa

A step-by-step description of how to reproduce the issue, based on the linked reproduction.

Runnable reproduction: https://gist.github.com/wildan2711/1630361a07bd531792be280519d8e3fa (npm install && npm test)

Minimal version:

// repro.js
require('@google-cloud/spanner');
console.log('SIGTERM listeners:', process.listenerCount('SIGTERM'));
setInterval(() => {}, 1000); // anything that keeps the event loop alive, e.g. an HTTP server
node repro.js &
kill -TERM $!   # process keeps running
kill -INT  $!   # still running; only SIGKILL stops it

Remove the require line and the same script exits on SIGTERM as expected.

A clear and concise description of what the bug is, and what you expected to happen.

Requiring @google-cloud/spanner makes a long-running Node.js process ignore SIGTERM and SIGINT. When the module loads, it registers process.on('SIGINT') and process.on('SIGTERM') listeners in handwritten/spanner/src/index.ts that run the metrics cleanup() but never exit or re-raise the signal. The process then keeps running until it gets SIGKILL. This applies even if no Spanner client is ever created. In practice, Cloud Run, GKE and App Engine instances run until the end of the shutdown grace period instead of stopping, docker stop and process managers leave orphaned processes holding their ports, and Ctrl+C doesn't stop a dev server.

Expected: loading the library doesn't change how the process responds to signals. A process that would exit on SIGTERM or SIGINT without @google-cloud/spanner should still exit with it.

A clear and concise description WHY you expect this behavior, i.e., was it a recent change, there is documentation that points to this behavior, etc. **
  • It's a regression. 8.0.0 registers no signal listeners and the process exits normally. The listeners first appear in 8.1.0 and are still present in 9.0.0 and on main. We noticed when upgrading from 6.x to 8.6.0: our services stopped shutting down on SIGTERM.
  • Node.js documents this effect. Per the signal events docs, "SIGTERM and SIGINT have default handlers on non-Windows platforms that reset the terminal mode before exiting with code 128 + signal number. If one of these signals has a listener installed, its default behavior will be removed (Node.js will no longer exit)." So any listener that doesn't exit stops the process from shutting down.
  • The code's own comment says the process should exit. It reads // For signals (let process exit naturally), which shows the listeners were meant to flush metrics without blocking shutdown. But a process with an open server, socket or timer never exits "naturally", so in practice they block it.
  • Libraries generally shouldn't own process signals. Shutdown on SIGTERM and SIGINT belongs to the application or its framework, which may need its own graceful-shutdown logic. A dependency that silently disables the default makes that impossible to see, and the only workaround is removing the listeners by hand.
Lingua principale
TypeScript
Stelle
3.2k
Fork
721
Merge medio
3g 7h
PR unite (30g)
149

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di googleapis/google-cloud-node

Tutte le issue di googleapis/google-cloud-node

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.