Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Implementation:Microsoft Playwright ArtifactDispatcher

From Leeroopedia
Revision as of 11:35, 16 February 2026 by Admin (talk | contribs) (Auto-imported from implementations/Microsoft_Playwright_ArtifactDispatcher.md)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Knowledge Sources
Domains Dispatcher, Artifact
Last Updated 2026-02-12 00:00 GMT

Overview

Concrete tool for exposing server-side Artifact objects over the Playwright RPC protocol provided by the Playwright library.

Description

The `ArtifactDispatcher` class extends `Dispatcher` and implements `channels.ArtifactChannel` to bridge server-side `Artifact` objects to the client over the protocol. It provides `pathAfterFinished` to retrieve the artifact's local path after completion, `saveAs` to save the artifact to a specified path (using `StreamDispatcher` for efficient streaming), `saveAsStream` to return a readable stream, `stream` to get the artifact content as a stream, `failure` to check for errors, `cancel` to abort, and `delete` to remove the artifact. Static factory methods `from` and `fromNullable` handle dispatcher reuse and creation.

Usage

Use ArtifactDispatcher when the Playwright protocol layer needs to expose download, video, or trace artifacts to remote clients.

Code Reference

Source Location

  • Repository: Microsoft_Playwright
  • File: packages/playwright-core/src/server/dispatchers/artifactDispatcher.ts

Signature

export class ArtifactDispatcher extends Dispatcher<Artifact, channels.ArtifactChannel, DispatcherScope> implements channels.ArtifactChannel {
  _type_Artifact: boolean;
  static from(parentScope: DispatcherScope, artifact: Artifact): ArtifactDispatcher;
  static fromNullable(parentScope: DispatcherScope, artifact: Artifact | undefined): ArtifactDispatcher | undefined;
  async pathAfterFinished(params: channels.ArtifactPathAfterFinishedParams, progress: Progress): Promise<channels.ArtifactPathAfterFinishedResult>;
  async saveAs(params: channels.ArtifactSaveAsParams, progress: Progress): Promise<channels.ArtifactSaveAsResult>;
  async failure(params: channels.ArtifactFailureParams, progress: Progress): Promise<channels.ArtifactFailureResult>;
  async stream(params: channels.ArtifactStreamParams, progress: Progress): Promise<channels.ArtifactStreamResult>;
  async cancel(params: channels.ArtifactCancelParams, progress: Progress): Promise<channels.ArtifactCancelResult>;
  async delete(params: channels.ArtifactDeleteParams, progress: Progress): Promise<channels.ArtifactDeleteResult>;
}

Import

import { ArtifactDispatcher } from '../server/dispatchers/artifactDispatcher';

I/O Contract

Inputs

Name Type Required Description
parentScope DispatcherScope Yes Parent dispatcher scope for channel hierarchy
artifact Artifact Yes The server-side artifact object to expose
params.path string Yes (saveAs) Destination path for saving the artifact

Outputs

Name Type Description
value string Local path of the finished artifact
stream StreamDispatcher Readable stream for artifact content
error string or undefined Failure error message, if any

Usage Examples

import { ArtifactDispatcher } from '../server/dispatchers/artifactDispatcher';

const dispatcher = ArtifactDispatcher.from(parentScope, artifact);
const { value: path } = await dispatcher.pathAfterFinished({}, progress);
await dispatcher.saveAs({ path: '/downloads/file.pdf' }, progress);

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment