siyuan-note/siyuan · error · TypeError

The tracked range owner is required

Error message

The tracked range owner is required

What it means

TypeError guard in trackRange: options.owner is missing or not a function/object. A stable owner identity is required to scope and garbage-collect tracked-range handles (e.g. per plugin), so omitting it is a caller contract violation.

Solutions

  1. Pass the plugin instance or another stable object as options.owner
  2. Do not pass null, undefined, or primitive owners
Defensive patterns

Strategy: type-guard

When it happens

Trigger: Thrown at app/src/protyle/util/trackedRange.ts:1137 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/564ad996b4e0d982. Report an issue: GitHub.

Appendix: source

Thrown at app/src/protyle/util/trackedRange.ts:1137

        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");
    }
    const handle = Object.freeze({id: `tracked-range-${++handleSequence}`});
    const trackedRange = range.cloneRange();
    const state: ITrackedRangeState = {

View on GitHub (pinned to 9f775e8a12)