From ceaec3324925e53ca3f467b0438a98f1108eed0f Mon Sep 17 00:00:00 2001 From: Julia Johannesen Date: Sun, 22 Sep 2024 19:41:12 -0400 Subject: [PATCH] Add `DetachedWindowAPI.close` calls to `MfmService` --- packages/backend/src/core/MfmService.ts | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/packages/backend/src/core/MfmService.ts b/packages/backend/src/core/MfmService.ts index 1b6951ca19..94bb5af6b5 100644 --- a/packages/backend/src/core/MfmService.ts +++ b/packages/backend/src/core/MfmService.ts @@ -245,7 +245,7 @@ export class MfmService { return null; } - const { window } = new Window(); + const { happyDOM, window } = new Window(); const doc = window.document; @@ -463,7 +463,11 @@ export class MfmService { appendChildren(nodes, body); - return new XMLSerializer().serializeToString(body); + const serialized = new XMLSerializer().serializeToString(body); + + happyDOM.close().catch(e => {}); + + return serialized; } // the toMastoApiHtml function was taken from Iceshrimp and written by zotan and modified by marie to work with the current MK version @@ -474,7 +478,7 @@ export class MfmService { return null; } - const { window } = new Window(); + const { happyDOM, window } = new Window(); const doc = window.document; @@ -681,6 +685,8 @@ export class MfmService { result = result.replace(/^

/, '').replace(/<\/p>$/, ''); } + happyDOM.close().catch(e => {}); + return result; } }