question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

gitGraph throws error in wrong format for live editor.

See original GitHub issue

Describe the bug

Cannot change the main branch to anything.

To Reproduce Go to https://mermaid.live and select Git Graph from the samples pane.

Change config to this:

{
  "theme": "default",
  "gitGraph": {
    "mainBranchName": "trunk"
  }
}

Go back to the diagram and try to change main to trunk. It blinks and won’t change anything. The console lights up with errors like this:

Uncaught Error: D.hash.loc is undefined

S@https://mermaid.live/_app/pages/edit.svelte-6f83f87b.js:109:13610
ln/</<@https://mermaid.live/_app/chunks/index-3ccfa173.js:4:906
ln/<@https://mermaid.live/_app/chunks/index-3ccfa173.js:4:892
In/</</<@https://mermaid.live/_app/pages/edit.svelte-6f83f87b.js:14:1891

Trying it the other way around - changing main to trunk in the editor first (before config), logs that a branch isn’t created yet, as expected, then changing main in config to trunk resets the editor back to main.

Expected behavior

The editor shall allow users to change the name of the main branch to an arbitrary name.

Desktop (please complete the following information):

  • OS: Windows 10
  • Browser: FireFox, Chrome
  • Version: both latest, as of this post

Issue Analytics

  • State:closed
  • Created a year ago
  • Reactions:3
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
ashishjain0512commented, Aug 23, 2022

This issue is now fixed. Verified in Mermaid Live Editor against mermaid v9.1.6

1reaction
sidharthv96commented, Jun 28, 2022

@ashishjain0512, I’m fixing the editor hanging issue in mermaid-js/mermaid-live-editor#864. But the issue happened because the Error thrown by the gitGraph is totally different from the Error thrown by other diagram types. It lacks the e.hash.loc data, so we can’t highlight where the error is in the code.

My current fix handles the situation and shows the thrown error above the diagram, but we should standardize the errors thrown by all diagram types.

try {
    mermaid.parse(state.code);
  } catch (e) {
    processed.error = e;
    console.error(e);
    if (e.hash) {
      try {
        const marker: MarkerData = {
          severity: 8, // Error
          startLineNumber: e.hash.loc.first_line,
          startColumn: e.hash.loc.first_column,
          endLineNumber: e.hash.loc.last_line,
          endColumn: (e.hash.loc.last_column as number) + 1,
          message: e.str
        };
        processed.errorMarkers = [marker];
      } catch (err) {
        console.error('Error without line helper', err);
      }
    }
  }
Read more comments on GitHub >

github_iconTop Results From Across the Web

gitGraph throws error in wrong format for live editor. #3191
Go to https://mermaid.live and select Git Graph from the samples pane. Change config to this: { "theme": "default", "gitGraph" ...
Read more >
How can I fix git commit error "Waiting for your editor to close ...
The issue seems due to the gutentags plugin. So, if you arrived here because you are getting the Waiting for your editor to...
Read more >
Mermaid support for class diagrams and state diagrams
Wiki editor supports only a limited set of mermaid's diagram types. I guess with a simple mermaid upgrade we could get both class...
Read more >
Changelog - Mermaid zh-cn doc - Hello Wac
live editor latin error after update #560; Simple full example in online documentation is broken #558; Graph No Arrow Head v7.0.3 #543; Conflict ......
Read more >
VS Code tips — The Git Graph extension - YouTube
Get visual and interactive view of the current .git repository with the Git Graph extension for VS Code.Browse through commits, switch ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found