ronantakizawa/codereview-bench huggingface dataset:
Repository: denoland/deno
File: cli/tools/lint/mod.rs (Rust)

Code before:
        options: lint_options,
      });
    }
  }
  if paths_with_options_batches.is_empty() {
    return Err(generic_error("No target files found."));
  }
  Ok(paths_with_options_batches)
}

type WorkspaceModuleGraphFuture =
  SharedLocal<LocalBoxFuture<'static, Result<Rc<ModuleGraph>, Rc<AnyError>>>>;

struct WorkspaceLinter {
  caches: Arc<Caches>,
  lint_rule_provider: LintRuleProvider,
  module_graph_creator: Arc<ModuleGraphCreator>,
  workspace_dir: Arc<WorkspaceDirectory>,
  reporter_lock: Arc<Mutex<Box<dyn LintReporter + Send>>>,
  workspace_module_graph: Option<WorkspaceModuleGraphFuture>,
  has_error: Arc<AtomicFlag>,
  file_count: usize,
}

type WorkspaceLinterFuture =
  Pin<Box<dyn Future<Output = Result<(), AnyError>>>>;

impl WorkspaceLinter {
  pub fn new(
    caches: Arc<Caches>,
    lint_rule_provider: LintRuleProvider,
    module_graph_creator: Arc<ModuleGraphCreator>,
    workspace_dir: Arc<WorkspaceDirectory>,
    workspace_options: &WorkspaceLintOptions,
  ) -> Self {
    let reporter_lock =
      Arc::new(Mutex::new(create_reporter(workspace_options.reporter_kind)));
    Self {
      caches,
      lint_rule_provider,
      module_graph_creator,
      workspace_dir,
      reporter_lock,
      workspace_module_graph: None,
      has_error: Default::default(),
      file_count: 0,
    }
  }

  pub async fn lint_files(
    &mut self,

Review comment (suggestion):
Use `BoxFuture`? https://docs.rs/futures/latest/futures/future/type.BoxFuture.html

Code after:
    }
  }
  if paths_with_options_batches.is_empty() {
    return Err(generic_error("No target files found."));
  }
  Ok(paths_with_options_batches)
}

type WorkspaceModuleGraphFuture =
  SharedLocal<LocalBoxFuture<'static, Result<Rc<ModuleGraph>, Rc<AnyError>>>>;

struct WorkspaceLinter {
  caches: Arc<Caches>,
  lint_rule_provider: LintRuleProvider,
  module_graph_creator: Arc<ModuleGraphCreator>,
  workspace_dir: Arc<WorkspaceDirectory>,
  reporter_lock: Arc<Mutex<Box<dyn LintReporter + Send>>>,
  workspace_module_graph: Option<WorkspaceModuleGraphFuture>,
  has_error: Arc<AtomicFlag>,
  file_count: usize,
}

impl WorkspaceLinter {
  pub fn new(
    caches: Arc<Caches>,
    lint_rule_provider: LintRuleProvider,
    module_graph_creator: Arc<ModuleGraphCreator>,
    workspace_dir: Arc<WorkspaceDirectory>,
    workspace_options: &WorkspaceLintOptions,
  ) -> Self {
    let reporter_lock =
      Arc::new(Mutex::new(create_reporter(workspace_options.reporter_kind)));
    Self {
      caches,
      lint_rule_provider,
      module_graph_creator,
      workspace_dir,
      reporter_lock,
      workspace_module_graph: None,
      has_error: Default::default(),
      file_count: 0,
    }
  }

