Skip to content

Parsing HTML exceeding approximately 65,000 characters fails. #1

Description

@narumincho
import { HtmlParser } from "jsr:@nmyvision/html-parser@2.0.0";

const html = await (await fetch("https://deno.com/"))
  .text();

console.log(html.length); // 309979

console.log(new HtmlParser().parse(html));
309979
error: Uncaught (in promise) RangeError: Maximum call stack size exceeded
    super(...(text ? Array.from(text) : []));
    ^
    at new StringQueue (https://jsr.io/@nmyvision/html-parser/2.0.0/src/StringQueue.ts:11:5)
    at HtmlParser.parse (https://jsr.io/@nmyvision/html-parser/2.0.0/src/HtmlParser.ts:39:14)
    at ...

In the V8 engine used by Deno, an error occurs if the number of arguments passed to a constructor exceeds approximately 65,000.
To handle large inputs, instead of using the spread syntax (...items), pass an array directly.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions