(err, socket, opts)
| 156 | // which timer (Node's internal one or undici's `connectTimeout`) wins the race. |
| 157 | // The original `AggregateError` is preserved on `.cause`. |
| 158 | function maybeNormalizeConnectError (err, socket, opts) { |
| 159 | if ( |
| 160 | err instanceof AggregateError && |
| 161 | (err.code === 'ETIMEDOUT' || err.errors.some((e) => e != null && e.code === 'ETIMEDOUT')) |
| 162 | ) { |
| 163 | let message = 'Connect Timeout Error' |
| 164 | if (Array.isArray(socket.autoSelectFamilyAttemptedAddresses)) { |
| 165 | message += ` (attempted addresses: ${socket.autoSelectFamilyAttemptedAddresses.join(', ')},` |
| 166 | } else { |
| 167 | message += ` (attempted address: ${opts.hostname}:${opts.port},` |
| 168 | } |
| 169 | message += ` timeout: ${opts.timeout}ms)` |
| 170 | |
| 171 | const wrapped = new ConnectTimeoutError(message) |
| 172 | wrapped.cause = err |
| 173 | return wrapped |
| 174 | } |
| 175 | return err |
| 176 | } |
| 177 | |
| 178 | module.exports = buildConnector |
no test coverage detected