Skip to content

Linter: "Failed to initialize buffer with capacity of X" errorΒ #1429

@jeromedalbert

Description

@jeromedalbert

Description

On version 0.8.10, running yarn herb-lint on my codebase only takes ~900ms.

But on version 0.9.0, yarn herb-lint never seems to end. The last line of the following output takes a while to appear:

$ yarn herb-lint
yarn run v1.22.22
$ /Users/jerome/c/myrepo/node_modules/.bin/herb-lint
βœ“ Using Herb config file at /Users/jerome/c/myrepo/.herb.yml
Error: Failed to initialize buffer with capacity of 2787.

This error message is similar to the last output line in issue #1016. The program then continues running, at which point I decide to exit because my CPU maxes out at 300%-600%.

I then ran yarn herb-lint app/**/*.html.erb packs/**/*.html.erb, and after some bisecting I was able to more or less find a problematic file.

Repro steps

Run yarn herb-lint on the following test.html.erb file:

<%= my_table(
      data: @things,
    ) do |table|
    table.with_column(
      value: lambda do |thing|
        tag.div class: "flex justify-end" do
          action_menu_id = "thing-#{thing.id}-action-menu"
          my_action_menu(id: action_menu_id) do |menu|
            menu.with_trigger do
              tag.button(
                my_icon(icon: "some-icon", size: :medium),
                **popover_trigger_attributes(
                  popovertarget: action_menu_id
                ),
                class: "rounded p-0.5 hover:bg-neutral",
                aria: { label: "Thing #{thing.id} actions" }
              )
            end
            if thing.processed?
              thing.available_manage_actions.each do |action|
                menu.with_item do
                  link_to(t(".table.header.actions.#{action}"), "/foo/#{current_location.id}/bar/things/#{thing.id}/edit?thing_action=#{action}&some_object_id=#{@some_object.id}", data: { testid: "thing-#{thing.id}-action-#{action}" })
                end
              end
            end
          end
        end
      end
    )
end %>

While I don't get a "Failed to initialize buffer" error message, linting never ends and my CPU is maxed at 100%. I waited 20 minutes before exiting.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinglinter

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions