hardhat
hardhat copied to clipboard
Interruptions should be cancellable
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();
This is a feature we will look to support. Currently it is planned for after the Beta launch.