Skip to content

fix: close sockets without synthetic error#577

Open
Haihan-Jiang wants to merge 1 commit into
GoogleCloudPlatform:mainfrom
Haihan-Jiang:codex/cloud-sql-close-destroy-without-error
Open

fix: close sockets without synthetic error#577
Haihan-Jiang wants to merge 1 commit into
GoogleCloudPlatform:mainfrom
Haihan-Jiang:codex/cloud-sql-close-destroy-without-error

Conversation

@Haihan-Jiang
Copy link
Copy Markdown

Change Description

Fixes #576.

CloudSQLInstance.close() still destroys every tracked socket so shutdown can clean up active handles, but it no longer passes a synthetic CloudSQLConnectorError into socket.destroy(). Passing that error causes Node to emit an asynchronous socket error event; after drivers such as pg have drained a pool and removed socket listeners, that event can become an uncaught exception during intentional connector shutdown.

The added unit test verifies close-time socket teardown calls destroy() without an error argument.

Checklist

  • Make sure to open an issue as a bug/issue before writing your code
  • Ensure the tests and linter pass
  • Appropriate documentation is updated (not necessary)

Validation

  • npx tap -t0 -c test/cloud-sql-instance.ts
  • npm run lint
  • npm run compile
  • npm test

@Haihan-Jiang Haihan-Jiang marked this pull request as ready for review May 23, 2026 23:49
@Haihan-Jiang Haihan-Jiang requested a review from a team as a code owner May 23, 2026 23:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CloudSQLInstance.close() calls socket.destroy(err) after connection pool drain, causing unhandled 'error' event and process crash

2 participants