Skip to content

Refactor common Playwright wrappers as services - #31

Merged
fiws merged 1 commit into
mainfrom
fix-common-wrapper-services
Sep 3, 2026
Merged

Refactor common Playwright wrappers as services#31
fiws merged 1 commit into
mainfrom
fix-common-wrapper-services

Conversation

@fiws

@fiws fiws commented Sep 3, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • replace common Playwright Data.TaggedClass wrappers with Context.Service values and named constructors
  • migrate internal callsites and public exports to the named constructors
  • fix receiver loss in Request.failure, Request.postData, and Request.postDataBuffer
  • wrap synchronous Request.postDataJSON parsing with Effect.try

Closes #29
Closes #30

Verification

  • pnpm test src/common.test.ts
  • pnpm test src/playwright.test.ts
  • pnpm type-check
  • pnpm build
  • Biome checks for changed source and test files

Note

Medium Risk
Breaking public API for six common event/network wrappers affects all consumers; Request wrapper changes alter error and binding semantics on widely used network APIs.

Overview
Breaking (0.8.0): Request, Response, Worker, Dialog, FileChooser, and Download are no longer Data.TaggedClass models. They are now Context.Service interfaces with makeRequest, makeResponse, makeWorker, makeDialog, makeFileChooser, and makeDownload exported on Playwright. Wrapped values no longer have _tag; use the named constructors instead of Playwright.Request.make(...).

Event mappings on Page and BrowserContext and the public playwright-api exports were updated to the new constructors. Agent docs and CHANGELOG describe the Effect 4 / service pattern.

Request behavior fixes: postData, postDataBuffer, and failure call the native methods with correct this binding. postDataJSON is wrapped in Effect.try and maps nullish results to Option. Tests cover these cases and assert services via Effect.provideService instead of _tag.

Reviewed by Cursor Bugbot for commit 5b087bb. Bugbot is set up for automated code reviews on this repo. Configure here.

@pkg-pr-new

pkg-pr-new Bot commented Sep 3, 2026

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/effect-playwright@5b087bb

commit: 5b087bb

@fiws
fiws requested a review from StefanWerW September 3, 2026 08:02
@fiws fiws self-assigned this Sep 3, 2026
@fiws
fiws force-pushed the fix-common-wrapper-services branch 2 times, most recently from 0a3ff0f to d757915 Compare September 3, 2026 08:07
@fiws
fiws force-pushed the fix-common-wrapper-services branch from d757915 to 5b087bb Compare September 3, 2026 08:09
@fiws
fiws merged commit 4d4a11a into main Sep 3, 2026
5 checks passed
@fiws
fiws deleted the fix-common-wrapper-services branch September 3, 2026 08:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Request.postDataJSON fails because its synchronous result is passed to Effect.tryPromise Request.postData loses the Playwright receiver and throws

2 participants