Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Awaiting for the pool to end returns before the pool ends completely #239

Closed
weg-da opened this issue Apr 14, 2023 · 2 comments
Closed

Awaiting for the pool to end returns before the pool ends completely #239

weg-da opened this issue Apr 14, 2023 · 2 comments

Comments

@weg-da
Copy link

weg-da commented Apr 14, 2023

When running a jest test (typescript), i am connecting to a mariadb using a pool. The database querys are working fine.
After finishing the tests, the mariadb connection is ended, but still there is an Error.

Awaiting for the pool to end is not ending the pool completely, there seems to be still a process running in the background.

ReferenceError: You are trying to `import` a file after the Jest environment has been torn down. From test/ddl.view.test.ts.

  at Function.pluginHandler (../.yarn/cache/mariadb-npm-3.1.0-1d9a7a9506-d906ffc915.zip/node_modules/mariadb/lib/cmd/handshake/handshake.js:205:22)
  at Handshake.dispatchAuthSwitchRequest (../.yarn/cache/mariadb-npm-3.1.0-1d9a7a9506-d906ffc915.zip/node_modules/mariadb/lib/cmd/handshake/handshake.js:168:31)
  at Handshake.handshakeResult (../.yarn/cache/mariadb-npm-3.1.0-1d9a7a9506-d906ffc915.zip/node_modules/mariadb/lib/cmd/handshake/handshake.js:93:14)
  at PacketInputStream.receivePacketBasic (../.yarn/cache/mariadb-npm-3.1.0-1d9a7a9506-d906ffc915.zip/node_modules/mariadb/lib/io/packet-input-stream.js:80:9)
  at PacketInputStream.onData (../.yarn/cache/mariadb-npm-3.1.0-1d9a7a9506-d906ffc915.zip/node_modules/mariadb/lib/io/packet-input-stream.js:130:20)

Code used for closing the pool:

afterAll(async () => {
await pool.end()
})

What fixed the problem temporarily:

afterAll(async () => {
await pool.end()
await new Promise((resolve) => {
setTimeout(resolve, 100)
})
})
@rusher
Copy link
Collaborator

rusher commented Apr 14, 2023

Some race condition can make that possible : closing pool while pool was in the middle of creating a connection. That is not a problem usually because the connection being created will automatically beeing close a few nanoseconds after, but current implementation for authentication import file, making the error listed above.

This will be corrected in 3.1.2

@rusher
Copy link
Collaborator

rusher commented May 11, 2023

closing since correction is released

@rusher rusher closed this as completed May 11, 2023
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

No branches or pull requests

2 participants