undici 5.28.5 → 5.29.0

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.
@@ -1,7 +1,7 @@
1
1
  'use strict'
2
2
 
3
3
  const { parseSetCookie } = require('./parse')
4
- const { stringify, getHeadersList } = require('./util')
4
+ const { stringify } = require('./util')
5
5
  const { webidl } = require('../fetch/webidl')
6
6
  const { Headers } = require('../fetch/headers')
7
7
 
@@ -77,14 +77,13 @@ function getSetCookies (headers) {
77
77
 
78
78
  webidl.brandCheck(headers, Headers, { strict: false })
79
79
 
80
- const cookies = getHeadersList(headers).cookies
80
+ const cookies = headers.getSetCookie()
81
81
 
82
82
  if (!cookies) {
83
83
  return []
84
84
  }
85
85
 
86
- // In older versions of undici, cookies is a list of name:value.
87
- return cookies.map((pair) => parseSetCookie(Array.isArray(pair) ? pair[1] : pair))
86
+ return cookies.map((pair) => parseSetCookie(pair))
88
87
  }
89
88
 
90
89
  /**
@@ -1,8 +1,9 @@
1
1
  'use strict'
2
2
 
3
- const assert = require('assert')
4
- const { kHeadersList } = require('../core/symbols')
5
-
3
+ /**
4
+ * @param {string} value
5
+ * @returns {boolean}
6
+ */
6
7
  function isCTLExcludingHtab (value) {
7
8
  if (value.length === 0) {
8
9
  return false
@@ -263,29 +264,11 @@ function stringify (cookie) {
263
264
  return out.join('; ')
264
265
  }
265
266
 
266
- let kHeadersListNode
267
-
268
- function getHeadersList (headers) {
269
- if (headers[kHeadersList]) {
270
- return headers[kHeadersList]
271
- }
272
-
273
- if (!kHeadersListNode) {
274
- kHeadersListNode = Object.getOwnPropertySymbols(headers).find(
275
- (symbol) => symbol.description === 'headers list'
276
- )
277
-
278
- assert(kHeadersListNode, 'Headers cannot be parsed')
279
- }
280
-
281
- const headersList = headers[kHeadersListNode]
282
- assert(headersList)
283
-
284
- return headersList
285
- }
286
-
287
267
  module.exports = {
288
268
  isCTLExcludingHtab,
289
- stringify,
290
- getHeadersList
269
+ validateCookieName,
270
+ validateCookiePath,
271
+ validateCookieValue,
272
+ toIMFDate,
273
+ stringify
291
274
  }
@@ -10,6 +10,7 @@ const {
10
10
  isValidHeaderName,
11
11
  isValidHeaderValue
12
12
  } = require('./util')
13
+ const util = require('util')
13
14
  const { webidl } = require('./webidl')
14
15
  const assert = require('assert')
15
16
 
@@ -563,6 +564,9 @@ Object.defineProperties(Headers.prototype, {
563
564
  [Symbol.toStringTag]: {
564
565
  value: 'Headers',
565
566
  configurable: true
567
+ },
568
+ [util.inspect.custom]: {
569
+ enumerable: false
566
570
  }
567
571
  })
568
572
 
package/lib/pool.js CHANGED
@@ -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] () {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "undici",
3
- "version": "5.28.5",
3
+ "version": "5.29.0",
4
4
  "description": "An HTTP/1.1 client, written from scratch for Node.js",
5
5
  "homepage": "https://undici.nodejs.org",
6
6
  "bugs": {