Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] TypeError: Cannot read properties of undefined (reading 'editor') #503

Open
Cito opened this issue Jan 10, 2024 · 5 comments · May be fixed by #517
Open

[BUG] TypeError: Cannot read properties of undefined (reading 'editor') #503

Cito opened this issue Jan 10, 2024 · 5 comments · May be fixed by #517
Labels
bug Something isn't working

Comments

@Cito
Copy link

Cito commented Jan 10, 2024

Describe the bug

After starting Obsidian, the following error message appears in the developer console:

app.js:1 TypeError: Cannot read properties of undefined (reading 'editor')
    at t.get (app.js:1:2074065)
    at getEditorFromState (VM230 plugin:obsidian-outliner:88:13)
    at VerticalLinesPluginValue.waitForEditor (VM230 plugin:obsidian-outliner:2552:28)
    at new VerticalLinesPluginValue (VM230 plugin:obsidian-outliner:2602:14)
    at e.eval [as create] (VM230 plugin:obsidian-outliner:2795:82)
    at e.update (app.js:1:362106)
    at e.setState (app.js:1:462573)
    at t.clear (app.js:1:1360629)
    at t.clear (app.js:1:2068961)
    at t [as constructor] (app.js:1:1357528)
    at t [as constructor] (app.js:1:1377268)
    at new t (app.js:1:2068323)
    at new t (app.js:1:2072393)
    at app.js:1:1770557
    at t.<anonymous> (app.js:1:1826837)
    at app.js:1:237258
    at Object.next (app.js:1:237363)
    at a (app.js:1:236081)

To Reproduce

Steps to reproduce the behavior:

Just starting Obsidian is enough. The current page doesn't even need to include an outline.

Expected behavior

There should be no error messages in the console.

Screenshots

If applicable, add screenshots to help explain your problem.

Environment (please complete the following information):

  • OS: Windows 11
  • Obsidian Version: 1.5.3
  • Plugin Version: [e.g. 4.6.2]

Additional context

I would investigate and try to provide a PR, but currently I'm not sure whether this plugin is still maintained given that no updates have appeared since months though many bug reports have been accumulated.

@Cito Cito added the bug Something isn't working label Jan 10, 2024
@dpiro
Copy link

dpiro commented Jan 12, 2024

Same issue here, upon launch of Obsidian app, causes delays with "launching..." screen while the following is displayed to console repeatedly. Have been running the plugin without issue for 1-2 years.

OS: MacOS
ObsidianVersion: 1.5.3
Plugin Version: 4.8.0

app.js:1 TypeError: Cannot read properties of undefined (reading 'editor')
at t.get (app.js:1:2074065)
at getEditorFromState (plugin:obsidian-outliner:88:13)
at VerticalLinesPluginValue.waitForEditor (plugin:obsidian-outliner:2552:28)
at new VerticalLinesPluginValue (plugin:obsidian-outliner:2602:14)
at e.eval [as create] (plugin:obsidian-outliner:2795:82)
at e.update (app.js:1:362106)
at e.setState (app.js:1:462573)
at t.clear (app.js:1:1360629)
at t.clear (app.js:1:2068961)
at t [as constructor] (app.js:1:1357528)

@ghost
Copy link

ghost commented Jan 15, 2024

export function getEditorFromState(state: EditorState) {
  const markdownFileInfo = state.field(editorInfoField);

  try {
    if (!markdownFileInfo.editor) {
      return null;
    }

    return new MyEditor(markdownFileInfo.editor);
  } catch {
    return null;
  }
}

It probably doesn't fix the issue, but you can hide the message by wrapping the function with a try-catch block.

@Elaws
Copy link

Elaws commented Feb 13, 2024

Same issue here, are there any news ? Thanks.

@Michael679089
Copy link

Describe the bug
Your plugin is giving me the "TypeError" in the console, clogging the console in the developer tools.

To Reproduce

Download Outliner
Open a note.
Check the developer tools (ctrl + shift + i)
See Console TypeError.
Expected behavior
A clear and concise description of what you expected to happen.

I expected it to work normally without it giving any errors.

Screenshots
If applicable, add screenshots to help explain your problem.

image

Environment (please complete the following information):

OS: Microsoft
Obsidian Version: v1.5.8
Plugin Version: v4.8.0
Additional context
None.

@Michael679089
Copy link

Michael679089 commented Mar 4, 2024

export function getEditorFromState(state: EditorState) {
  const markdownFileInfo = state.field(editorInfoField);

  try {
    if (!markdownFileInfo.editor) {
      return null;
    }

    return new MyEditor(markdownFileInfo.editor);
  } catch {
    return null;
  }
}

It probably doesn't fix the issue, but you can hide the message by wrapping the function with a try-catch block.

Where do you put that?

I just put it as javascript and it works:

function getEditorFromState(state) {
    const markdownFileInfo = state.field(obsidian.editorInfoField);

    try {
        if (!markdownFileInfo.editor) {
            return null;
        }

        return new MyEditor(markdownFileInfo.editor);
    } catch {
        return null;
    }
}

Out of sight, out of mind.

@ericbiewener ericbiewener linked a pull request Mar 26, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants