Skip to content

Conversation

AtofStryker
Copy link
Contributor

@AtofStryker AtofStryker commented Oct 2, 2025

  • Closes N/A

Additional details

This PR refactors @packages/network into two packages, @packages/network and @packages/network-tools.

Why are we doing this?

The refactor was prompted by the effort to make every package an independent bundle, where packages are built themselves and needed functions/modules are imported through the main package entrypoint and not importing the source directly. This means that:

import { module } from '@packages/network/path/to/not/transpiled/code' 

and would need to do

import { module }  from '@packages/network' 

Will no longer work as the the the source files are not compiled along side the module and are not shipped with the module. It may work in the monorepo, but it will FAIL when you attempt to build the binary. This means that the function needs to be imported from the package directly and not from a source file

This will change over time as we are able to update our TypeScript targets, but currently because we are bound to moduleResolution:'node', we can't leverage export paths, similar to how we do in the CLI. Eventually, when our internal packages are ESM-only, this type of pattern will be much less of a concern, but until we get there we need to adhere to this type of compiling/module building.

As a positive side effect, it makes individually type checking individual packages much easier as we can ship declaration types with the package, which is much better respected by skipLibCheck in the tsconfig.json vs importing directly from source, which means the package importing from another module has to completely TypeCheck the other module.

Right now, as we are in a grey area between sinon/mocha/chai and vitest, importing from src is usally fine in a testing context because the files are present. They are also much easier to mock in sinon then from a distributed package because sinon can't mock ES6 classes effectively. The only mechanism to do this is to stub the prototype, which is not ideal.

The new structure

@packages/network-tools only contains the cors, uri, and document domain utilities that are used commonly throughout the repo. This will likely include some of the cookie utils that are used in the server in the future to avoid circular dependencies between a given package and the server

@packages/network-tools only contains utilities and can run in either the browser OR the node context. @packages/network as a true distributed package contains a lot of node code, which means it can't run in the browser unless we polyfill the libraries needed or change them. The frontend modules only need the non-node utilities, hence the refactor.

With the refactor, I tried to remove bluebird references where possible and use async/await. Now that the types of changed for how the package is built, I needed to fix/add types in some areas. A couple types are failing in the server in the v8-snapshot task and to be honest, why that is currently is not clear to me, so those are handled with a ts-ignore.

Steps to test

How has the user experience changed?

PR Tasks


Note

