Long render times when issue description contains trailing whitespace
This stems from debugging #1983 (closed)
In a development environment:
- Create a new issue, using https://gitlab.com/snippets/6509/raw as the description. Be sure to Select All so that the trailing whitespace at the end is included.
- Visit the issue's
show
page. This will take a long time (20-40 seconds on my local server).
Now comes the weirdness!
-
Open
app/views/projects/issues/show.html.haml
and remove or comment the following lines:%textarea.hidden.js-task-list-field = @issue.description
-
Open
app/views/projects/_zen.html.haml
and remove or comment the following line:= f.text_area attr, class: classes, placeholder: ''
-
View the issue again. It should load quickly.
But not having textarea
s isn't a solution. So let's try something else.
-
Undo the two removals/comments from above.
-
Open
app/views/projects/issues/show.html.haml
and remove or comment the following lines:= preserve do = markdown(@issue.description)
-
View the issue again. It should load quickly.
So that's... pretty weird. Rendering the description causes any textarea coming after it to bring the server-side page rendering to a crawl. What gives?
Haml does some whitespace preservation in textarea
s by default, where it replaces every newline with the HTML escape code 

. I'm not sure why this would have an effect here, but it sure seems to.
I tried disabling this behavior through its preserve
option to no avail.
I "fixed" this by changing = markdown(@issue.description)
to = markdown(@issue.description.gsub(/[[:space:]]+$/, '')
but that seems super hacky.