Skip to content

Conversation

@barjin
Copy link
Member

@barjin barjin commented Jul 1, 2025

Caused by a recent update of @types/node (see here DefinitelyTyped/DefinitelyTyped#73095). By implementing the missing methods (and wrapping other calls in @ts-ignore), this should fix the downstream build errors (e.g. here)

Closes #163

@barjin barjin requested review from B4nan, Copilot and vladfrangu July 1, 2025 08:10
@barjin barjin self-assigned this Jul 1, 2025
@barjin barjin added the adhoc Ad-hoc unplanned task added during the sprint. label Jul 1, 2025
@github-actions github-actions bot added this to the 118th sprint - Tooling team milestone Jul 1, 2025
@github-actions github-actions bot added the t-tooling Issues with this label are in the ownership of the tooling team. label Jul 1, 2025
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR addresses compatibility issues introduced by the new @types/node version by implementing missing methods and adding @ts-ignore comments to bypass stricter type definitions. Key changes include:

  • Updated proxy hook implementations with additional ts-ignore directives.
  • Extended the wrapped agent interface with new methods and type handling.
  • Adjusted ESLint rules to warn on ts-comment usage.

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.

File Description
src/hooks/proxy.ts Added ts-ignore annotations for HTTP/HTTPS proxy agent instantiation to resolve type narrowing issues.
src/agent/wrapped-agent.ts Implemented new methods (createConnection, keepSocketAlive, reuseSocket, getName) with ts-ignore usage.
src/agent/h1-proxy-agent.ts Modified constructors and connection creation functions with ts-ignore to comply with updated type definitions.
.eslintrc.json Updated ESLint configuration by adding a rule to warn on ts-comment usage.
Comments suppressed due to low confidence (1)

.eslintrc.json:12

  • [nitpick] Confirm that setting ban-ts-comment to warn aligns with the project’s long-term strategy for handling type suppressions, as current usage of @ts-ignore is widespread.
		"@typescript-eslint/ban-ts-comment": "warn"

constructor(options: AgentOptions) {
super(options);

// @ts-ignore New @types/node patch has narrower types than got-scraping exported interfaces
Copy link

Copilot AI Jul 1, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] Review the need for @ts-ignore here and consider adding a TODO for revisiting this once updated types are available.

Suggested change
// @ts-ignore New @types/node patch has narrower types than got-scraping exported interfaces
// @ts-expect-error New @types/node patch has narrower types than got-scraping exported interfaces
// TODO: Revisit this once updated types are available for @types/node or got-scraping.

Copilot uses AI. Check for mistakes.
return this;
}

createConnection(options: NetConnectOpts, callback?: (err: Error | null, stream: Duplex) => void): Duplex {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

or is the actual fix those new methods?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Partially, the linked @types/node PR adds those methods to the HttpAgent interface, so we need to implement those here to implement the interface correctly (so that TS doesn't throw compilation errors).

@barjin barjin merged commit 48dfe44 into master Jul 1, 2025
11 checks passed
@barjin barjin deleted the fix/wrapped-agent-implements branch July 1, 2025 10:02
@B4nan
Copy link
Member

B4nan commented Jul 1, 2025

seems to be working fine, lets ship a stable release right ahead i guess?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

adhoc Ad-hoc unplanned task added during the sprint. t-tooling Issues with this label are in the ownership of the tooling team.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

TypeScript Error: WrappedAgent incorrectly implements Agent interface

3 participants