diff --git a/lib/src/dbs/channel.rs b/lib/src/dbs/channel.rs index 603a879e..b3b35032 100644 --- a/lib/src/dbs/channel.rs +++ b/lib/src/dbs/channel.rs @@ -78,7 +78,9 @@ impl Iterable { // Loop until no more keys loop { // Check if the context is finished - ctx.check()?; + if ctx.is_done() { + break; + } // Get the next 1000 key-value entries let res = match nxt { None => { @@ -104,7 +106,9 @@ impl Iterable { // Loop over results for (i, (k, v)) in res.into_iter().enumerate() { // Check the context - ctx.check()?; + if ctx.is_done() { + break; + } // Ready the next if n == i + 1 { nxt = Some(k.clone()); @@ -199,7 +203,9 @@ impl Iterable { // Loop until no more keys loop { // Check if the context is finished - ctx.check()?; + if ctx.is_done() { + break; + } // Get the next 1000 key-value entries let res = match nxt { None => { @@ -225,7 +231,9 @@ impl Iterable { // Loop over results for (i, (k, _)) in res.into_iter().enumerate() { // Check the context - ctx.check()?; + if ctx.is_done() { + break; + } // Ready the next if n == i + 1 { nxt = Some(k.clone()); diff --git a/lib/src/dbs/iterate.rs b/lib/src/dbs/iterate.rs index dc1ed709..c1d66e58 100644 --- a/lib/src/dbs/iterate.rs +++ b/lib/src/dbs/iterate.rs @@ -78,7 +78,9 @@ impl Iterable { // Loop until no more keys loop { // Check if the context is finished - ctx.check()?; + if ctx.is_done() { + break; + } // Get the next 1000 key-value entries let res = match nxt { None => { @@ -104,7 +106,9 @@ impl Iterable { // Loop over results for (i, (k, v)) in res.into_iter().enumerate() { // Check the context - ctx.check()?; + if ctx.is_done() { + break; + } // Ready the next if n == i + 1 { nxt = Some(k.clone()); @@ -199,7 +203,9 @@ impl Iterable { // Loop until no more keys loop { // Check if the context is finished - ctx.check()?; + if ctx.is_done() { + break; + } // Get the next 1000 key-value entries let res = match nxt { None => { @@ -225,7 +231,9 @@ impl Iterable { // Loop over results for (i, (k, _)) in res.into_iter().enumerate() { // Check the context - ctx.check()?; + if ctx.is_done() { + break; + } // Ready the next if n == i + 1 { nxt = Some(k.clone()); diff --git a/lib/src/fnc/script/main.rs b/lib/src/fnc/script/main.rs index a725773f..aa72b5a2 100644 --- a/lib/src/fnc/script/main.rs +++ b/lib/src/fnc/script/main.rs @@ -12,7 +12,9 @@ pub async fn run( doc: Option<&Value>, ) -> Result { // Check the context - let _ = ctx.check()?; + if ctx.is_done() { + return Ok(Value::None); + } // Create a new agent let exe = Executor::default(); // Create an JavaScript context