Skip to content
This repository has been archived by the owner on Feb 26, 2024. It is now read-only.

fix: work around a Node v20.0.0-20.2.0 bug #4427

Merged
merged 3 commits into from
Aug 6, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions packages/ethereum/ethereum/src/forking/handlers/http-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,21 @@ import { BaseHandler } from "./base-handler";
import { Handler } from "../types";
import Deferred from "../deferred";

// Work around a node v20.0.0, v20.1.0, and v20.2.0 bug. The issue was fixed
// in v20.3.0.
// https://github.com/nodejs/node/issues/47822#issuecomment-1564708870
// Safe to remove once support for Node v20 is dropped.
if (
// webpack will replace process.env.IS_BROWSER with a boolean
!process.env.IS_BROWSER &&
process.versions &&
// check for `node` in case we want to use this in deno/bun/etc
process.versions.node &&
process.versions.node.match(/20\.[0-2]\.0/)
) {
require("net").setDefaultAutoSelectFamily(false);
}

const { JSONRPC_PREFIX } = BaseHandler;

export class HttpHandler extends BaseHandler implements Handler {
Expand Down