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

SSR performance issue with HTML in markdown #190

Closed
jsonmaur opened this issue Jul 6, 2018 · 2 comments · Fixed by #192
Closed

SSR performance issue with HTML in markdown #190

jsonmaur opened this issue Jul 6, 2018 · 2 comments · Fixed by #192

Comments

@jsonmaur
Copy link

jsonmaur commented Jul 6, 2018

I've found a strange bug in v6.6.8 that is seriously impacting performance during SSR. When the markdown contents have a specific combination of colons and HTML, it sometimes takes around 30-40 seconds to render (on a 2.6GHz i5 Mac Mini), and will occasionally completely freeze. It also pushes the CPU usage to 100% for the entire duration of the program.

We had some auto-triggered builds that were generating large static markdown sites, and the builds started to freeze and timeout since 6.6.8 was released. I've put together a simple example that is able to replicate this on a small scale:

index.js
import fs from 'fs'
import React from 'react'
import Markdown from 'markdown-to-jsx'
import { renderToString } from 'react-dom/server'

// renders immediately
const good = `# This is a normal markdown file. <a href="/">Foo Bar</a>`
console.log(renderToString(<Markdown>{good}</Markdown>))

// takes a long time with high CPU
const bad = `Lorum *ipsum*: <a href="" style="float: right"><small>foo</small></a><span style="float: right"><small>&nbsp;</small></span><a href="" style="float: right"><small>bar</small></a>`
console.log(renderToString(<Markdown>{bad}</Markdown>))
package.json
{
  "scripts": {
    "start": "babel-node index.js"
  },
  "dependencies": {
    "babel-cli": "6.26.0",
    "babel-core": "6.26.3",
    "babel-preset-env": "1.7.0",
    "babel-preset-react": "6.24.1",
    "markdown-to-jsx": "6.6.8",
    "react": "16.4.1",
    "react-dom": "16.4.1"
  },
  "babel": {
    "presets": [
      "env",
      "react"
    ]
  }
}

I haven't been able to nail down exactly which part of the bad markdown string is causing the issue, as removing different pieces will make the render time fluctuate--sometimes making it longer, sometimes shorter. It's weird. Downgrading to v6.6.7 fixes the issue.

@quantizor
Copy link
Owner

quantizor commented Jul 6, 2018 via email

@quantizor
Copy link
Owner

Fixed in 6.6.9

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

Successfully merging a pull request may close this issue.

2 participants