undici 6.21.1 → 6.21.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -73,6 +73,20 @@ class Pool extends PoolBase {
73
73
  ? { ...options.interceptors }
74
74
  : undefined
75
75
  this[kFactory] = factory
76
+
77
+ this.on('connectionError', (origin, targets, error) => {
78
+ // If a connection error occurs, we remove the client from the pool,
79
+ // and emit a connectionError event. They will not be re-used.
80
+ // Fixes https://github.com/nodejs/undici/issues/3895
81
+ for (const target of targets) {
82
+ // Do not use kRemoveClient here, as it will close the client,
83
+ // but the client cannot be closed in this state.
84
+ const idx = this[kClients].indexOf(target)
85
+ if (idx !== -1) {
86
+ this[kClients].splice(idx, 1)
87
+ }
88
+ }
89
+ })
76
90
  }
77
91
 
78
92
  [kGetDispatcher] () {
@@ -162,7 +162,10 @@ function extractBody (object, keepalive = false) {
162
162
  }
163
163
  }
164
164
 
165
- const chunk = textEncoder.encode(`--${boundary}--`)
165
+ // CRLF is appended to the body to function with legacy servers and match other implementations.
166
+ // https://github.com/curl/curl/blob/3434c6b46e682452973972e8313613dfa58cd690/lib/mime.c#L1029-L1030
167
+ // https://github.com/form-data/form-data/issues/63
168
+ const chunk = textEncoder.encode(`--${boundary}--\r\n`)
166
169
  blobParts.push(chunk)
167
170
  length += chunk.byteLength
168
171
  if (hasUnknownSizeValue) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "undici",
3
- "version": "6.21.1",
3
+ "version": "6.21.3",
4
4
  "description": "An HTTP/1.1 client, written from scratch for Node.js",
5
5
  "homepage": "https://undici.nodejs.org",
6
6
  "bugs": {
@@ -28,4 +28,5 @@ declare namespace Interceptors {
28
28
  export function retry(opts?: RetryInterceptorOpts): Dispatcher.DispatcherComposeInterceptor
29
29
  export function redirect(opts?: RedirectInterceptorOpts): Dispatcher.DispatcherComposeInterceptor
30
30
  export function responseError(opts?: ResponseErrorInterceptorOpts): Dispatcher.DispatcherComposeInterceptor
31
+ export function dns (opts?: DNSInterceptorOpts): Dispatcher.DispatcherComposeInterceptor
31
32
  }