Skip to content

fix(watch): fix pool leak on unexpected connection termination#711

Merged
benjie merged 1 commit intov4from
pool-leak
Jan 29, 2021
Merged

fix(watch): fix pool leak on unexpected connection termination#711
benjie merged 1 commit intov4from
pool-leak

Conversation

@benjie
Copy link
Copy Markdown
Member

@benjie benjie commented Jan 29, 2021

Description

The Client is already cleaned up comment was incorrect; this fixes the release behaviour on error.

  • _handleChange is now only cancelled in stop(); it doesn't seem to be necessary to cancel it in error handler
  • When releasing the client, you can pass false to prevent issuing the unlisten call; this is risky as it may leak event listeners.

Need to be sure that client.on('error', ...) only fires when the client connection is closed... I'm not sure if this is the case, may need to dig through the pg source code to find out.

Fixes #710

Performance impact

None.

Security impact

Fixes a potential denial of service issue with watch mode (note that watch mode is still not recommended for production).

Checklist

  • My code matches the project's code style and yarn lint:fix passes.
  • I've added tests for the new feature, and yarn test passes.
  • I have detailed the new feature in the relevant documentation.
  • I have added this feature to 'Pending' in the RELEASE_NOTES.md file (if one exists).
  • If this is a breaking change I've explained why.

@benjie
Copy link
Copy Markdown
Member Author

benjie commented Jan 29, 2021

Need to be sure that client.on('error', ...) only fires when the client connection is closed... I'm not sure if this is the case, may need to dig through the pg source code to find out.

I think yes, because these are the only emit('error')s and they both relate to connection issues.:

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.

Connection pool leak when unexpected tcp reset occurs

1 participant