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

rpc calls create unresolved timeouts/promises until HttpClient.DEFAULT_TIMEOUT as such jest tests warning #172

Closed
opx221 opened this issue Jan 20, 2024 · 4 comments

Comments

@opx221
Copy link

opx221 commented Jan 20, 2024

Hello again

Also problem I experienced is that HttpClient creates unresolved timeouts/promises until HttpClient.DEFAULT_TIMEOUT - timeout check
this results in jest tests giving warnings and not exiting properly
this can be fixed by settings HttpClient.DEFAULT_TIMEOUT to a low value, for example 1000, or by using the jest --forceExit, or by canceling the unresolved timeout (or was it promise?) on successful result from rpc call

Thank you

@woodser
Copy link
Owner

woodser commented Jan 20, 2024

The RPC call should resolve as soon as a response is received, or after the default timeout, whichever happens first.

Can you give a specific example of different behavior?

@opx221
Copy link
Author

opx221 commented Jan 20, 2024

The RPC call should resolve as soon as a response is received, or after the default timeout, whichever happens first.

Can you give a specific example of different behavior?

the rpc call itself does resolve, but it creates another unresolved timeout or promise for checking the timeout that makes jest complain

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.

jest test demonstrating this

import { HttpClient } from 'monero-ts';
import { connectToWalletRpc } from 'monero-ts';

//HttpClient.DEFAULT_TIMEOUT = 1000;
// uncomment to make jest test exit properly

test('rpc does not leave open handles', async () => {
  const walletRpc = await connectToWalletRpc('http://localhost:18081');
  expect(await walletRpc.getPrimaryAddress()).toBeTruthy();
});

@woodser
Copy link
Owner

woodser commented Jan 22, 2024

I haven't been able to recreate the issue in a jest project, but are you able to test this commit? c0651ab

It cancels the timeout promise on successful response.

Otherwise, maybe you have a project I could check out to recreate?

@woodser
Copy link
Owner

woodser commented Jan 29, 2024

Fixed with the last release: 96daaa0

@woodser woodser closed this as completed Jan 29, 2024
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