Skip to content
This repository has been archived by the owner on Oct 11, 2024. It is now read-only.

Commit

Permalink
Fix ics high memory usage by disabling auto wrap text in html2text
Browse files Browse the repository at this point in the history
  • Loading branch information
meain committed Feb 23, 2024
1 parent f3fdb4a commit 796a0dd
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/internal/converters/ics/ics.go
Original file line number Diff line number Diff line change
Expand Up @@ -484,7 +484,14 @@ func updateEventProperties(ctx context.Context, event models.Eventable, iCalEven
desc := replacer.Replace(description)
iCalEvent.AddProperty("X-ALT-DESC", desc, ics.WithFmtType("text/html"))
} else {
stripped, err := html2text.FromString(description, html2text.Options{PrettyTables: true})
// Disable auto wrap, causes huge memory spikes
// https://github.com/jaytaylor/html2text/issues/48
prettyTablesOptions := html2text.NewPrettyTablesOptions()
prettyTablesOptions.AutoWrapText = false

stripped, err := html2text.FromString(
description,
html2text.Options{PrettyTables: true, PrettyTablesOptions: prettyTablesOptions})
if err != nil {
return clues.Wrap(err, "converting html to text").
With("description_length", len(description))
Expand Down

0 comments on commit 796a0dd

Please sign in to comment.