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

Client does not exit after invoking .destroy() #327

Closed
Bullrich opened this issue Mar 14, 2024 · 0 comments · Fixed by #328
Closed

Client does not exit after invoking .destroy() #327

Bullrich opened this issue Mar 14, 2024 · 0 comments · Fixed by #328

Comments

@Bullrich
Copy link

When running tests the client does not properly exit, keeping the thread running.

This happens even when .destroy() is invoked.

This gives problems with test suites, as they never finish.

It is currently making paritytech/get-fellows-action#11 test fail by timing out.

Minimal reproduction

Test file in src/test/papi.test.ts

import { createClient } from "@polkadot-api/client";
import { getChain } from "@polkadot-api/node-polkadot-provider";
import { WebSocketProvider } from "@polkadot-api/ws-provider/node";

import relayDescriptor from "../codegen/relay";

test("Example", async () => {
  const polkadotClient = createClient(
    getChain({
      provider: WebSocketProvider("wss://rpc.polkadot.io"),
      keyring: [],
    }),
  );

  console.log("Requesting data");
  await polkadotClient
    .getTypedApi(relayDescriptor)
    .query.Identity.IdentityOf.getEntries();
  console.log("Finished operation");

  polkadotClient.destroy();
});

Log result

yarn run v1.22.21
$ jest src/test/papi.test.ts
  console.log
    Requesting data

      at src/test/papi.test.ts:15:11

 FAIL  src/test/papi.test.ts (21.206 s)
  ✕ Example (20003 ms)

  ● Example

    thrown: "Exceeded timeout of 20000 ms for a test.
    Add a timeout value to this test to increase the timeout, if this is a long-running test. See https://jestjs.io/docs/api#testname-fn-timeout."

       5 | import relayDescriptor from "../codegen/relay";
       6 |
    >  7 | test("Example", async () => {
         | ^
       8 |   const polkadotClient = createClient(
       9 |     getChain({
      10 |       provider: WebSocketProvider("wss://rpc.polkadot.io"),

      at Object.<anonymous> (src/test/papi.test.ts:7:1)

Test Suites: 1 failed, 1 total
Tests:       1 failed, 1 total
Snapshots:   0 total
Time:        21.229 s
Ran all test suites matching /src\/test\/papi.test.ts/i.
Jest did not exit one second after the test run has completed.

'This usually means that there are asynchronous operations that weren't stopped in your tests. Consider running Jest with `--detectOpenHandles` to troubleshoot this issue.
Bullrich added a commit to paritytech/get-fellows-action that referenced this issue Mar 14, 2024
It was reported in polkadot-api/polkadot-api#327 that PAPI does not exit correctly.

Until this is fixed, we need to add this parameter
Bullrich added a commit to paritytech/get-fellows-action that referenced this issue Mar 15, 2024
Until polkadot-api/polkadot-api#327 is fixed, we need to manually exit the process
Bullrich added a commit to paritytech/get-fellows-action that referenced this issue Mar 15, 2024
Migrated from `@polkadot/api` to `@polkadot-api/api` after watching
@josepot's video.

All the code entry points are still the same. So are the tests.

This resolves #9

Thanks you @josepot and @kratico for your help implementing PAPI and smoldot.

This commit also has a dirty fix to the issue reported in polkadot-api/polkadot-api#327
Bullrich added a commit to paritytech/get-fellows-action that referenced this issue Jul 2, 2024
Upgraded yarn to version 4

Upgraded all the dependencies to latest.
- papi `0.4.0` -> `0.9.0` which contains a fix for
polkadot-api/polkadot-api#327
Bullrich added a commit to Bullrich/polkadot-fellows-runtimes that referenced this issue Jul 3, 2024
This commit updates get-fellows-action to v1.1.4 where `papi` was updated to latest (`0.9.0`) which contains a fix for polkadot-api/polkadot-api#327. This will accelerate the process of the triggering of review-bot.

Review-bot has also been updated to latest. It has the pull request number being injected, so it will always fetch the latest status when it runs.
Bullrich added a commit to Bullrich/polkadot-fellows-runtimes that referenced this issue Jul 3, 2024
This commit updates get-fellows-action to v1.1.4 where `papi` was updated to latest (`0.9.0`) which contains a fix for polkadot-api/polkadot-api#327. This will accelerate the process of the triggering of review-bot.

Review-bot has also been updated to latest. It has the pull request number being injected, so it will always fetch the latest status when it runs.
fellowship-merge-bot bot added a commit to polkadot-fellows/runtimes that referenced this issue Jul 3, 2024
This commit updates get-fellows-action to v1.1.4 where `papi` was
updated to latest (`0.9.0`) which contains a fix for
polkadot-api/polkadot-api#327. This will accelerate the process of the
triggering of review-bot.

Review-bot has also been updated to latest. It has the pull request
number being injected, so it will always fetch the latest status when it
runs.

With the fix provided in #369 this should make the whole process work as
intended.

- [x] Does not require a CHANGELOG entry

---------

Co-authored-by: fellowship-merge-bot[bot] <151052383+fellowship-merge-bot[bot]@users.noreply.github.com>
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

Successfully merging a pull request may close this issue.

1 participant