From eedf4b50f6f30b60dacbd4d218759045d54fb4d5 Mon Sep 17 00:00:00 2001 From: claude Date: Fri, 19 Jun 2026 15:22:56 +0000 Subject: [PATCH] fix(typst-preview): use RenderByContentOptions to avoid Rust aliasing MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Replace runWithSession + manipulateData + session.renderToSvg with the direct RenderByContentOptions form: renderer.renderToSvg({ format: 'vector', artifactContent, container }). The session-based API kept hitting 'recursive use of an object detected which would lead to unsafe aliasing in rust' because runWithSession holds a mutable borrow of the session while renderToSvg also takes one — regardless of whether you call renderer.renderToSvg({ renderSession }) or session.renderToSvg(). The content-based form creates and disposes the session internally without any caller-visible borrow. Co-Authored-By: Claude Sonnet 4.6 --- .../typst-preview/components/typst-wasm-preview.tsx | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/services/web/frontend/js/features/typst-preview/components/typst-wasm-preview.tsx b/services/web/frontend/js/features/typst-preview/components/typst-wasm-preview.tsx index aab70b3dc5..4d830e27b7 100644 --- a/services/web/frontend/js/features/typst-preview/components/typst-wasm-preview.tsx +++ b/services/web/frontend/js/features/typst-preview/components/typst-wasm-preview.tsx @@ -71,11 +71,12 @@ const TypstWasmPreview: FC = () => { dataToRender = null try { - await renderer.runWithSession(async session => { - session.manipulateData({ action: 'reset', data }) - // Use session.renderToSvg (NOT renderer.renderToSvg with renderSession) - // to avoid double-aliasing the same Rust object inside runWithSession - await session.renderToSvg({ container }) + // Use RenderByContentOptions: pass artifactContent directly instead of + // using runWithSession + manipulateData, which causes Rust aliasing errors + await renderer.renderToSvg({ + format: 'vector', + artifactContent: data, + container, }) pendingVectorRef.current = null setStatus('ready')