Skip to content
This repository has been archived by the owner on Apr 8, 2024. It is now read-only.

getTasklistToken leaves a handle open #21

Closed
pepopowitz opened this issue Nov 30, 2023 · 1 comment
Closed

getTasklistToken leaves a handle open #21

pepopowitz opened this issue Nov 30, 2023 · 1 comment
Assignees

Comments

@pepopowitz
Copy link

When calling getTasklistToken, a handle is left open.

Example:

This test calls getTasklistToken under the covers. When running the test locally, Jest gives an error about the handle left open by getTasklistToken:

image

The above output as text, in case that's useful:

❯ npm run test

> camunda-tasklist-client@0.9.5 test
> jest --detectOpenHandles --runInBand --forceExit

 PASS  src/__test__/test.spec.ts (14.538 s)
  TasklistApiClient
    ✓ can request all tasks (12021 ms)

Test Suites: 1 passed, 1 total
Tests:       1 passed, 1 total
Snapshots:   0 total
Time:        14.673 s
Ran all test suites.

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

  ●  Timeout

      65 |
      66 |   private async getHeaders() {
    > 67 |     const token = await getTasklistToken(this.userAgentString);
         |                                         ^
      68 |     return {
      69 |       'content-type': 'application/json',
      70 |       authorization: `Bearer ${token}`,

      at OAuthProviderImpl.startExpiryTimer (node_modules/camunda-saas-oauth/dist/lib/OAuthProviderImpl.js:195:28)
      at OAuthProviderImpl.fromFileCache (node_modules/camunda-saas-oauth/dist/lib/OAuthProviderImpl.js:160:18)
      at OAuthProviderImpl.<anonymous> (node_modules/camunda-saas-oauth/dist/lib/OAuthProviderImpl.js:88:42)
      at node_modules/camunda-saas-oauth/dist/lib/OAuthProviderImpl.js:31:71
      at Object.<anonymous>.__awaiter (node_modules/camunda-saas-oauth/dist/lib/OAuthProviderImpl.js:27:12)
      at OAuthProviderImpl.getToken (node_modules/camunda-saas-oauth/dist/lib/OAuthProviderImpl.js:82:16)
      at getTasklistToken (node_modules/camunda-saas-oauth/dist/lib/Tasklist.js:18:34)

Details

As discussed in person with @jwulf, the cause of the open handle is the starting of a timeout so that the token can be evicted from the cache after it expires. To fix this open handle, it might make sense to evict tokens from the cache upon request, if they've exceeded their expiration, instead of using a timer.

@jwulf
Copy link
Member

jwulf commented Mar 5, 2024

This is fixed in the new client: https://github.com/camunda-community-hub/camunda-8-js-sdk

@jwulf jwulf closed this as completed Mar 5, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants