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

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
@Haihan-Jiang

Copy link
Copy Markdown
Author

This is ready for review from my side. The remaining integration-test-pr checks appear to require project-side approval/run permissions; could someone take a look or trigger them when convenient?

@Haihan-Jiang
Haihan-Jiang force-pushed the codex/cloud-sql-close-destroy-without-error branch from 1f7f62a to 42bf85b Compare June 7, 2026 23:50
@Haihan-Jiang

Copy link
Copy Markdown
Author

I rebased this on the latest main and resolved the conflict in src/cloud-sql-instance.ts.

I kept the close path from passing a synthetic error into socket.destroy(), and updated the unit test setup to use a domain-backed instance so the tracked-socket path is exercised.

Validation:

  • npm test -- test/cloud-sql-instance.ts
  • npm run compile
  • npm run lint

The latest head is 42bf85b; GitHub shows the commit signature as valid.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants