summaryrefslogtreecommitdiff
path: root/ext/web/08_text_encoding.js
diff options
context:
space:
mode:
authorFlorian Schwalm <68847951+egfx-notifications@users.noreply.github.com>2023-11-12 20:47:03 +0100
committerGitHub <noreply@github.com>2023-11-12 12:47:03 -0700
commit3a7abe6906c54f9c628215c2b71d67e8db25a519 (patch)
treee6305b1fc3d32038cb18246b5d924a9ff90ea7ea /ext/web/08_text_encoding.js
parent9f4a45561f4a01019cdbff86e2056de0296e791b (diff)
fix(ext/web): Prevent TextDecoderStream resource leak on stream cancellation (#21074)
This PR uses the new `cancel` method of `TransformStream` to properly clean up the internal `TextDecoder` used in `TextDecoderStream` if the stream is cancelled. Fixes #13142 Co-authored-by: Bartek IwaƄczuk <biwanczuk@gmail.com>
Diffstat (limited to 'ext/web/08_text_encoding.js')
-rw-r--r--ext/web/08_text_encoding.js8
1 files changed, 8 insertions, 0 deletions
diff --git a/ext/web/08_text_encoding.js b/ext/web/08_text_encoding.js
index 45dbad538..5f8391e12 100644
--- a/ext/web/08_text_encoding.js
+++ b/ext/web/08_text_encoding.js
@@ -301,6 +301,14 @@ class TextDecoderStream {
return PromiseReject(err);
}
},
+ cancel: (_reason) => {
+ try {
+ const _ = this.#decoder.decode();
+ return PromiseResolve();
+ } catch (err) {
+ return PromiseReject(err);
+ }
+ },
});
this[webidl.brand] = webidl.brand;
}