Comparing version 6.19.5 to 6.19.6
@@ -37,4 +37,5 @@ 'use strict' | ||
if (hasFinalizationRegistry) { | ||
registry = new FinalizationRegistry((stream) => { | ||
if (!stream.locked && !isDisturbed(stream) && !isErrored(stream)) { | ||
registry = new FinalizationRegistry((weakRef) => { | ||
const stream = weakRef.deref() | ||
if (stream && !stream.locked && !isDisturbed(stream) && !isErrored(stream)) { | ||
stream.cancel('Response object has been garbage collected').catch(noop) | ||
@@ -530,3 +531,8 @@ } | ||
if (hasFinalizationRegistry && innerResponse.body?.stream) { | ||
registry.register(response, innerResponse.body.stream) | ||
// If the target (response) is reclaimed, the cleanup callback may be called at some point with | ||
// the held value provided for it (innerResponse.body.stream). The held value can be any value: | ||
// a primitive or an object, even undefined. If the held value is an object, the registry keeps | ||
// a strong reference to it (so it can pass it to the cleanup callback later). Reworded from | ||
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/FinalizationRegistry | ||
registry.register(response, new WeakRef(innerResponse.body.stream)) | ||
} | ||
@@ -533,0 +539,0 @@ |
{ | ||
"name": "undici", | ||
"version": "6.19.5", | ||
"version": "6.19.6", | ||
"description": "An HTTP/1.1 client, written from scratch for Node.js", | ||
@@ -5,0 +5,0 @@ "homepage": "https://undici.nodejs.org", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1132893
23962