googleapis / google-cloud-node

Google Cloud Client Library for Node.js
https://cloud.google.com/nodejs
Apache License 2.0
2.9k stars 590 forks source link

SIGABRT when using `@google-cloud/resource-manager`, with trace events, and doing a `process.exit(0)` #4384

Open Stono opened 1 year ago

Stono commented 1 year ago

Environment details

Steps to reproduce

If you use the google-cloud/resource-manager and then also implement shutdown hooks within your application that gracefully stop things like a webserver, before doing a process.exit(0); then you end up with a SIGABRT:

❯ NODE_OPTIONS="--trace-events-enabled --trace-event-categories v8" node test.js
hi
hi
hi
hi
hi
^C[1]    55453 abort      NODE_OPTIONS="--trace-events-enabled --trace-event-categories v8" node test.j

This code reproduces the issue:

const Crm = require('@google-cloud/resource-manager')
const client = new Crm.ProjectsClient()

const interval = setInterval(() => {
  console.log('hi')
}, 500)

const shutdown = () => {
  process.exit(0)
}
process.on('SIGINT', shutdown)
process.on('SIGTERM', shutdown)
Stono commented 1 year ago

I've also raised https://github.com/nodejs/node/issues/48598; which could be related