Skip to content

Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.

docs: discourage Download.createReadStream (#37831)

Simon Knott25ca30f7ff92
diff --git a/docs/src/api/class-download.md b/docs/src/api/class-download.md
index 3333d36996..11b0c68e15 100644
--- a/docs/src/api/class-download.md
+++ b/docs/src/api/class-download.md
@@ -74,6 +74,10 @@ Upon successful cancellations, `download.failure()` would resolve to `'canceled'
Returns a readable stream for a successful download, or throws for a failed/canceled download.
+:::note
+If you don't need a readable stream, it's usually simpler to read the file from disk after the download completed. See [`method: Download.path`].
+:::
+
## async method: Download.delete
* since: v1.8
diff --git a/packages/playwright-client/types/types.d.ts b/packages/playwright-client/types/types.d.ts
index c510663fcc..a04bcc1fc1 100644
--- a/packages/playwright-client/types/types.d.ts
+++ b/packages/playwright-client/types/types.d.ts
@@ -19106,6 +19106,10 @@ export interface Download {
/**
* Returns a readable stream for a successful download, or throws for a failed/canceled download.
+ *
+ * **NOTE** If you don't need a readable stream, it's usually simpler to read the file from disk after the download
+ * completed. See [download.path()](https://playwright.dev/docs/api/class-download#download-path).
+ *
*/
createReadStream(): Promise<Readable>;
diff --git a/packages/playwright-core/types/types.d.ts b/packages/playwright-core/types/types.d.ts
index c510663fcc..a04bcc1fc1 100644
--- a/packages/playwright-core/types/types.d.ts
+++ b/packages/playwright-core/types/types.d.ts
@@ -19106,6 +19106,10 @@ export interface Download {
/**
* Returns a readable stream for a successful download, or throws for a failed/canceled download.
+ *
+ * **NOTE** If you don't need a readable stream, it's usually simpler to read the file from disk after the download
+ * completed. See [download.path()](https://playwright.dev/docs/api/class-download#download-path).
+ *
*/
createReadStream(): Promise<Readable>;