hcp-uw / syntext

website for practicing your typing
5 stars 0 forks source link

npm mysql2 connection pool issue #57

Closed elimelt closed 1 year ago

elimelt commented 1 year ago

I spent literally all night and all day writing tests and messing with this, and I still haven't figured it out completely.

There seems to be an issue with our snippet-db client, and specifically its ability to close connections made from the async pool. This causes tests running in parallel to eventually deadlock if put under enough stress, something that makes me think this might be a real issue. I was able to fix the deadlock by manipulating calls to all of our async functions, but i STILL can't seem to clear this pesky error that originates from the connection in createSnippet. Not only that, but since I ran all the tests it causes a timeout on several other long-running test cases.

image

I think the problem might have something to do with how much I'm abusing async await, so the next thing I will try is to refactor createSnippet to execute in parallel/in a non-blocking fashion.

If anyone has any ideas, right now the issue is in user-router, although I'm sure it existed before I wrote tests that made it obvious there was an issue.

elimelt commented 1 year ago

I've since figured out that this is an issue with the fact that we aren't mocking a connection pool in testing. Shouldn't matter in a production setting!