fix(server/objects): solves database connection resource leak when client connections are prematurely closed #3889
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description & motivation
This PR fixes a long existing bug with prematurely closed streaming connections. Prior to this PR, for the
/api/getobjects/*
REST endpoint, if the client prematurely closed a connection to the server it was not propogated to the database connection. This resulted in the database connection never being closed, and inevitably saturation for the server and the inability to serve further traffic (reffectively a Denial of Service until the server is restarted).The bug is due to an issue with Node.js stream.pipeline implementation, described in the documentation as so:
Changes:
stream-chain
library to resolve a known issue with Node.js built-instream.pipeline
To-do before merge:
Screenshots:
Before (recreating the issue):
After (the fix has been applied):
Validation of changes:
Run the test with
yarn test --run 'modules/core/tests/integration/objectsStream.rest.spec.ts' -f 'should close database connections if client connection is prematurely closed'
Checklist:
References