fix(backend): happy-domを使用後にcloseするように (#14615)

* Add `DetachedWindowAPI.close` calls to `MfmService`

(cherry picked from commit ceaec33249)

* fix

* update changelog

* fix

---------

Co-authored-by: Julia Johannesen <julia@insertdomain.name>
This commit is contained in:
かっこかり 2024-09-23 21:43:48 +09:00 committed by GitHub
parent 7f7445ad7a
commit e673c143a9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 10 additions and 4 deletions

View file

@ -28,6 +28,8 @@
(Cherry-picked from https://activitypub.software/TransFem-org/Sharkey/-/commit/26e0412fbb91447c37e8fb06ffb0487346063bb8) (Cherry-picked from https://activitypub.software/TransFem-org/Sharkey/-/commit/26e0412fbb91447c37e8fb06ffb0487346063bb8)
- Fix: `Retry-After`ヘッダーが送信されなかった問題を修正 - Fix: `Retry-After`ヘッダーが送信されなかった問題を修正
(Cherry-picked from https://activitypub.software/TransFem-org/Sharkey/-/commit/8a982c61c01909e7540ff1be9f019df07c3f0624) (Cherry-picked from https://activitypub.software/TransFem-org/Sharkey/-/commit/8a982c61c01909e7540ff1be9f019df07c3f0624)
- Fix: サーバーサイドのDOM解析完了時にリソースを開放するように
(Cherry-picked from https://activitypub.software/TransFem-org/Sharkey/-/merge_requests/634)
## 2024.8.0 ## 2024.8.0

View file

@ -239,7 +239,7 @@ export class MfmService {
return null; return null;
} }
const { window } = new Window(); const { happyDOM, window } = new Window();
const doc = window.document; const doc = window.document;
@ -457,6 +457,10 @@ export class MfmService {
appendChildren(nodes, body); appendChildren(nodes, body);
return new XMLSerializer().serializeToString(body); const serialized = new XMLSerializer().serializeToString(body);
happyDOM.close().catch(err => {});
return serialized;
} }
} }

View file

@ -207,7 +207,7 @@ export class ApRequestService {
if ((contentType ?? '').split(';')[0].trimEnd().toLowerCase() === 'text/html' && _followAlternate === true) { if ((contentType ?? '').split(';')[0].trimEnd().toLowerCase() === 'text/html' && _followAlternate === true) {
const html = await res.text(); const html = await res.text();
const window = new Window({ const { window, happyDOM } = new Window({
settings: { settings: {
disableJavaScriptEvaluation: true, disableJavaScriptEvaluation: true,
disableJavaScriptFileLoading: true, disableJavaScriptFileLoading: true,
@ -241,7 +241,7 @@ export class ApRequestService {
} catch (e) { } catch (e) {
// something went wrong parsing the HTML, ignore the whole thing // something went wrong parsing the HTML, ignore the whole thing
} finally { } finally {
window.close(); happyDOM.close().catch(err => {});
} }
} }
//#endregion //#endregion