siyuan-note/siyuan · error · Error
Cannot track a range in a destroyed Protyle instance
Error message
Cannot track a range in a destroyed Protyle instance
What it means
Thrown by trackRange before creating a range handle when the given IProtyle instance has previously been destroyed (registered in destroyedProtyles). Range tracking against a destroyed editor is meaningless because its DOM and model are gone; the caller must hold a live Protyle instance or drop the tracking call after destroy.
Solutions
- Track ranges only while the Protyle instance is alive
- Re-create the Protyle instance before tracking
- Guard plugin code against operating on a destroyed editor
Defensive patterns
Strategy: type-guard
When it happens
Trigger: Thrown at app/src/protyle/util/trackedRange.ts:1134 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of siyuan-note/siyuan@9f775e8a12 (2026-09-19).
Data as JSON: /api/errors/54e90bf8c70008cc.
Report an issue: GitHub.
Appendix: source
Thrown at app/src/protyle/util/trackedRange.ts:1134
removeInputListeners(protyle);
}
if (state.owner) {
const handles = ownedHandles.get(state.owner);
handles?.forEach(item => {
if (item.protyle === protyle && item.handle === handle) {
handles.delete(item);
}
});
if (handles?.size === 0) {
ownedHandles.delete(state.owner);
}
}
};
export const trackRange = (protyle: IProtyle, range: Range,
options: ITrackRangeOptions): ITrackedRangeHandle => {
if (destroyedProtyles.has(protyle)) {
throw new Error("Cannot track a range in a destroyed Protyle instance");
}
if (!options?.owner || !["function", "object"].includes(typeof options.owner)) {
throw new TypeError("The tracked range owner is required");
}
if (options.affinity && !["after", "before"].includes(options.affinity)) {
throw new TypeError("The tracked range affinity must be before or after");
}
if (unloadingPlugins.has(options.owner)) {
throw new Error("Cannot track a range for an unloaded plugin");
}
const rangeSnapshot = getRangeSnapshot(protyle, range);
if (!rangeSnapshot) {
throw new TypeError("The range must be inside one editable source block of this Protyle instance");
}
const targetTokens = rangeSnapshot.stream.tokens.slice(rangeSnapshot.start, rangeSnapshot.end);
if (!range.collapsed && targetTokens.length === 0) {
throw new TypeError("The tracked range must contain semantic content");
}View on GitHub (pinned to 9f775e8a12)