  pub async fn lint_files(
    &mut self,
    cli_options: &Arc<CliOptions>,
    lint_options: LintOptions,
    lint_config: DenoLintConfig,
    member_dir: WorkspaceDirectory,
    paths: Vec<PathBuf>,
Repository: denoland/deno
File: ext/node/polyfills/fs.ts (TypeScript)

Code before:
  O_RDONLY,
  O_WRONLY,
  O_RDWR,
  O_NOCTTY,
  O_TRUNC,
  O_APPEND,
  O_DIRECTORY,
  O_NOFOLLOW,
  O_SYNC,
  O_DSYNC,
  O_SYMLINK,
  O_NONBLOCK,
  O_CREAT,
  O_EXCL,
} = constants;

const promises = {
  access: accessPromise,
  constants,
  copyFile: copyFilePromise,
  cp: cpPromise,
  open: openPromise,
  opendir: opendirPromise,
  rename: renamePromise,
  truncate: truncatePromise,
  ftruncate: ftruncatePromise,
  rm: rmPromise,
  rmdir: rmdirPromise,
  mkdir: mkdirPromise,
  readdir: readdirPromise,
  readlink: readlinkPromise,
  symlink: symlinkPromise,
  lstat: lstatPromise,
  stat: statPromise,
  statfs: statfsPromise,
  fstat: fstatPromise,
  link: linkPromise,
  unlink: unlinkPromise,
  chmod: chmodPromise,
  // lchmod: promisify(lchmod),
  lchown: lchownPromise,
  chown: chownPromise,
  utimes: utimesPromise,
  lutimes: lutimesPromise,
  realpath: realpathPromise,
  mkdtemp: mkdtempPromise,
  writeFile: writeFilePromise,
  appendFile: appendFilePromise,
  readFile: readFilePromise,
  watch: watchPromise,
};

Review comment (suggestion):
Node doesn't seem having `fs.promises.ftruncate` (No doc entry for it, and also not available in runtime) https://nodejs.org/api/fs.html

Let's not expose it

Code after:
  O_TRUNC,
  O_APPEND,
  O_DIRECTORY,
  O_NOFOLLOW,
  O_SYNC,
  O_DSYNC,
  O_SYMLINK,
  O_NONBLOCK,
  O_CREAT,
  O_EXCL,
} = constants;

const promises = {
  access: accessPromise,
  constants,
  copyFile: copyFilePromise,
  cp: cpPromise,
  open: openPromise,
  opendir: opendirPromise,
  rename: renamePromise,
  truncate: truncatePromise,
  rm: rmPromise,
  rmdir: rmdirPromise,
  mkdir: mkdirPromise,
  readdir: readdirPromise,
  readlink: readlinkPromise,
  symlink: symlinkPromise,
  lstat: lstatPromise,
  stat: statPromise,
  statfs: statfsPromise,
  fstat: fstatPromise,
  link: linkPromise,
  unlink: unlinkPromise,
  chmod: chmodPromise,
  // lchmod: promisify(lchmod),
  lchown: lchownPromise,
  chown: chownPromise,
  utimes: utimesPromise,
  lutimes: lutimesPromise,
  realpath: realpathPromise,
  mkdtemp: mkdtempPromise,
  writeFile: writeFilePromise,
  appendFile: appendFilePromise,
  readFile: readFilePromise,
  watch: watchPromise,
};

