Skip to content

Conversation

lutovich
Copy link
Contributor

Connection pool has limited size and returns Promise<Connection> instead of Connection directly. Returned promise can be failed when connection acquisition timeout has fired. Pool uses helper function util#promiseOrTimeout() to race acquisition and timeout promises.

This function allowed both timeout callback to be invoked and connection to be acquired. It cleared the timeout outside of the raced promises. As result connection was acquired but timeout callback failed in background. It tried to clear non-existing pending acquisition attempts.

This PR fixes the problem by including #clearTimeout() call in the chain of raced promises.

Fixes #304

Connection pool has limited size and returns `Promise<Connection>`
instead of `Connection` directly. Returned promise can be failed when
connection acquisition timeout has fired. Pool uses helper function
`util#promiseOrTimeout()` to race acquisition and timeout promises.

This function allowed both timeout callback to be invoked and connection
to be acquired. It cleared the timeout outside of the raced promises. As
result connection was acquired but timeout callback failed in background.
It tried to clear non-existing pending acquisition attempts.

This commit fixes the problem by including `#clearTimeout()` call in
the chain of raced promises.
@lutovich lutovich requested a review from ali-ince December 18, 2017 11:37
Copy link
Contributor

@ali-ince ali-ince left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@ali-ince ali-ince merged commit b011bc1 into neo4j:1.5 Dec 22, 2017
@lutovich lutovich deleted the 1.5-pool-fix branch December 22, 2017 13:04
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.

2 participants