Splits shared network utilities into a new @packages/network-tools package, refactors @packages/network to a buildable bundle with native promises, updates imports/usages across repo, and aligns CI/workflows and TS configs.

  • Packages:
    • @packages/network-tools (new): Adds browser/Node-safe utilities (cors, uri, document-domain-injection, types, tests, build configs).
    • @packages/network: Removes shared utils; focuses on Node code; adds CJS/ESM builds, TS configs; exposes CombinedAgent and strict agent.
  • Codebase-wide updates:
    • Replace imports from @packages/network/lib/* with @packages/network-tools where applicable (driver, proxy, server, config, tests).
    • Migrate Bluebird to native async/await in network modules (e.g., agent.ts, connect.ts, ca.ts, client certs) and adjust types.
    • Update cookie/CORS/URI helpers usage (origin, removeDefaultPort, urlMatchesOriginProtectionSpace, etc.).
  • Server/Cloud:
    • Use strictAgent/agent from @packages/network in cloud API; minor ESM/TS cleanups (machine_id, api).
  • Build/Tooling:
    • Add/adjust TS configs and scripts for CJS/ESM outputs in network and network-tools; add TypeScript devDeps where needed; README updates.
  • CI:
    • Reorder build steps and change workflow dependencies to require build before packaging artifacts (incl. linux-arm64); bump cache key.

Written by Cursor Bugbot for commit 207dd10. This will update automatically on new commits. Configure here.

cursor[bot]

This comment was marked as outdated.

cursor[bot]

This comment was marked as outdated.

Copy link

cypress bot commented Oct 2, 2025

cypress    Run #66345

Run Properties:  status check failed Failed #66345  •  git commit 207dd10c04: update pull-request job as well
Project cypress
Branch Review chore/network-bundle
Run status status check failed Failed #66345
Run duration 20m 35s
Commit git commit 207dd10c04: update pull-request job as well
Committer Bill Glesias
View all properties for this run ↗︎

Test results
Tests that failed  Failures 2
Tests that were flaky  Flaky 11
Tests that did not run due to a developer annotating a test with .skip  Pending 1102
Tests that did not run due to a failure in a mocha hook  Skipped 4
Tests that passed  Passing 26689
View all changes introduced in this branch ↗︎

Warning

Partial Report: The results for the Application Quality reports may be incomplete.

UI Coverage  45.11%
  Untested elements 186  
  Tested elements 157  
Accessibility  97.96%
  Failed rules  4 critical   8 serious   2 moderate   2 minor
  Failed elements 101  

Tests for review

Failed  cypress/e2e/studio/studio.cy.ts • 2 failed tests • app-e2e

View Output

Test Artifacts
Cypress Studio > updates an existing test with assertions Test Replay Screenshots
Cypress Studio > creates a new test from an empty spec Test Replay Screenshots
Flakiness  issues/28527.cy.ts • 1 flaky test • 5x-driver-electron

View Output

Test Artifacts
issue 28527 > fails and then retries and verifies about:blank is not displayed Test Replay Screenshots
Flakiness  commands/net_stubbing.cy.ts • 1 flaky test • 5x-driver-firefox

View Output

Test Artifacts
... > stops waiting when an xhr request is canceled
    </td>
  </tr></table>
Flakiness  commands/files.cy.js • 1 flaky test • 5x-driver-firefox

View Output

Test Artifacts
src/cy/commands/files > #readFile > retries to read when ENOENT
    </td>
  </tr></table>
Flakiness  issues/28527.cy.ts • 1 flaky test • 5x-driver-firefox

View Output

Test Artifacts
issue 28527 > fails and then retries and verifies about:blank is not displayed Screenshots
Flakiness  e2e/origin/config_env.cy.ts • 1 flaky test • 5x-driver-chrome:beta

View Output

Test Artifacts
cy.origin- Cypress.config() > serializable > overwrites different values in secondary if one exists in the primary Test Replay

The first 5 flaky specs are shown, see all 11 specs in Cypress Cloud.

@AtofStryker AtofStryker force-pushed the chore/network-bundle branch from 21c3259 to 2b03c2c Compare October 3, 2025 01:38
cursor[bot]

This comment was marked as outdated.

@AtofStryker AtofStryker force-pushed the chore/network-bundle branch 2 times, most recently from a6ac039 to eab0745 Compare October 3, 2025 15:14
@AtofStryker AtofStryker self-assigned this Oct 3, 2025
cursor[bot]

This comment was marked as outdated.

@AtofStryker AtofStryker force-pushed the chore/network-bundle branch 3 times, most recently from 187cfd7 to 267df5b Compare October 3, 2025 19:35
… network-tools is expected to be used in simple environments, where network is intended to be used in the node context. additionally, makes these packages bundable and removes the ts-node entrypoint to make ESM possible.
@AtofStryker AtofStryker force-pushed the chore/network-bundle branch from 267df5b to e9f5df0 Compare October 6, 2025 23:41
cursor[bot]

This comment was marked as outdated.

@AtofStryker AtofStryker changed the title chore (draft): package @packages/network as an independent bundle chore: package @packages/network as an independent bundle Oct 7, 2025
@AtofStryker AtofStryker force-pushed the chore/network-bundle branch from 9ede409 to fbda21d Compare October 8, 2025 16:35
@AtofStryker AtofStryker force-pushed the chore/network-bundle branch from fbda21d to 91201d8 Compare October 8, 2025 16:36
@AtofStryker AtofStryker force-pushed the chore/network-bundle branch from cad614f to 3af70f9 Compare October 9, 2025 21:30
@AtofStryker AtofStryker force-pushed the chore/network-bundle branch from 3af70f9 to 1a08c4c Compare October 9, 2025 21:36
cursor[bot]

This comment was marked as outdated.

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.

1 participant