export default {
  access,
  accessSync,
  appendFile,
Repository: denoland/deno
File: cli/tools/registry/pm/deps.rs (Rust)

Code before:
    while let Some(info_future) = info_futures.next().await {
      if let Some((specifier, info)) = info_future {
        let exports = info.exports();
        for (k, _) in exports {
          if let Ok(spec) = specifier.join(k) {
            roots.push(spec);
          }
        }
      }
    }

    self
      .module_load_preparer
      .prepare_module_load(
        graph,
        &roots,
        false,
        deno_config::deno_json::TsTypeLib::DenoWindow,
        self.permissions_container.clone(),
        None,
      )
      .await?;

    self
      .dependencies_resolved
      .store(true, std::sync::atomic::Ordering::Relaxed);
    graph_permit.commit();

    Ok(())
  }

  pub fn resolved_version(&self, id: DepId) -> Option<&PackageNv> {
    self.resolved_versions[id.0].as_ref()
  }

  pub async fn resolve_current_versions(&mut self) -> Result<(), AnyError> {
    self.run_dependency_resolution().await?;

    let graph = self.main_module_graph_container.graph();

    let mut resolved = Vec::with_capacity(self.deps.len());
    let snapshot = self.npm_resolver.as_managed().unwrap().snapshot();
    let resolved_npm = snapshot.package_reqs();
    let resolved_jsr = graph.packages.mappings();
    for dep in &self.deps {
      match dep.kind {
        DepKind::Npm => {
          let resolved_version = resolved_npm.get(&dep.req).cloned();
          resolved.push(resolved_version);
        }
        DepKind::Jsr => {

Review comment (suggestion):
We should change this to use `SyncFlag` sometime in the future as the api is slightly nicer.

Code after:
            roots.push(spec);
          }
        }
      }
    }

    self
      .module_load_preparer
      .prepare_module_load(
        graph,
        &roots,
        false,
        deno_config::deno_json::TsTypeLib::DenoWindow,
        self.permissions_container.clone(),
        None,
      )
      .await?;

    self.dependencies_resolved.raise();
    graph_permit.commit();

    Ok(())
  }

  pub fn resolved_version(&self, id: DepId) -> Option<&PackageNv> {
    self.resolved_versions[id.0].as_ref()
  }

  pub async fn resolve_current_versions(&mut self) -> Result<(), AnyError> {
    self.run_dependency_resolution().await?;

    let graph = self.main_module_graph_container.graph();

    let mut resolved = Vec::with_capacity(self.deps.len());
    let snapshot = self.npm_resolver.as_managed().unwrap().snapshot();
    let resolved_npm = snapshot.package_reqs();
    let resolved_jsr = graph.packages.mappings();
    for dep in &self.deps {
      match dep.kind {
        DepKind::Npm => {
          let resolved_version = resolved_npm.get(&dep.req).cloned();
          resolved.push(resolved_version);
        }
        DepKind::Jsr => {
          let resolved_version = resolved_jsr.get(&dep.req).cloned();
          resolved.push(resolved_version)
        }
      }
    }

    self.resolved_versions = resolved;
Repository: denoland/deno
File: .github/workflows/ci.generate.ts (TypeScript)

Code before:
  linuxX86: {
    os: "linux",
    arch: "x86_64",
    runner: ubuntuX86Runner,
  },
  linuxX86Xl: {
    os: "linux",
    arch: "x86_64",
    runner:
      `\${{ github.repository == 'denoland/deno' && '${ubuntuX86XlRunner}' || '${ubuntuX86Runner}' }}`,
  },
  linuxArm: {
    os: "linux",
    arch: "aarch64",
    runner: ubuntuARMRunner,
  },
  macosX86: {
    os: "macos",
    arch: "x86_64",
    runner: macosX86Runner,
  },
  macosArm: {
    os: "macos",
    arch: "aarch64",
    runner:
      `\${{ github.repository == 'denoland/deno' && '${selfHostedMacosArmRunner}' || '${macosArmRunner}' }}`,
  },
  windowsX86: {
    os: "windows",
    arch: "x86_64",
    runner: windowsX86Runner,
  },
  windowsX86Xl: {
    os: "windows",
    arch: "x86_64",
    runner:
      `\${{ github.repository == 'denoland/deno' && '${windowsX86XlRunner}' || '${windowsX86Runner}' }}`,
  },
} as const;

const prCacheKeyPrefix =
  `${cacheVersion}-cargo-target-\${{ matrix.os }}-\${{ matrix.arch }}-\${{ matrix.profile }}-\${{ matrix.job }}-`;
const prCacheKey = `${prCacheKeyPrefix}\${{ github.sha }}`;
const prCachePath = [
  // this must match for save and restore (https://github.com/actions/cache/issues/1444)
  "./target",
  "!./target/*/gn_out",
  "!./target/*/gn_root",
  "!./target/*/*.zip",
  "!./target/*/*.tar.gz",
].join("\n");

Review comment (suggestion):
```suggestion
      `\${{ github.repository == 'denoland/deno' && github.ref == 'refs/heads/main' && '${selfHostedMacosArmRunner}' || '${macosArmRunner}' }}`,
```

Code after:
  linuxX86: {
    os: "linux",
    arch: "x86_64",
    runner: ubuntuX86Runner,
  },
  linuxX86Xl: {
    os: "linux",
    arch: "x86_64",
    runner:
      `\${{ github.repository == 'denoland/deno' && '${ubuntuX86XlRunner}' || '${ubuntuX86Runner}' }}`,
  },
  linuxArm: {
    os: "linux",
    arch: "aarch64",
    runner: ubuntuARMRunner,
  },
  macosX86: {
    os: "macos",
    arch: "x86_64",
    runner: macosX86Runner,
  },
  macosArm: {
    os: "macos",
    arch: "aarch64",
    runner:
      `\${{ github.repository == 'denoland/deno' && github.ref == 'refs/heads/main' && '${selfHostedMacosArmRunner}' || '${macosArmRunner}' }}`,
  },
  windowsX86: {
    os: "windows",
    arch: "x86_64",
    runner: windowsX86Runner,
  },
  windowsX86Xl: {
    os: "windows",
    arch: "x86_64",
    runner:
      `\${{ github.repository == 'denoland/deno' && '${windowsX86XlRunner}' || '${windowsX86Runner}' }}`,
  },
} as const;

const prCacheKeyPrefix =
  `${cacheVersion}-cargo-target-\${{ matrix.os }}-\${{ matrix.arch }}-\${{ matrix.profile }}-\${{ matrix.job }}-`;
