You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
My understanding (from looking at the methods available on the connection object) is there's no way to explicitly close the TCP socket that @solana/web3.js makes to the validator. This doesn't affect anything on production - as the socket is open pretty much all the time - but nearly all test suites will complain with open handles warning unless the socket is explicitly closed.
Integration tests which use @solana/web3.js will complain with something like:
Jest has detected the following 2 open handles potentially keeping Jest from exiting:
● TCPWRAP
260 | test(`Get all Bob's token accounts`, async () => {
261 | // See https://solana.stackexchange.com/questions/1685/how-do-i-prevent-open-handles-issues-when-using-the-solana-connection-object
> 262 | const tokenAccounts = await connection.getTokenAccountsByOwner(
| ^
263 | bob.publicKey,
264 | {
265 | programId: TOKEN_PROGRAM_ID,
at node_modules/@solana/web3.js/node_modules/node-fetch/lib/index.js:1468:15
at Function.fetch [as default] (node_modules/@solana/web3.js/node_modules/node-fetch/lib/index.js:1437:9)
at fetchImpl (node_modules/@solana/web3.js/src/fetch-impl.ts:12:16)
at ClientBrowser.fetch [as callServer] (node_modules/@solana/web3.js/src/connection.ts:1173:23)
at ClientBrowser.Object.<anonymous>.ClientBrowser.request (node_modules/jayson/lib/client/browser/index.js:102:8)
at request (node_modules/@solana/web3.js/src/connection.ts:1212:14)
at Connection._rpcRequest (node_modules/@solana/web3.js/src/connection.ts:1211:12)
at Connection._rpcRequest [as getTokenAccountsByOwner] (node_modules/@solana/web3.js/src/connection.ts:2757:34)
at Object.<anonymous> (src/tokens.test.ts:262:44)
Proposed Solution
We add a close() method to the Connection object. I'm happy to do this myself if needed (I just want to make sure there's no existing way to close the connection that I have missed first).
The text was updated successfully, but these errors were encountered:
Problem
My understanding (from looking at the methods available on the
connection
object) is there's no way to explicitly close the TCP socket that@solana/web3.js
makes to the validator. This doesn't affect anything on production - as the socket is open pretty much all the time - but nearly all test suites will complain with open handles warning unless the socket is explicitly closed.Integration tests which use
@solana/web3.js
will complain with something like:Proposed Solution
We add a
close()
method to theConnection
object. I'm happy to do this myself if needed (I just want to make sure there's no existing way to close the connection that I have missed first).The text was updated successfully, but these errors were encountered: