glossarify-md icon indicating copy to clipboard operation
glossarify-md copied to clipboard

One empty heading breaks glossarify-md, doesn't render any terms, terminates

Open christophcemper opened this issue 3 years ago • 0 comments

Describe the bug When you have a file with an empty H4 heading (####) somewhere in your source files, glossarify now runs forever, generates no links and then crashes with a terrible cryptic error message

It appears to have surfaced in the past weeks.

☛ Reading from: /home/christophc/learn_glossarify/docs
☛ Writing to:   /home/christophc/learn_glossarify/docs-glossarified

glossary.md: no issues found
pages/page1.md: no issues found
pages/page2.md: no issues found
TypeError: Cannot read properties of undefined (reading 'localeCompare')
    at file:///home/christophc/node_modules/glossarify-md/lib/exporter.js:60:42
    at Array.sort (<anonymous>)
    at exportGlossaries (file:///home/christophc/node_modules/glossarify-md/lib/exporter.js:60:10)
    at Module.run (file:///home/christophc/node_modules/glossarify-md/lib/main.js:26:15)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async file:///home/christophc/node_modules/glossarify-md/bin/index.js:210:13

To Reproduce glossarify-631-empty-header-defect.zip

Steps to reproduce the behavior:

I created a mini project, after spending hours isolating where the problem in our overall source code base was.

  1. unzip the file
  2. run npm glossarify
  3. get the same terrible error message

Expected behavior A clear and concise error message about which file, term, etc. was processed that caused the "undefined" crash.

Screenshots

image

Desktop (please complete the following information):

  • OS: Ubuntu 21.10
  • glossarify-md version: 6.3.1

christophcemper avatar Oct 27 '22 20:10 christophcemper