rpc calls create unresolved timeouts/promises until HttpClient.DEFAULT_TIMEOUT as such jest tests warning
Closed this issue · 4 comments
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
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 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();
});