const prCacheKey = `${prCacheKeyPrefix}\${{ github.sha }}`;
const prCachePath = [
  // this must match for save and restore (https://github.com/actions/cache/issues/1444)
  "./target",
  "!./target/*/gn_out",
  "!./target/*/gn_root",
  "!./target/*/*.zip",
  "!./target/*/*.tar.gz",
].join("\n");
Repository: denoland/deno
File: cli/cache/incremental.rs (Rust)

Code before:
    "file_path TEXT PRIMARY KEY,",
    "state_hash INTEGER NOT NULL,",
    "source_hash INTEGER NOT NULL",
    ");"
  ),
  on_version_change: "DELETE FROM incrementalcache;",
  preheat_queries: &[],
  // If the cache fails, just ignore all caching attempts
  on_failure: CacheFailure::Blackhole,
};

/// Cache used to skip formatting/linting a file again when we
/// know it is already formatted or has no lint diagnostics.
pub struct IncrementalCache(IncrementalCacheInner);

impl IncrementalCache {
  pub fn new<TState: std::hash::Hash>(
    db: CacheDB,
    state: &TState,
    initial_file_paths: &[PathBuf],
  ) -> Self {
    IncrementalCache(IncrementalCacheInner::new(db, state, initial_file_paths))
  }

  #[allow(unused)]
  pub fn new_with_state_cb<TState: std::hash::Hash>(
    db: CacheDB,
    initial_file_paths: &[PathBuf],
    state_cb: impl FnOnce(&mut FastInsecureHasher) -> TState,
  ) -> Self {
    IncrementalCache(IncrementalCacheInner::new_with_state_cb(
      db,
      initial_file_paths,
      state_cb,
    ))
  }

  pub fn is_file_same(&self, file_path: &Path, file_text: &str) -> bool {
    self.0.is_file_same(file_path, file_text)
  }

  pub fn update_file(&self, file_path: &Path, file_text: &str) {
    self.0.update_file(file_path, file_text)
  }

  pub async fn wait_completion(&self) {
    self.0.wait_completion().await;
  }
}

enum ReceiverMessage {

Review comment (performance):
Maybe we should just change `new` to need to accept a `CacheDBHash`? Then we don't need to code generate multiple paths.

Code after:
    "state_hash INTEGER NOT NULL,",
    "source_hash INTEGER NOT NULL",
    ");"
  ),
  on_version_change: "DELETE FROM incrementalcache;",
  preheat_queries: &[],
  // If the cache fails, just ignore all caching attempts
  on_failure: CacheFailure::Blackhole,
};

/// Cache used to skip formatting/linting a file again when we
/// know it is already formatted or has no lint diagnostics.
pub struct IncrementalCache(IncrementalCacheInner);

impl IncrementalCache {
  pub fn new(
    db: CacheDB,
    state_hash: CacheDBHash,
    initial_file_paths: &[PathBuf],
  ) -> Self {
    IncrementalCache(IncrementalCacheInner::new(
      db,
      state_hash,
      initial_file_paths,
    ))
  }

  pub fn is_file_same(&self, file_path: &Path, file_text: &str) -> bool {
    self.0.is_file_same(file_path, file_text)
  }

  pub fn update_file(&self, file_path: &Path, file_text: &str) {
    self.0.update_file(file_path, file_text)
  }

  pub async fn wait_completion(&self) {
    self.0.wait_completion().await;
  }
}

enum ReceiverMessage {
  Update(PathBuf, CacheDBHash),
  Exit,
}

struct IncrementalCacheInner {
  previous_hashes: HashMap<PathBuf, CacheDBHash>,
  sender: tokio::sync::mpsc::UnboundedSender<ReceiverMessage>,
  handle: Mutex<Option<JoinHandle<()>>>,
}
Repository: denoland/deno
File: tests/unit_node/_fs/_fs_handle_test.ts (TypeScript)

Code before:
    assertEquals(Deno.statSync(testData).mode! & 0o777, readWrite);

    await fileHandle.close();
  },
});

Deno.test({
  name: "[node/fs filehandle.chown] Change owner of the file",
  ignore: Deno.build.os === "windows",
  async fn() {
    const tempFile: string = await Deno.makeTempFile();
    const fileHandle = await fs.open(tempFile);

    await fileHandle.chmod(0o700);

    const nobodyUid = 65534;
    const nobodyGid = 65534;

    try {
      await fileHandle.chown(nobodyUid, nobodyGid);
    } catch (e) {
      assert(
        e instanceof Deno.errors.PermissionDenied,
        "Expected permissionDenied error",
      );
    }

    const realUid = Deno.uid() || 1000;
    const realGid = Deno.gid() || 1000;

    await fileHandle.chown(realUid, realGid);

    assertEquals(Deno.statSync(tempFile).uid, realUid);
    assertEquals(Deno.statSync(tempFile).gid, realGid);

    await fileHandle.close();
  },
});


