neo4j / neo4j-javascript-driver

Neo4j Bolt driver for JavaScript
https://neo4j.com/docs/javascript-manual/current/
Apache License 2.0
839 stars 148 forks source link

Fix OOM crash, when closing a transaction while Queries are still ongoing #1193

Closed reckter closed 1 month ago

reckter commented 1 month ago

When closing a transaction while queries are still running, the _onErrorCallbacks will cause an infinite loop which leads to an OOM crash.

Because FAILED is only set as a state in this function, I opted to use it as a failsafe check, to cut the recursion short.

The test triggers the OOM crash when the fix is not included, otherwise it passes in <1s on my machine.

I hope the test is ok as it is, let me know if you need any changes for this.

EDIT: Upon a bit further testing, it's not actually infinite, but just scaling exponentially. 3 simultaneous queries gets us ~3000 _onErrorCallback calls, 4 gets us ~32000, 5 gets us ~195000, 6 gets us ~840000, 7-12 gets us "Map maximum size exceeded" 13+ gets us the mentioned OOM

reckter commented 1 month ago

@bigmontz (Sorry for the ping, but this is a server-crashing issue for us, which actually causes errors for our users.).

If there is anything I can do to get this merged faster, please let me know :)

Thanks!