### Is there an existing issue for this?

- [X] I have searched the existing issues

### Current behaviour

Using clang version 15.0.7 on Ubuntu and enabling the thread sanitizer, the `wallet_miniscript.py --descriptors` test consistently fails with a timeout.

### Expected behaviour

Don't timeout.

I could of course increate the timeouts, but this is the only test with that issue.

As an aside, the log output contains extremely long descriptors which should probably be truncated.

### Steps to reproduce

```
./autogen
./configure CC=clang CXX=clang++ --enable-suppress-external-warnings --with-sanitizers=thread --without-gui
make -j33
test/functional/wallet_miniscript.py --descriptors
```

### Relevant log output

Full log: https://termbin.com/p81f

```
2023-11-06T03:18:08.275000Z TestFramework (ERROR): JSONRPC error
Traceback (most recent call last):
  File "/home/sjors/dev/bitcoin/test/functional/test_framework/authproxy.py", line 151, in _get_response
    http_response = self.__conn.getresponse()
  File "/home/sjors/.pyenv/versions/3.9.18/lib/python3.9/http/client.py", line 1377, in getresponse
    response.begin()
  File "/home/sjors/.pyenv/versions/3.9.18/lib/python3.9/http/client.py", line 320, in begin
    version, status, reason = self._read_status()
  File "/home/sjors/.pyenv/versions/3.9.18/lib/python3.9/http/client.py", line 281, in _read_status
    line = str(self.fp.readline(_MAXLINE + 1), "iso-8859-1")
  File "/home/sjors/.pyenv/versions/3.9.18/lib/python3.9/socket.py", line 704, in readinto
    return self._sock.recv_into(b)
socket.timeout: timed out

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/sjors/dev/bitcoin/test/functional/test_framework/test_framework.py", line 132, in main
    self.run_test()
  File "/home/sjors/dev/bitcoin/test/functional/wallet_miniscript.py", line 386, in run_test
    self.signing_test(desc, None, None, 1, 3, None)
  File "/home/sjors/dev/bitcoin/test/functional/wallet_miniscript.py", line 258, in signing_test
    res = self.ms_sig_wallet.importdescriptors(
  File "/home/sjors/dev/bitcoin/test/functional/test_framework/coverage.py", line 50, in __call__
    return_val = self.auth_service_proxy_instance.__call__(*args, **kwargs)
  File "/home/sjors/dev/bitcoin/test/functional/test_framework/authproxy.py", line 127, in __call__
    response, status = self._request('POST', self.__url.path, postdata.encode('utf-8'))
  File "/home/sjors/dev/bitcoin/test/functional/test_framework/authproxy.py", line 106, in _request
    return self._get_response()
  File "/home/sjors/dev/bitcoin/test/functional/test_framework/authproxy.py", line 153, in _get_response
    raise JSONRPCException({
test_framework.authproxy.JSONRPCException: 'importdescriptors' RPC took longer than 240.000000 seconds. Consider using larger timeout for calls that take longer to return. (-344)
2023-11-06T03:18:08.335000Z TestFramework (INFO): Stopping nodes
2023-11-06T03:18:08.335000Z TestFramework.node0 (ERROR): Unable to stop node.
Traceback (most recent call last):
  File "/home/sjors/dev/bitcoin/test/functional/test_framework/test_node.py", line 361, in stop_node
    self.stop(wait=wait)
  File "/home/sjors/dev/bitcoin/test/functional/test_framework/coverage.py", line 50, in __call__
    return_val = self.auth_service_proxy_instance.__call__(*args, **kwargs)
  File "/home/sjors/dev/bitcoin/test/functional/test_framework/authproxy.py", line 127, in __call__
    response, status = self._request('POST', self.__url.path, postdata.encode('utf-8'))
  File "/home/sjors/dev/bitcoin/test/functional/test_framework/authproxy.py", line 105, in _request
    self.__conn.request(method, path, postdata, headers)
  File "/home/sjors/.pyenv/versions/3.9.18/lib/python3.9/http/client.py", line 1285, in request
    self._send_request(method, url, body, headers, encode_chunked)
  File "/home/sjors/.pyenv/versions/3.9.18/lib/python3.9/http/client.py", line 1296, in _send_request
    self.putrequest(method, url, **skips)
  File "/home/sjors/.pyenv/versions/3.9.18/lib/python3.9/http/client.py", line 1122, in putrequest
    raise CannotSendRequest(self.__state)
http.client.CannotSendRequest: Request-sent
```

### How did you obtain Bitcoin Core

Compiled from source

### What version of Bitcoin Core are you using?

master@953d302a242381ae13112ea42f87d57e6e796147

### Operating system and version

Ubuntu 23.04

### Machine specifications

AMD Ryzen 7950x
`/tmp` is mounted to tmpfs
{
    LOCK(cs_desc_man);
    if (!m_map_keys.empty()) {
        return false;
    }
    bool keyPass = m_map_crypted_keys.empty(); 
    bool keyFail = false;
    for (const auto& mi : m_map_crypted_keys) {
        const CPubKey &pubkey = mi.second.first;
        const std::vector<unsigned char> &crypted_secret = mi.second.second;
        CKey key;
        if (!DecryptKey(master_key, crypted_secret, pubkey, key)) {
            keyFail = true;
            break;
        }
        keyPass = true;
        if (m_decryption_thoroughly_checked)
            break;
    }
    if (keyPass && keyFail) {
        LogPrintf("The wallet is probably corrupted: Some keys decrypt but not all.\n");
        throw std::runtime_error("Error unlocking wallet: some keys decrypt but not all. Your wallet file may be corrupt.");
    }
    if (keyFail || (!keyPass && !accept_no_keys)) {
        return false;
    }
    m_decryption_thoroughly_checked = true;
    return true;
}
bool DescriptorScriptPubKeyMan::Encrypt(const CKeyingMaterial& master_key, WalletBatch* batch)