Timeout layer
Add timeout for every operation to avoid slow or unexpected hang operations.
TimeoutLayer treats all operations in two kinds:
TimeoutLayer
stat
delete
timeout
read
Reader::read
Writer::write
io_timeout
const op = new Operator("fs", { root: "/tmp" })const timeout = new TimeoutLayer();timeout.timeout = 10000; // 10 seconds for non-IO ops (in milliseconds)timeout.ioTimeout = 3000; // 3 seconds for IO ops (in milliseconds)op.layer(timeout.build()); Copy
const op = new Operator("fs", { root: "/tmp" })const timeout = new TimeoutLayer();timeout.timeout = 10000; // 10 seconds for non-IO ops (in milliseconds)timeout.ioTimeout = 3000; // 3 seconds for IO ops (in milliseconds)op.layer(timeout.build());
Set timeout for IO operations (read, write, etc.)
Set timeout for non-IO operations (stat, delete, etc.)
Timeout layer
Add timeout for every operation to avoid slow or unexpected hang operations.
Notes
TimeoutLayertreats all operations in two kinds:stat,deletethey operate on a single file. We control them by settingtimeout.read,Reader::readandWriter::write, they operate on data directly, we control them by settingio_timeout.Default
Examples