Review comment (suggestion):
Can you use `assertRejects` instead? This passes when `await fileHandle.chown(nobodyUid, nobodyGid)` doesn't throw

Code after:
    assertEquals(decoder.decode(data.subarray(0, 2)), "hi");
    // Verify null bytes
    assertEquals(data[2], 0);
    assertEquals(data[3], 0);
    assertEquals(data[4], 0);
  },
);

Deno.test(
  "[node/fs filehandle.truncate] Truncate file with negative length",
  async function () {
    const tempFile: string = await Deno.makeTempFile();
    const fileHandle = await fs.open(tempFile, "w+");

    await fileHandle.writeFile("hello world");

    await fileHandle.truncate(-1);

    const data = Deno.readFileSync(tempFile);
    await Deno.remove(tempFile);
    await fileHandle.close();

    assertEquals(decoder.decode(data), "");
    assertEquals(data.length, 0);
  },
);

Deno.test({
  name: "[node/fs filehandle.chmod] Change the permissions of the file",
  ignore: Deno.build.os === "windows",
  async fn() {
    const fileHandle = await fs.open(testData);

    const readOnly = 0o444;
    await fileHandle.chmod(readOnly.toString(8));
    assertEquals(Deno.statSync(testData).mode! & 0o777, readOnly);

    const readWrite = 0o666;
    await fileHandle.chmod(readWrite.toString(8));
    assertEquals(Deno.statSync(testData).mode! & 0o777, readWrite);

    await fileHandle.close();
  },
});

Deno.test({
  name:
    "[node/fs filehandle.utimes] Change the file system timestamps of the file",
  async fn() {
    const fileHandle = await fs.open(testData);
Repository: denoland/deno
File: ext/console/lib.deno_console.d.ts (TypeScript)

Code before:
   */
  count(label?: string): void;

  /**
   * Resets the counter for a given label
   * @param label The label to reset. Defaults to 'default'
   * @example
   * ```ts
   * console.count('myCounter');
   * console.countReset('myCounter'); // Resets to 0
   * ```
   */
  countReset(label?: string): void;

  /**
   * Outputs a debugging message to the console
   * @param data Values to be printed to the console
   * @example
   * ```ts
   * console.debug('Debug message', { detail: 'some data' });
   * ```
   */
  debug(...data: any[]): void;

  /**
   * Displays an interactive list of the properties of a specified object
   * @param item Object to display
   * @param options Formatting options
   * @example
   * ```ts
   * console.dir({ name: 'object', value: 42 }, { depth: 1 });
   * ```
   */
  dir(item?: any, options?: any): void;

  /**
   * Displays an XML/HTML Element representation of the specified object if possible
   * @param data Elements to display
   * @example
   * ```ts
   * const element = document.createElement('div');
   * console.dirxml(element);
   * ```
   */
  dirxml(...data: any[]): void;

  /**
   * Outputs an error message to the console
   * @param data Values to be printed to the console
   * @example
   * ```ts

Review comment (suggestion):
```suggestion
   * Displays a list of the properties of a specified object
```

Code after:
   */
  count(label?: string): void;

  /**
   * Resets the counter for a given label
   * @param label The label to reset. Defaults to 'default'
   * @example
   * ```ts
   * console.count('myCounter');
   * console.countReset('myCounter'); // Resets to 0
   * ```
   */
  countReset(label?: string): void;

  /**
   * Outputs a debugging message to the console
   * @param data Values to be printed to the console
   * @example
   * ```ts
   * console.debug('Debug message', { detail: 'some data' });
   * ```
   */
  debug(...data: any[]): void;

  /**
   * Displays a list of the properties of a specified object
   * @param item Object to display
   * @param options Formatting options
   * @example
   * ```ts
   * console.dir({ name: 'object', value: 42 }, { depth: 1 });
   * ```
   */
  dir(item?: any, options?: any): void;

  /**
   * @ignore
   */
  dirxml(...data: any[]): void;

  /**
   * Outputs an error message to the console.
   * This method routes the output to stderr,
   * unlike other console methods that route to stdout.
   * @param data Values to be printed to the console
   * @example
   * ```ts
   * console.error('Error occurred:', new Error('Something went wrong'));
   * ```
   */
  error(...data: any[]): void;
Repository: denoland/deno
File: ext/console/lib.deno_console.d.ts (TypeScript)

Code before:
   * ```
   */
  timeLog(label?: string, ...data: any[]): void;

  /**
   * Outputs a stack trace to the console
   * @param data Values to be printed to the console
   * @example
   * ```ts
   * console.trace('Trace message');
   * ```
   */
  trace(...data: any[]): void;

  /**
   * Outputs a warning message to the console
   * @param data Values to be printed to the console
   * @example
   * ```ts
   * console.warn('Deprecated feature used');
   * ```
   */
  warn(...data: any[]): void;

  /**
   * Adds a marker to the browser's Timeline or DevTools Performance panel
   * @param label Label for the timestamp
   * @example
   * ```ts
   * console.timeStamp('Navigation Start');
   * ```
   */
  timeStamp(label?: string): void;

  /**
   * Starts recording a performance profile
   * @param label Profile label
   * @example
   * ```ts
   * console.profile('Performance Profile');
   * // ... code to profile
   * console.profileEnd('Performance Profile');
   * ```
   */
  profile(label?: string): void;

  /**
   * Stops recording a performance profile
   * @param label Profile label to stop
   * @example
   * ```ts

Review comment (performance):
```suggestion
   * Adds a marker to the DevTools Performance panel
```

Code after:
  /**
   * Outputs a stack trace to the console
   * @param data Values to be printed to the console
   * @example
   * ```ts
   * console.trace('Trace message');
   * ```
   */
  trace(...data: any[]): void;

  /**
   * Outputs a warning message to the console
   * @param data Values to be printed to the console
   * @example
   * ```ts
   * console.warn('Deprecated feature used');
   * ```
   */
  warn(...data: any[]): void;

  /**
   * Adds a marker to the DevTools Performance panel
   * @param label Label for the timestamp
   * @example
   * ```ts
   * console.timeStamp('Navigation Start');
   * ```
   */
  timeStamp(label?: string): void;

  /**
   * Starts recording a performance profile
   * @param label Profile label
   * @example
   * ```ts
   * console.profile('Performance Profile');
   * // ... code to profile
   * console.profileEnd('Performance Profile');
   * ```
   */
  profile(label?: string): void;

  /**
   * Stops recording a performance profile
   * @param label Profile label to stop
   * @example
   * ```ts
   * console.profile('Performance Profile');
   * // ... code to profile
   * console.profileEnd('Performance Profile');
   * ```
Repository: denoland/deno
File: tests/unit_node/http_test.ts (TypeScript)

Code before:

      decompress.on("data", (chunk) => {
        body += chunk;
      });

      decompress.on("end", () => {
        resolve();
      });
    },
  );
  request.on("error", reject);
  request.end(() => {
    assert(received);
  });

  await promise;
  ac.abort();
  await server.finished;

  assertEquals(JSON.parse(body), [["accept-language", "*"], [
    "host",
    "localhost:3000",
  ], ["user-agent", "Deno/2.1.1"]]);
});

Deno.test("[node/http] an error with DNS propagates to reqeust object", async () => {
  const { resolve, promise } = Promise.withResolvers<void>();
  const req = http.request("http://invalid-hostname.test", () => {});
  req.on("error", (err) => {
    assertEquals(err.name, "Error");
    assertEquals(err.message, "getaddrinfo ENOTFOUND invalid-hostname.test");
    resolve();
  });
  await promise;
});


Review comment (suggestion):
```suggestion
Deno.test("[node/http] an error with DNS propagates to request object", async () => {
```

Code after:

      decompress.on("data", (chunk) => {
        body += chunk;
      });

      decompress.on("end", () => {
        resolve();
      });
    },
  );
  request.on("error", reject);
  request.end(() => {
    assert(received);
  });

  await promise;
  ac.abort();
  await server.finished;

  assertEquals(JSON.parse(body), [["accept-language", "*"], [
    "host",
    "localhost:3000",
  ], ["user-agent", "Deno/2.1.1"]]);
});

Deno.test("[node/http] an error with DNS propagates to request object", async () => {
  const { resolve, promise } = Promise.withResolvers<void>();
  const req = http.request("http://invalid-hostname.test", () => {});
  req.on("error", (err) => {
    assertEquals(err.name, "Error");
    assertEquals(err.message, "getaddrinfo ENOTFOUND invalid-hostname.test");
    resolve();
  });
  await promise;
});