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

New function - Abort #41

Open
oliver-kriska opened this issue Aug 16, 2022 · 1 comment
Open

New function - Abort #41

oliver-kriska opened this issue Aug 16, 2022 · 1 comment

Comments

@oliver-kriska
Copy link

oliver-kriska commented Aug 16, 2022

Hello,
I would like to ask you about implementation abort function so we can skip some resources to load, especially in my case images and videos.
I made this function here:
https://github.com/geometerio/playwright-elixir/blob/ab729b6f6f1f4f6d9e238d5e97598757b968c548/lib/playwright/route.ex#L14-L15

@spec abort(t(), binary()) :: :ok
  defp abort(%Route{session: session} = route, error_code \\ nil) do
    Channel.post(session, {:guid, route.guid}, :abort, %{error_ode: error_code})
  end

and implementation:

Playwright.Page.route(page_loader, "**/*", fn route, request ->
      if request.resource_type in ["image", "font"] do
        Playwright.Route.abort(route, "blockedbyclient")
      else
        Playwright.Route.continue(route)
      end
    end)

But it crash server, I very new in playwright so not sure where can be problem.

Doc for abort is here and my code is here

@coreyti
Copy link
Member

coreyti commented Jan 8, 2023

Hi @oliver-kriska, a quick note:

@lexun and I were taking a look at this yesterday. It turns out that the immediate fix/implementation for Route.abort/2 as you implemented is not too difficult1, but we discovered some fun edge-case bugs while working on that.

So, thanks for creating this GitHub issue! It's going to lead to additional improvements. I hope to get those out shortly. And, thank you @lexun for your eyes and contributions on this.

Work in progress.

Footnotes

  1. indeed, I believe that you solved it later in your fork.

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