fix(typst-preview): use RenderByContentOptions to avoid Rust aliasing
Build and Deploy Verso / deploy (push) Successful in 10m35s

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 <noreply@anthropic.com>
This commit is contained in:
claude
2026-06-19 15:22:56 +00:00
parent c6d71e58b7
commit eedf4b50f6
@@ -71,11 +71,12 @@ const TypstWasmPreview: FC = () => {
dataToRender = null dataToRender = null
try { try {
await renderer.runWithSession(async session => { // Use RenderByContentOptions: pass artifactContent directly instead of
session.manipulateData({ action: 'reset', data }) // using runWithSession + manipulateData, which causes Rust aliasing errors
// Use session.renderToSvg (NOT renderer.renderToSvg with renderSession) await renderer.renderToSvg({
// to avoid double-aliasing the same Rust object inside runWithSession format: 'vector',
await session.renderToSvg({ container }) artifactContent: data,
container,
}) })
pendingVectorRef.current = null pendingVectorRef.current = null
setStatus('ready') setStatus('ready')