refactor(server): convert cdp_automation promise chains to async/await#34245
Open
AtofStryker wants to merge 1 commit into
Open
refactor(server): convert cdp_automation promise chains to async/await#34245AtofStryker wants to merge 1 commit into
AtofStryker wants to merge 1 commit into
Conversation
cypress
|
||||||||||||||||||||||||||||||||||||||||
| Project |
cypress
|
| Branch Review |
refactor/automation_client_p2
|
| Run status |
|
| Run duration | 19m 55s |
| Commit |
|
| Committer | Bill Glesias |
| View all properties for this run ↗︎ | |
| Test results | |
|---|---|
|
|
0
|
|
|
7
|
|
|
1124
|
|
|
0
|
|
|
26363
|
| View all changes introduced in this branch ↗︎ | |
UI Coverage
0%
|
|
|---|---|
|
|
4
|
|
|
0
|
Accessibility
100%
|
|
|---|---|
|
|
0 critical
0 serious
0 moderate
0 minor
|
|
|
0
|
2 tasks
Behavior-neutral conversion of packages/server/lib/browsers/cdp_automation.ts off bluebird and .then/.catch chains onto native async/await: - getAllCookies / getCookiesByUrl / getCookie become async functions - the onRequest set:cookie, set:cookies, clear:cookie, and take:screenshot cases await inline instead of chaining - Bluebird.mapSeries in clear:cookies becomes a sequential for...of loop, preserving the serial ordering and the undefined entries for cookies that no longer exist - _updateFrameTree's promise-with-async-executor becomes an async IIFE with identical resolution semantics The new Promise usages in activateMainTab (event listener + timeout race) and the intentionally unawaited .catch in _continueRequest are left as is. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
ec4798a to
b1d8540
Compare
MartinLVila
approved these changes
Jul 9, 2026
mschile
approved these changes
Jul 10, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Additional details
Stacked on #34244 (
refactor/automation_client_p1) — this PR targets that branch and only adds the one commit.This converts
packages/server/lib/browsers/cdp_automation.tsoff bluebird and.then/.catchchains onto native async/await. It is intended to be behavior neutral — no logic, ordering, or error-handling changes:getAllCookies/getCookiesByUrl/getCookiebecomeasyncfunctions; the explicit CDP response type annotations move from the callback parameters onto the awaited constsonRequestcases forset:cookie,set:cookies,clear:cookie, andtake:screenshotawait inline instead of chaining, preserving the same error messages and result shapesBluebird.mapSeriesinclear:cookiesbecomes a sequentialfor...ofloop — same serial execution (each cookie fetched and deleted before the next) and the sameundefinedentries in the result array for cookies that no longer exist_updateFrameTree'snew Promisewith an async executor becomes an async IIFE with identical resolution semantics (never rejects, nulls the in-flight marker before resolving)Deliberately left as-is: the two
new Promiseconstructions inactivateMainTab(an event-listener wait and a timeout race — the constructor is the right tool there), the intentionally unawaited.catchin_continueRequest(swallows lateInvalid InterceptionIderrors so they can't crash Cypress), and the already-nativePromise.allinreset:browser:state.This removes the last bluebird usage from this file, though
bluebirdremains a dependency of other server modules.Steps to test
No behavior change to validate — the existing suites cover every converted path:
Also verified green:
chrome_spec,electron_spec,cri-client_spec(consumers ofCdpAutomation),check-ts, and lint.How has the user experience changed?
No change.
PR Tasks
cypress-documentation?type definitions?Note
Low Risk
Behavior-neutral style modernization in CDP automation with no intended logic or ordering changes; existing unit specs cover the touched paths.
Overview
Mechanical refactor in
cdp_automation.ts: drops thebluebirdimport and rewrites cookie helpers, frame-tree updates, and severalonRequestbranches to native async/await instead of.then/.catchchains.Cookie paths (
getAllCookies,getCookiesByUrl,getCookie) and automation cases (set:cookie,set:cookies,clear:cookie,take:screenshot) keep the same CDP calls, error text, and return shapes; CDP response types are annotated on awaited results.clear:cookiesreplacesBluebird.mapSerieswith a sequentialfor...ofloop that still deletes one cookie at a time and still pushesundefinedwhen a cookie is missing._updateFrameTreeuses an async IIFE instead ofnew Promisewith an async executor, with the same non-rejecting behavior andgettingFrameTreecleanup.Intentionally unchanged:
activateMainTab’s listener/timeoutPromiseusage, the unawaited.catchonFetch.continueRequest, andPromise.allinreset:browser:state.Reviewed by Cursor Bugbot for commit b1d8540. Bugbot is set up for automated code reviews on this repo. Configure here.