Link parsing for UnsubscribeHeader lags with large threads


This is similar to Significant Lag on Large Threads, opening threads with many replies as well as opening messages within those threads lags for a considerable amount of time. I profiled this and it looks like this is due to the unsubscribe link parsing added in Feature/unsubscribe header by Phylu · Pull Request #2275 · Foundry376/Mailspring · GitHub. There is a note on that PR about the performance of cheerio being a potential issue, and it seems that is what’s causing the problem for me. The _getLinks function is very slow, with most of its time spent in calls to cheerio.

To Reproduce…

Steps to reproduce the behavior:

  1. Open thread with many replies, containing many links
  2. Application freezes for a short while

Expected Behavior

Thread opens smoothly



Reproducible as of commit 44853d81e70aac13de7de4d35708c4efebfded35

  • OS and Version: macOS 11.4
  • Installation Method: source
  • Mailspring Version: 1.9.1

Thanks. I will take a look and see if I can provide a fix for it.