Skip to content

Fix abort handling for notes with multiple D2 blocks#58

Open
RacyMind wants to merge 1 commit into
terrastruct:masterfrom
RacyMind:codex/fix-d2-multiple-block-abort
Open

Fix abort handling for notes with multiple D2 blocks#58
RacyMind wants to merge 1 commit into
terrastruct:masterfrom
RacyMind:codex/fix-d2-multiple-block-abort

Conversation

@RacyMind

Copy link
Copy Markdown

Summary

  • Key D2 preview debounce and abort state by code block instead of page.
  • Clean up abort controllers with the same key used to store them.
  • Treat intentional AbortErrors as superseded renders instead of D2 compilation failures.

Why

Obsidian runs the markdown code block processor once for each fenced D2 block, but the plugin currently stores debouncedMap and abortControllerMap entries under a page-level ID. In notes with more than one D2 block, a later block can abort an in-flight render for an earlier block on the same page. That aborted child process surfaces as AbortError: The operation was aborted, which the plugin currently renders as D2 Compilation Error even though D2 did not fail to compile the diagram.

This also fixes the cleanup mismatch where controllers are stored under pageID but deleted using pageContainer.dataset.id.

Validation

  • node_modules\.bin\tsc.cmd -noEmit -skipLibCheck
  • node esbuild.config.mjs production
  • node --check main.js

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants