silverbullet icon indicating copy to clipboard operation
silverbullet copied to clipboard

Uncaught RangeError: Position 779 is out of range for changeset of length 778

Open Blackilykat opened this issue 1 year ago • 2 comments

I was adding an object to a page and suddenly i couldn't move my cursor anymore. I was in vim mode when this happened and the red highlighting wouldn't move but the edits would happen where they were supposed to. Switching vim mode off, I saw the same thing: cursor does not move but pressing the arrow keys and typing something would as expected.

When trying to edit the page nothing will save.

There's an error spammed in console, here's the full log:

b main.js:135:12
d main.js:148:11
replacement running main.js:157:11
Layout was forced before the page was fully loaded. If stylesheets are not yet loaded this may cause a flash of unstyled content. markup.js:250:53
Booting SilverBullet client in Online Mode boot.ts:8:10
Service worker registered... boot.ts:33:14
Rebuilding editor state client.ts:863:12
Loading plugs client_system.ts:197:12
(Re)loading plugs client_system.ts:200:12
alreadyFetching is on, skipping even triggering for fetchFileList. evented_space_primitives.ts:56:14
Activated plug markdown system.ts:161:12
Booting up worker for markdown worker_sandbox.ts:33:12
Activated plug template system.ts:161:12
Activated plug emoji system.ts:161:12
Activated plug plug-manager system.ts:161:12
Activated plug core system.ts:161:12
Activated plug editor system.ts:161:12
Activated plug index system.ts:161:12
Activated plug search system.ts:161:12
Activated plug federation system.ts:161:12
Activated plug share system.ts:161:12
Activated plug query system.ts:161:12
Activated plug sync system.ts:161:12
Activated plug tasks system.ts:161:12
Booting up worker for index worker_sandbox.ts:33:12
Booting up worker for template worker_sandbox.ts:33:12
Booting up worker for query worker_sandbox.ts:33:12
An exception was thrown as a result of invoking function lintYAML error: l is undefined index.plug.js:1:709
Error dispatching event editor:lint to index.lintYAML: l is undefined event.ts:72:28
Error: l is undefined
    onMessage worker_sandbox.ts:93
    onmessage worker_sandbox.ts:59
    init worker_sandbox.ts:45
    init worker_sandbox.ts:44
    invoke worker_sandbox.ts:107
    invoke plug.ts:108
    invokeFunction system.ts:104
    _0t config.ts:67
    WA config.ts:129
    loadConfig client.ts:266
    init client.ts:238
    async* boot.ts:24
    B2 async.ts:98
    <anonymous> boot.ts:7
    <anonymous> boot.ts:52
view.mjs:2:35279
Loaded 0 functions, 0 commands, 0 event handlers from space-script common_system.ts:54:16
Now navigating to 
Object { page: "External Drive Index", scrollTop: 0, selection: {…} }
client.ts:476:14
Booting up worker for editor worker_sandbox.ts:33:12
Updating page list cache client.ts:751:12
YAML error unexpected end of the stream within a double quoted scalar (2:1)

 1 | name: "Sandisk”
 2 | 
-----^ index.plug.js:8:2161
Saving page External Drive Index client.ts:667:20
Flushed widget cache to store client.ts:1274:12
Uncaught RangeError: Position 779 is out of range for changeset of length 778
    mapPos state.mjs:5
    sm state.mjs:6
    compare state.mjs:6
    E_ view.mjs:3
    update view.mjs:3
    update view.mjs:4
    dispatchTransactions view.mjs:4
    dispatch view.mjs:4
    kM view.mjs:3
    setTimeout handler*kM view.mjs:3
    blur view.mjs:3
    runHandlers view.mjs:3
    handleEvent view.mjs:3
    ensureHandlers view.mjs:3
    Xu view.mjs:4
    init client.ts:198
    async* boot.ts:24
    B2 async.ts:98
    <anonymous> boot.ts:7
    <anonymous> boot.ts:52
state.mjs:5:5602
Uncaught RangeError: Position 779 is out of range for changeset of length 778
    mapPos state.mjs:5
    sm state.mjs:6
    compare state.mjs:6
    E_ view.mjs:3
    update view.mjs:3
    update view.mjs:4
    dispatchTransactions view.mjs:4
    dispatch view.mjs:4
    kM view.mjs:3
    setTimeout handler*kM view.mjs:3
    focus view.mjs:3
    runHandlers view.mjs:3
    handleEvent view.mjs:3
    ensureHandlers view.mjs:3
    Xu view.mjs:4
    init client.ts:198
    async* boot.ts:24
    B2 async.ts:98
    <anonymous> boot.ts:7
    <anonymous> boot.ts:52
state.mjs:5:5602
Uncaught RangeError: Position 779 is out of range for changeset of length 778
    mapPos state.mjs:5
    sm state.mjs:6
    compare state.mjs:6
    E_ view.mjs:3
    update view.mjs:3
    update view.mjs:4
    dispatchTransactions view.mjs:4
    dispatch view.mjs:4
    select view.mjs:3
    start view.mjs:3
    mousedown view.mjs:3
    runHandlers view.mjs:3
    handleEvent view.mjs:3
    ensureHandlers view.mjs:3
    Xu view.mjs:4
    init client.ts:198
    async* boot.ts:24
    B2 async.ts:98
    <anonymous> boot.ts:7
    <anonymous> boot.ts:52
state.mjs:5:5602
Uncaught RangeError: Position 779 is out of range for changeset of length 778
    mapPos state.mjs:5
    sm state.mjs:6
    compare state.mjs:6
    E_ view.mjs:3
    update view.mjs:3
    update view.mjs:4
    dispatchTransactions view.mjs:4
    dispatch view.mjs:4
    kp editor_ui.tsx:67
    setTimeout handler*kp/< editor_ui.tsx:66
    kp editor_ui.tsx:65
    init client.ts:195
    async* boot.ts:24
    B2 async.ts:98
    <anonymous> boot.ts:7
    <anonymous> boot.ts:52
state.mjs:5:5602
Uncaught RangeError: Position 779 is out of range for changeset of length 778
    mapPos state.mjs:5
    sm state.mjs:6
    compare state.mjs:6
    E_ view.mjs:3
    update view.mjs:3
    update view.mjs:4
    dispatchTransactions view.mjs:4
    dispatch view.mjs:4
    select view.mjs:3
    start view.mjs:3
    mousedown view.mjs:3
    runHandlers view.mjs:3
    handleEvent view.mjs:3
    ensureHandlers view.mjs:3
    Xu view.mjs:4
    init client.ts:198
    async* boot.ts:24
    B2 async.ts:98
    <anonymous> boot.ts:7
    <anonymous> boot.ts:52
state.mjs:5:5602
Uncaught RangeError: Position 779 is out of range for changeset of length 778
    mapPos state.mjs:5
    sm state.mjs:6
    compare state.mjs:6
    E_ view.mjs:3
    update view.mjs:3
    update view.mjs:4
    dispatchTransactions view.mjs:4
    dispatch view.mjs:4
    select view.mjs:3
    move view.mjs:3
    M_ view.mjs:3
    mousedown view.mjs:3
    runHandlers view.mjs:3
    handleEvent view.mjs:3
    ensureHandlers view.mjs:3
    Xu view.mjs:4
    init client.ts:198
    async* boot.ts:24
    B2 async.ts:98
    <anonymous> boot.ts:7
    <anonymous> boot.ts:52
state.mjs:5:5602
Uncaught RangeError: Position 779 is out of range for changeset of length 778
    mapPos state.mjs:5
    sm state.mjs:6
    compare state.mjs:6
    E_ view.mjs:3
    update view.mjs:3
    update view.mjs:4
    dispatchTransactions view.mjs:4
    dispatch view.mjs:4
    kp editor_ui.tsx:67
    setTimeout handler*kp/< editor_ui.tsx:66
    kp editor_ui.tsx:65
    init client.ts:195
    async* boot.ts:24
    B2 async.ts:98
    <anonymous> boot.ts:7
    <anonymous> boot.ts:52
state.mjs:5:5602
Uncaught RangeError: Position 779 is out of range for changeset of length 778
    mapPos state.mjs:5
    sm state.mjs:6
    compare state.mjs:6
    E_ view.mjs:3
    update view.mjs:3
    update view.mjs:4
    dispatchTransactions view.mjs:4
    dispatch view.mjs:4
    select view.mjs:3
    start view.mjs:3
    mousedown view.mjs:3
    runHandlers view.mjs:3
    handleEvent view.mjs:3
    ensureHandlers view.mjs:3
    Xu view.mjs:4
    init client.ts:198
    async* boot.ts:24
    B2 async.ts:98
    <anonymous> boot.ts:7
    <anonymous> boot.ts:52
state.mjs:5:5602
Uncaught RangeError: Position 779 is out of range for changeset of length 778
    mapPos state.mjs:5
    sm state.mjs:6
    compare state.mjs:6
    E_ view.mjs:3
    update view.mjs:3
    update view.mjs:4
    dispatchTransactions view.mjs:4
    dispatch view.mjs:4
    kp editor_ui.tsx:67
    setTimeout handler*kp/< editor_ui.tsx:66
    kp editor_ui.tsx:65
    init client.ts:195
    async* boot.ts:24
    B2 async.ts:98
    <anonymous> boot.ts:7
    <anonymous> boot.ts:52
state.mjs:5:5602
Uncaught RangeError: Position 779 is out of range for changeset of length 778
    mapPos state.mjs:5
    sm state.mjs:6
    compare state.mjs:6
    E_ view.mjs:3
    update view.mjs:3
    update view.mjs:4
    dispatchTransactions view.mjs:4
    dispatch view.mjs:4
    kM view.mjs:3
    setTimeout handler*kM view.mjs:3
    blur view.mjs:3
    runHandlers view.mjs:3
    handleEvent view.mjs:3
    ensureHandlers view.mjs:3
    Xu view.mjs:4
    init client.ts:198
    async* boot.ts:24
    B2 async.ts:98
    <anonymous> boot.ts:7
    <anonymous> boot.ts:52
state.mjs:5:5602

I uploaded the markdown file as it was when the error happened here

Manually changing the file to have an extra character at the end fixed the issue

Blackilykat avatar Oct 07 '24 16:10 Blackilykat

I see 3 suspicious things. This is how the file in fact ends:

```#drive
name: "Sandisk”
  1. the code block is not ended
  2. the second quotation mark of the "Sandisk” is not an ASCII quotation mark but U+201D Right Double Quotation Mark Unicode Character
  3. the last EOL is missing

mjf avatar Oct 11 '24 11:10 mjf

thank you for pointing to the potential causes.

i just ran into the same issue and was able to verify these conditions:

  1. i started a code block ```yaml
  2. i entered 2 lines into it (not pressing enter on the end of the second line)
  3. i used up-arrow key to get out of the block
  4. the whole application became unusable (while on that specific page)

so i went to test what is really causing this.

in my case the quotation marks did not make a difference. tried both, and even not closed. did not cause an issue for me.

but "code block is not ended" causes an issue for me IF there is no newline at the last line. although it works if not ended BUT the last line has a newline

also: ending the code block (with 3 backticks) BUT still having no newline after that, also works.

i fixed my file outside of silverbullet, but silverbullet itself was used to get the file into an invalid state (see the 4 steps above).

hopefully this helps in pinpointing the underlying code issue / edge case

elgarfo avatar Jun 26 '25 12:06 elgarfo