pub struct PlaywrightServer {
pub process: Child,
}Expand description
Manages the Playwright server process lifecycle
The PlaywrightServer wraps a Node.js child process that runs the Playwright driver. It communicates with the server via stdio pipes using JSON-RPC protocol.
§Example
let server = PlaywrightServer::launch().await?;
// Use the server...
server.shutdown().await?;Fields§
§process: ChildThe Playwright server child process
This is public to allow integration tests to access stdin/stdout pipes. In production code, you should use the Connection layer instead of accessing the process directly.
Implementations§
Source§impl PlaywrightServer
impl PlaywrightServer
Sourcepub async fn launch() -> Result<Self>
pub async fn launch() -> Result<Self>
Launch the Playwright server process
This will:
- Check if the Playwright driver exists (download if needed)
- Launch the server using
node <driver>/cli.js run-driver - Set environment variable
PW_LANG_NAME=rust
§Errors
Returns Error::ServerNotFound if the driver cannot be located.
Returns Error::LaunchFailed if the process fails to start.
Sourcepub async fn shutdown(self) -> Result<()>
pub async fn shutdown(self) -> Result<()>
Shut down the server gracefully
Sends a shutdown signal to the server and waits for it to exit.
§Platform-Specific Behavior
Windows: Explicitly closes stdio pipes before killing the process to avoid hangs. On Windows, tokio uses a blocking threadpool for child process stdio, and failing to close pipes before terminating can cause the cleanup to hang indefinitely. Uses a timeout to prevent permanent hangs.
Unix: Uses standard process termination with graceful wait.
§Errors
Returns an error if the shutdown fails or times out.