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

Manually close Connection in web3.js? #26648

Closed
ndrewtl opened this issue Jul 15, 2022 · 1 comment
Closed

Manually close Connection in web3.js? #26648

ndrewtl opened this issue Jul 15, 2022 · 1 comment

Comments

@ndrewtl
Copy link

ndrewtl commented Jul 15, 2022

Problem

While running a Jest test harness, the code seems to throw an exception do to it exiting while a Connection is still open:

Jest has detected the following 1 open handle potentially keeping Jest from exiting:

    TCPWRAP

      33 | ): Promise<PublicKey[]> {
      34 |
    > 35 |   const { value } = await connection.getParsedTokenAccountsByOwner(
         |                                      ^
      36 |     publicKey, { programId: TOKEN_PROGRAM_ID }
      37 |   );
      38 |

      at node_modules/node-fetch/lib/index.js:1468:15
      at Function.fetch [as default] (node_modules/node-fetch/lib/index.js:1437:9)
      at fetch (node_modules/@solana/web3.js/src/fetch-impl.ts:12:16)
      at ClientBrowser.callServer (node_modules/@solana/web3.js/src/connection.ts:1009:23)
      at ClientBrowser.request (node_modules/jayson/lib/client/browser/index.js:102:8)
      at node_modules/@solana/web3.js/src/connection.ts:1048:14
      at Connection._rpcRequest (node_modules/@solana/web3.js/src/connection.ts:1047:12)
      at Connection.getParsedTokenAccountsByOwner (node_modules/@solana/web3.js/src/connection.ts:2563:34)

Proposed Solution

Provide a way to manually close a Connection. Perhaps a method like Connection.close(): Promise<void>.

@steveluscher
Copy link
Contributor

I think the problem might actually be because of the connection agent manager we have going on. Follow along in #25069!

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