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

drawExcludeDays() in gannt chart renderer can loop infinitely #4353

Closed
toolness opened this issue Apr 27, 2023 · 5 comments · Fixed by #4367
Closed

drawExcludeDays() in gannt chart renderer can loop infinitely #4353

toolness opened this issue Apr 27, 2023 · 5 comments · Fixed by #4367

Comments

@toolness
Copy link
Contributor

toolness commented Apr 27, 2023

Description

Creating certain kinds of gannt charts will cause the Mermaid renderer to hang. Looking at the debugger, it appears to be stuck infinitely iterating over this loop:

while (d.valueOf() <= maxTime) {
if (diagObj.db.isInvalidDate(d, dateFormat, excludes, includes)) {
if (!range) {
range = {
start: d,
end: d,
};
} else {
range.end = d;
}
} else {
if (range) {
excludeRanges.push(range);
range = null;
}
}
d = d.add(1, 'd');
}

Steps to reproduce

Try rendering the attached Mermaid code in the live editor, it will hang.

(Note that while you can paste this into the Mermaid live editor, you'll probably want to reset its site data after experiencing the hang, as the live editor appears to always load its previous input on page load.)

Code Sample

gantt
    title PlanA release schedule
    dateFormat YYYYMMDD
    axisFormat  %m/%d
		tickInterval 2day
		todayMarker off

				foo: blarg, 20230320, 20230513
        bar: milestone, prodthingy, 20230417, 0d

    section staging release
				Auth build : active, BOOP, 20230301, 20230420
				Auth stg release: crit, BOOPstg, after BOOP, 1d
				BONK set up : BLOP, 202304, 20d
				BONK stg release: crit, BLOPstg, after BLOP, 1d
    section test
				Auth test: BOOPtest, after BOOPstg, 7d
				BONK test: BLOPtest, after BLOPstg, 20230511

    section product release
        prod release: crit, release, 20230512, 1d

Setup

  • Mermaid version: 10.1.0

  • Browser and Version: Tested on Chrome 112.0.5615.137 and Safari 16.3.

  • Note that this bug does not occur on Firefox 112, which throws a Invalid date:202304 error. Perhaps this suggests that Chrome and Safari may be parsing dates in a way that leads to some kind of infinite loop?

Additional Context

No response

@toolness toolness added Status: Triage Needs to be verified, categorized, etc Type: Bug / Error Something isn't working or is incorrect labels Apr 27, 2023
@toolness
Copy link
Contributor Author

toolness commented May 1, 2023

Update: I just discovered that this bug doesn't occur on Firefox. Added the following to the issue description

  • Note that this bug does not occur on Firefox 112, which throws a Invalid date:202304 error. Perhaps this suggests that Chrome and Safari may be parsing dates in a way that leads to some kind of infinite loop?

@toolness
Copy link
Contributor Author

toolness commented May 1, 2023

Hmm, maybe I should just fix this myself? @sidharthv96 if i want to try fixing it myself, should I just go ahead and do it, or does the issue need to be assigned to me first?

@sidharthv96
Copy link
Member

@toolness that'd be great.

You don't have to be assigned to start working on issues. All open issues without PRs are for everyone to take a shot at.

@toolness
Copy link
Contributor Author

toolness commented May 2, 2023

Ok here you go @sidharthv96! #4367

@toolness
Copy link
Contributor Author

toolness commented May 2, 2023

@sidharthv96 also, I'd like to make another documentation PR which I describe here, let me know if you think it's a good idea: #866 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants