Skip to content

playwright-java is not thread-safe - wrap? #5

@vemv

Description

@vemv

Per https://github.com/microsoft/playwright-java/tree/b8a9d888be987b5ff522b542827d7a46fb8df90a#is-playwright-thread-safe :

Playwright is not thread safe, i.e. all its methods as well as methods on all objects created by it (such as BrowserContext, Browser, Page etc.) are expected to be called on the same thread where Playwright object was created or proper synchronization should be implemented to ensure only one thread calls Playwright methods at any given time.

By coincidence, I encountered that issue before reading that passage: if I tried to spawn multiple browsers in a pmap, it would fail opaquely.

Therefore it seems a good idea for Wally's API to prevent unsafe usage.

One possible approach would be to use ThreadLocals. And another, to use clojure.core/locking.

I might be able to offer a POC PR with a possible API if you'd appreciate that.

Cheers - V

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions