undici 6.6.1 → 6.6.2

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.
package/index-fetch.js CHANGED
@@ -14,4 +14,7 @@ module.exports.FormData = require('./lib/fetch/formdata').FormData
14
14
  module.exports.Headers = require('./lib/fetch/headers').Headers
15
15
  module.exports.Response = require('./lib/fetch/response').Response
16
16
  module.exports.Request = require('./lib/fetch/request').Request
17
+
17
18
  module.exports.WebSocket = require('./lib/websocket/websocket').WebSocket
19
+
20
+ module.exports.EventSource = require('./lib/eventsource/eventsource').EventSource
@@ -1099,11 +1099,12 @@ function fetchFinale (fetchParams, response) {
1099
1099
 
1100
1100
  const byteStream = new ReadableStream({
1101
1101
  readableStream: transformStream.readable,
1102
+ async start () {
1103
+ this._bodyReader = this.readableStream.getReader()
1104
+ },
1102
1105
  async pull (controller) {
1103
- const reader = this.readableStream.getReader()
1104
-
1105
1106
  while (controller.desiredSize >= 0) {
1106
- const { done, value } = await reader.read()
1107
+ const { done, value } = await this._bodyReader.read()
1107
1108
 
1108
1109
  if (done) {
1109
1110
  queueMicrotask(() => readableStreamClose(controller))
@@ -1905,8 +1906,8 @@ async function httpNetworkFetch (
1905
1906
 
1906
1907
  // 11. Let pullAlgorithm be an action that resumes the ongoing fetch
1907
1908
  // if it is suspended.
1908
- const pullAlgorithm = () => {
1909
- fetchParams.controller.resume()
1909
+ const pullAlgorithm = async () => {
1910
+ await fetchParams.controller.resume()
1910
1911
  }
1911
1912
 
1912
1913
  // 12. Let cancelAlgorithm be an algorithm that aborts fetchParams’s
@@ -2032,7 +2033,7 @@ async function httpNetworkFetch (
2032
2033
 
2033
2034
  // 9. If stream doesn’t need more data ask the user agent to suspend
2034
2035
  // the ongoing fetch.
2035
- if (!fetchParams.controller.controller.desiredSize) {
2036
+ if (fetchParams.controller.controller.desiredSize <= 0) {
2036
2037
  return
2037
2038
  }
2038
2039
  }
@@ -34,10 +34,14 @@ webidl.errors.invalidArgument = function (context) {
34
34
 
35
35
  // https://webidl.spec.whatwg.org/#implements
36
36
  webidl.brandCheck = function (V, I, opts = undefined) {
37
- if (opts?.strict !== false && !(V instanceof I)) {
38
- throw new TypeError('Illegal invocation')
37
+ if (opts?.strict !== false) {
38
+ if (!(V instanceof I)) {
39
+ throw new TypeError('Illegal invocation')
40
+ }
39
41
  } else {
40
- return V?.[Symbol.toStringTag] === I.prototype[Symbol.toStringTag]
42
+ if (V?.[Symbol.toStringTag] !== I.prototype[Symbol.toStringTag]) {
43
+ throw new TypeError('Illegal invocation')
44
+ }
41
45
  }
42
46
  }
43
47
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "undici",
3
- "version": "6.6.1",
3
+ "version": "6.6.2",
4
4
  "description": "An HTTP/1.1 client, written from scratch for Node.js",
5
5
  "homepage": "https://undici.nodejs.org",
6
6
  "bugs": {
@@ -104,7 +104,7 @@
104
104
  "@sinonjs/fake-timers": "^11.1.0",
105
105
  "@types/node": "^18.0.3",
106
106
  "abort-controller": "^3.0.0",
107
- "borp": "^0.5.0",
107
+ "borp": "^0.9.1",
108
108
  "chai": "^4.3.4",
109
109
  "chai-as-promised": "^7.1.1",
110
110
  "chai-iterator": "^3.0.2",