microsoft / microsoft/playwright
[Feature]: Allow route fulfillment with a readable stream body
Open
Nobody has claimed this yet.
P3-collecting-feedback
- Dominant language
- TypeScript
- Stars
- 96.4k
- Forks
- 6.5k
- Avg merge
- 1d 6h
- Merged PRs (30d)
- 180
Description
🚀 Feature Request
Currently, Route.fulfill only accepts string|Buffer as body type. Add nodejs type ReadableStream to permit streamed calls.
Example
const bodyStream = new Readable();
await page.route('**/*', async route => {
route.fulfill({
status: 200,
contentType: 'application/grpc-web+proto',
body: bodyStream
});
});
// @todo interact with page
bodyStream.push(chunk);
// @todo assert on DOM state
bodyStream.push(chunk);
// @todo assert on updated DOM state
bodyStream.destroy();
// @todo assert request completed
Motivation
There are several use-cases where this is useful:
- stubbing grpc-web calls that are server streaming - the test script could push events into the stream and assert the expected in-progress result is displayed in the webview
- stubbing server-sent events
- stubbing streams of other kinds (live video?)
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at the Route.fulfill and page.route entry points, then trace how the current string|Buffer body is handled. Check how a Node.js Readable stream would flow through fulfillment and verify the grpc-web, server-sent events, and incremental-body examples complete as expected.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- node.js, typescript
- Domain
- api
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100