Skip to content

[Feature Request]: Ability to Abort/Cancel Requests for Images, Stylesheets, Media, and Fonts #123

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

Open
2 tasks done
naimish33 opened this issue Apr 23, 2025 · 1 comment
Labels
enhancement New feature or request

Comments

@naimish33
Copy link

naimish33 commented Apr 23, 2025

Checklist before requesting

  • I have searched for similar feature requests and didn't find a duplicate.
  • I have checked the documentation to confirm this feature doesn't already exist.

Problem Statement

Hiii

I've gone through the documentation but couldn't find a solution, so I'm reaching out here to ask.

Is there currently any support for aborting or canceling requests for images, stylesheets, media files, or fonts? Additionally, is there a way to wait specifically for a certain API response?

Please let me know if there’s anything related to this that I might have missed.

Thanks!

Proposed Solution

async def on_request(page, event):
request_id = event['params']['requestId']

        if event['params'].get('type') in ["Image", "Media", "Stylesheet", "Font"]:
            page._execute_command(
            FetchCommands.abort_request(request_id)
        )

like playwright provides method to do that

    if request.resource_type in ["image", "media", "stylesheet", "font"]:
        await route.abort()
    else:
        await route.continue_()```


### Alternatives Considered

_No response_

### Additional Context

_No response_

### Importance

Nice to have

### Contribution

None
@naimish33 naimish33 added the enhancement New feature or request label Apr 23, 2025
@thalissonvs
Copy link
Member

Hi @naimish33 , thanks for the suggestion! I'll work on this issue in the next few days

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants