hardhat icon indicating copy to clipboard operation
hardhat copied to clipboard

Interruptions should be cancellable

Open ItsNickBarry opened this issue 6 months ago • 1 comments

Feedback

It should be possible to cancel a Hardhat user interrupt. For example, in response to a timeout or an on-chain event.

Here's a timeout example with readline:

  const rl = readline.promises.createInterface({
    input: process.stdin,
    output: process.stdout,
  });

  const aborter = new AbortController();

  setTimeout(aborter.abort.bind(aborter), timeout * 1000).unref();

  try {
    await rl.question(`Press <ENTER> to continue.\n`, {
      signal: aborter.signal,
    });
  } catch (error) {
    // rejected by aborter; do nothing
  }

  rl.close();

ItsNickBarry avatar May 25 '25 18:05 ItsNickBarry

This is a feature we will look to support. Currently it is planned for after the Beta launch.

kanej avatar Jun 16 '25 09:06 kanej