got 12.4.0 → 12.4.1

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.
@@ -431,6 +431,7 @@ export default class Request extends Duplex {
431
431
  if (this._request._writableState?.errored) {
432
432
  return;
433
433
  }
434
+ // The `!destroyed` check is required to prevent `uploadProgress` being emitted after the stream was destroyed
434
435
  if (!error) {
435
436
  this._bodySize = this._uploadedSize;
436
437
  this.emit('uploadProgress', this.uploadProgress);
@@ -998,7 +999,8 @@ export default class Request extends Duplex {
998
999
  return;
999
1000
  }
1000
1001
  this._request.write(chunk, encoding, (error) => {
1001
- if (!error) {
1002
+ // The `!destroyed` check is required to prevent `uploadProgress` being emitted after the stream was destroyed
1003
+ if (!error && !this._request.destroyed) {
1002
1004
  this._uploadedSize += Buffer.byteLength(chunk, encoding);
1003
1005
  const progress = this.uploadProgress;
1004
1006
  if (progress.percent < 1) {
@@ -1647,6 +1647,5 @@ export default class Options {
1647
1647
  Object.freeze(options.retry.errorCodes);
1648
1648
  Object.freeze(options.retry.methods);
1649
1649
  Object.freeze(options.retry.statusCodes);
1650
- Object.freeze(options.context);
1651
1650
  }
1652
1651
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "got",
3
- "version": "12.4.0",
3
+ "version": "12.4.1",
4
4
  "description": "Human-friendly and powerful HTTP request library for Node.js",
5
5
  "license": "MIT",
6
6
  "repository": "sindresorhus/got",