(kad-dht) What is the cause of: CodeError: Query aborted

I’m getting this error thrown occasionally (I can’t seem to get it to reproduce all that often), it crashes my entire program when it occurs.

file://node_modules/@libp2p/kad-dht/src/query/query-path.ts:227
      deferred.reject(new CodeError('Query aborted', 'ERR_QUERY_ABORTED'))
                      ^
CodeError: Query aborted
    at EventTarget.<anonymous> (file://node_modules/@libp2p/kad-dht/src/query/query-path.ts:227:23)
    at EventTarget.[nodejs.internal.kHybridDispatch] (node:internal/event_target:757:20)
    at EventTarget.dispatchEvent (node:internal/event_target:692:26)
    at abortSignal (node:internal/abort_controller:369:10)
    at AbortController.abort (node:internal/abort_controller:403:5)
    at EventTarget.onAbort (file://node_modules/any-signal/src/index.ts:14:16)
    at EventTarget.[nodejs.internal.kHybridDispatch] (node:internal/event_target:757:20)
    at EventTarget.dispatchEvent (node:internal/event_target:692:26)
    at abortSignal (node:internal/abort_controller:369:10)
    at AbortController.abort (node:internal/abort_controller:403:5) {
  code: 'ERR_QUERY_ABORTED',
  props: {}
}

My program has gotten quite large and is doing a lot of things simultaneously using Libp2p and Helia. and I am having a lot of trouble figuring out what precisely is causing this error or why it only occurs sometimes.

Shortly before this the logger produces a couple of errors:

libp2p:yamux frame for missing stream id=21
libp2p:connection-manager:dial-queue:error error during dial ... ECONNRESET ENETUNREACH
libp2p:kad-dht:wan:query ... ECONNRESET ENETUNREACH

But I don’t think these are the cause since it is throwing the entire program (uncaught) and it is only failing to dial a peer.

I know this doesn’t provide all the details necessary to debug this issue but if someone could point me in the right direction of things to more closely look at or test, it would be much appreciated.

Looks like it was due to a deferred promise not being handled right: