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

Maximum call stack size exceeded RangeError: Maximum call stack size exceeded #315

Open
xhaferd opened this issue Jun 3, 2024 · 1 comment

Comments

@xhaferd
Copy link

xhaferd commented Jun 3, 2024

I am using this library within a lambda function to convert email contents to plain text, since Microsoft Graph API returns them in HTML format. In one execution it processes about 20-30 emails in parallel.

I am getting the following error:

ERROR	Maximum call stack size exceeded RangeError: Maximum call stack size exceeded
    at Array.flatMap (<anonymous>)
    at /var/task/node_modules/@selderee/plugin-htmlparser2/lib/hp2-builder.cjs:13:38
    at /var/task/node_modules/@selderee/plugin-htmlparser2/lib/hp2-builder.cjs:40:33
    at /var/task/node_modules/@selderee/plugin-htmlparser2/lib/hp2-builder.cjs:13:51
    at Array.flatMap (<anonymous>)
    at Picker.f (/var/task/node_modules/@selderee/plugin-htmlparser2/lib/hp2-builder.cjs:13:38)
    at Picker.pick1 (/var/task/node_modules/selderee/lib/selderee.cjs:426:30)
    at recursiveWalk (/var/task/node_modules/html-to-text/lib/html-to-text.cjs:1241:46)
    at f1 (/var/task/node_modules/html-to-text/lib/html-to-text.cjs:27:44)
    at formatBlock$1 (/var/task/node_modules/html-to-text/lib/html-to-text.cjs:1324:3)

and this is the code:

export const convertHtmlToText = (html: string): string => {
    const text = htmlToText(html, {
        wordwrap: null, // Disable word wrapping
    });
    return text;
}
@KillyMXI
Copy link
Member

KillyMXI commented Jun 3, 2024

Usually happens on very badly formed HTML. Like when someone put an unescaped stack trace inside.

Error message tells me very little without the HTML that causes this.

We have some protection against large input, but cloud functions may have even stricter limitations.
You may need to adjust limits options to sensible values.

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

No branches or pull requests

2 participants