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

Introduces @packages/network-tools for shared browser/node networking utils and rebuilds @packages/network as a CJS/ESM bundle, updating imports and refactoring code (incl. async/await) across the repo and CI.

  • Packages:
    • New @packages/network-tools: exports cors, uri, document-domain-injection, and types; adds CJS/ESM builds, tsconfig, tests.
    • Rebuilt @packages/network: removes browser-focused utils, adds CJS/ESM build targets; refactors agent, connect, allow-destroy, client certs, and exports (incl. strictAgent).
  • Codebase updates:
    • Replace imports from @packages/network/lib/* with @packages/network-tools in config, driver (origin validation, location), proxy (request/response middleware, buffers, cookies), and server (cloud APIs, routes, controllers, remote_states, ensure-url, server-base).
    • Refactor several modules from Bluebird to native async/await and improve types; adjust tests accordingly.
  • CI & Docs:
    • CircleCI: build order tweaks and ensure @packages/network-tools/@packages/network built before binary checks.
    • ESM migration guide: mark network and network-tools as completed.
  • Misc: add TS deps where needed (eg. v8-snapshot), update package scripts/tsconfigs.

Written by Cursor Bugbot for commit 91201d8. 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 #66311

Run Properties:  status check failed Failed #66311  •  git commit 91201d81e8: chore: fix cloud specs
Project cypress
Branch Review chore/network-bundle
Run status status check failed Failed #66311
Run duration 19m 57s
Commit git commit 91201d81e8: chore: fix cloud specs
Committer Bill Glesias
View all properties for this run ↗︎

Test results
Tests that failed  Failures 2
Tests that were flaky  Flaky 13
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  commands/location.cy.js • 1 flaky test • 5x-driver-electron

View Output

Test Artifacts
... > does not log an additional log on failure Test Replay
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  e2e/origin/config_env.cy.ts • 1 flaky test • 5x-driver-inject-document-domain-chrome

View Output

Test Artifacts
cy.origin- Cypress.config() > serializable > overwrites different values in secondary if one exists in the primary Test Replay
Flakiness  commands/location.cy.js • 1 flaky test • 5x-driver-chrome

View Output

Test Artifacts
... > does not log an additional log on failure Test Replay
Flakiness  e2e/origin/config_env.cy.ts • 1 flaky test • 5x-driver-chrome

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 13 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
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