spanner: requiring @google-cloud/spanner stops the process from exiting on SIGTERM/SIGINT
Maintainer thường phản hồi trong vòng 1 ngày
@alkatrivedi đang làm issue này rồi.
Từ ngày 13/10/2026.
Đánh giá
- Độ khó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức phù hợp với người mới
- 78/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- nodejs, typescript
- Lĩnh vực
- backend
Hướng nghiên cứu
Bắt đầu với handwritten/spanner/src/index.ts, nơi các listener SIGINT và SIGTERM được đăng ký, rồi chạy bản tái hiện tối thiểu được liên kết bằng npm install && npm test. Xác nhận hành vi của tiến trình khi có và không có @google-cloud/spanner; được xem là hoàn tất khi việc tải thư viện không còn ngăn cản hành vi tắt tiến trình do tín hiệu như mong đợi.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Please make sure you have searched for information in the following guides.
- Search the issues already opened: https://github.com/GoogleCloudPlatform/google-cloud-node/issues
- Search StackOverflow: http://stackoverflow.com/questions/tagged/google-cloud-platform+node.js
- Check our Troubleshooting guide: https://github.com/googleapis/google-cloud-node/blob/main/docs/troubleshooting.md
- Check our FAQ: https://github.com/googleapis/google-cloud-node/blob/main/docs/faq.md
- Check our libraries HOW-TO: https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md
- Check out our authentication guide: https://github.com/googleapis/google-auth-library-nodejs
- Check out handwritten samples for many of our APIs: https://github.com/GoogleCloudPlatform/nodejs-docs-samples
- Check the API's issue tracker: https://cloud.google.com/support/docs/issue-trackers
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.
- Ngôn ngữ chính
- TypeScript
- Star
- 3.2k
- Fork
- 724
- Merge trung bình
- 1 ngày 23 giờ
- Pull request đã merge (30 ngày)
- 141
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của googleapis/google-cloud-node
-
google-auth-library: JWT with a JSON keyFile signs without iss since 10.6.1 (invalid_grant: account not found)Có thể đã có người làm @Marinski đã nhận 20 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 85/100
googleapis/google-cloud-node#9469 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
priority: p1 samples type: bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
googleapis/google-cloud-node#9367 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug(gapic-node-processing): setOnlyDefaultSystemTests incorrectly matches substring on absolute pathCó thể đã có người làm @rootkiller6788 đã nhận 14 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
googleapis/google-cloud-node#9342 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
TransferManager uploadFileInChunks does not error when abortedCó thể đã có người làm @Om-singhaI đã nhận 58 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
googleapis/google-cloud-node#9193 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
google-auth-library: getErrorFromOAuthErrorResponse() copies stack as non-writable, breaking error decoration in consumersCó thể đã có người làm @Om-singhaI đã nhận 58 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100
googleapis/google-cloud-node#9155 ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của googleapis/google-cloud-node
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
simkimsia/netlify-axi#19 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
subhranshudash13-dotcom/Contribo#74 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
enhancement frontend good first issue Stellar Wave trivial
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
Godgift-care/sci-healthcare-frontend#166 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
backend good first issue security Stellar Wave trivial
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
Godgift-care/sci-healthcare-backend#171 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày