@nxtedition/nxt-undici 6.4.2 → 6.4.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.
Files changed (2) hide show
  1. package/lib/request.js +18 -3
  2. package/package.json +1 -1
package/lib/request.js CHANGED
@@ -7,6 +7,10 @@ function noop() {}
7
7
 
8
8
  export class RequestHandler {
9
9
  constructor({ signal, method, body, highWaterMark }, resolve) {
10
+ if (isStream(body) && body.closed) {
11
+ body = null
12
+ }
13
+
10
14
  try {
11
15
  if (typeof resolve !== 'function') {
12
16
  throw new InvalidArgumentError('invalid resolve')
@@ -179,7 +183,18 @@ export function request(dispatch, url, opts) {
179
183
  path = url.search ? `${url.pathname}${url.search}` : url.pathname
180
184
  }
181
185
 
182
- opts = { ...opts, origin, path }
183
-
184
- return new Promise((resolve) => dispatch(opts, new RequestHandler(opts, resolve)))
186
+ return new Promise((resolve) =>
187
+ dispatch(
188
+ opts,
189
+ new RequestHandler(
190
+ {
191
+ ...opts,
192
+ origin,
193
+ path,
194
+ body: isStream(opts.body) && opts.body.readableEnded ? null : opts.body,
195
+ },
196
+ resolve,
197
+ ),
198
+ ),
199
+ )
185
200
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nxtedition/nxt-undici",
3
- "version": "6.4.2",
3
+ "version": "6.4.3",
4
4
  "license": "MIT",
5
5
  "author": "Robert Nagy <robert.nagy@boffins.se>",
6
6
  "main": "lib/index.js",