Skip to content

feat: replace nodeify by async/await#656

Merged
bliuchak merged 9 commits into
version-3.0from
feat/nodeify-replacement-v3
May 5, 2026
Merged

feat: replace nodeify by async/await#656
bliuchak merged 9 commits into
version-3.0from
feat/nodeify-replacement-v3

Conversation

@bliuchak

Copy link
Copy Markdown
Contributor

Close #642

@bliuchak bliuchak self-assigned this Apr 30, 2026
@github-actions github-actions Bot added t-unblocking Issues with this label are in the ownership of the unblocking team. tested Temporary label used only programatically for some analytics. labels Apr 30, 2026

Copilot AI left a comment

Copy link
Copy Markdown

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 removes the internal nodeify helper and shifts the codebase (including tests/examples) toward pure async/await, while also moving the package to modern Node/ESM conventions.

Changes:

  • Remove nodeify and drop callback-style overloads in favor of promise-based APIs.
  • Migrate the package/tests/examples to ESM (type: module, NodeNext TS config, .js specifiers).
  • Update CI/test infrastructure for newer Node versions and address Node 20+ keep-alive/test flakiness.

Reviewed changes

Copilot reviewed 36 out of 38 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
tsconfig.json Switch TS compilation to NodeNext ESM settings.
package.json Declare ESM package, add exports, bump engines/typescript tooling.
.mocharc.json Preload tsx for test execution under ESM.
scripts/test-docker-all.sh Update Docker test matrix to newer Node versions.
test/Dockerfile Update Node base image for test container.
.github/workflows/release.yaml Workflow formatting + beta script rename to .cjs.
.github/workflows/check.yaml Update CI Node matrix and lint gating.
.github/scripts/before-beta-release.cjs New script to auto-increment beta prerelease versions.
README.md Update docs to ESM import style and newer Node behavior notes.
examples/apify_proxy_tunnel.js Convert example to ESM import style.
src/utils/valid_headers_only.ts Update local import specifier to .js.
src/utils/get_basic.ts Update local import specifier to .js.
src/utils/count_target_bytes.ts Refactor socket typing/assertion approach.
src/utils/nodeify.ts Remove nodeify helper implementation.
src/tcp_tunnel_tools.ts Remove callback overloads; return promises directly.
src/server.ts Remove callback overloads for listen/close; update ESM imports/types.
src/index.ts Update barrel exports to .js specifiers; export type-only CustomResponse.
src/forward_socks.ts Update local import specifiers to .js.
src/forward.ts Update local import specifiers to .js.
src/direct.ts Update local import specifiers to .js.
src/chain_socks.ts Update local import specifiers to .js.
src/chain.ts Update local import specifiers to .js.
src/anonymize_proxy.ts Remove callback overloads; return promises directly; update imports.
test/utils/throws_async.js Convert test helper to ESM exports/imports.
test/utils/testing_tcp_service.js Convert net import to node: ESM style.
test/utils/target_server.js Convert to ESM, update ws usage, adjust keep-alive for Node 20+.
test/utils/run_locally.js Convert to ESM and run via tsx script.
test/tools.js Convert to ESM imports; remove nodeify tests.
test/tcp_tunnel.js Convert to ESM; rewrite one test to async/await + try/finally cleanup.
test/socks.js Convert to ESM; rewrite tests to async/await.
test/server.js Convert to ESM; improve puppeteer stability + Node 20 behavior adjustments; refactor a test to async/await.
test/phantom_get.js Remove PhantomJS-specific script.
test/https-stress-test.js Convert to ESM; disable keep-alive behaviors that break tracking on Node 20+.
test/https-server.js Convert to ESM; remove external dependency by using local target; relax OpenSSL-variant assertion.
test/http-agent.js Convert to ESM.
test/ee-memory-leak.js Convert to ESM; rewrite test to async/await.
test/anonymize_proxy_no_password.js Convert to ESM; remove callback-style coverage and adjust Node 20+ error expectations.
test/anonymize_proxy.js Convert to ESM; rewrite callback/promise mixed tests to async/await.
Comments suppressed due to low confidence (1)

README.md:30

  • Server.listen() is now async-only (no callback), but the README examples still use server.listen(() => ...). Update these snippets to await server.listen() (or server.listen().then(...)) so the example actually runs and prints after the server is listening.
import { Server } from 'proxy-chain';

const server = new Server({ port: 8000 });

server.listen(() => {
    console.log(`Proxy server is listening on port ${server.port}`);
});

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread .github/workflows/check.yaml
Comment thread package.json
Comment thread README.md
Comment thread test/socks.js Outdated
Comment thread test/server.js Outdated
Comment thread test/ee-memory-leak.js Outdated
@jirimoravcik

Copy link
Copy Markdown
Member

I wonder if the target branch should be master?

@daniil-poletaev daniil-poletaev left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looks way cleaner with async/await 👍

Left few suggestions

Comment thread .github/workflows/check.yaml Outdated
Comment thread README.md
Comment thread test/socks.js
Comment thread test/anonymize_proxy_no_password.js Outdated
@bliuchak

bliuchak commented May 4, 2026

Copy link
Copy Markdown
Contributor Author

I wonder if the target branch should be master?

@jirimoravcik my bad, should be version-3

@bliuchak bliuchak changed the base branch from master to version-3.0 May 4, 2026 17:28
@bliuchak bliuchak requested a review from daniil-poletaev May 5, 2026 09:38
@bliuchak bliuchak merged commit 27916f0 into version-3.0 May 5, 2026
3 checks passed
@bliuchak bliuchak deleted the feat/nodeify-replacement-v3 branch May 5, 2026 12:00
bliuchak added a commit that referenced this pull request May 5, 2026
* feat!: update minimal supported version of Node.js to v20 (#638)
* chore: remove typeSocket assertion helper (#653)
* feat!: migrate from CJS to ESM (#654)
* feat: upgrade typescript to v5 (#655)
* feat!: replace nodeify by async/await (#656)
* chore: format changelog markdown
* docs: add new version info into changelog
* chore: bump package version to a major one

Close #637
@bliuchak bliuchak added the validated Issues that are resolved and their solutions fulfill the acceptance criteria. label May 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

t-unblocking Issues with this label are in the ownership of the unblocking team. tested Temporary label used only programatically for some analytics. validated Issues that are resolved and their solutions fulfill the acceptance criteria.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Prefer pure async/await instead of nodeify

5 participants