From 27192663ee7aaa7729c0399cc83c9597f6d1c5be Mon Sep 17 00:00:00 2001 From: Clement Hue Date: Thu, 23 Apr 2026 11:53:46 +0200 Subject: [PATCH] feat: add non_blocking support for async fetch dependencies Allow dependencies marked as `non_blocking` to continue the fetch chain even on error, preventing a single failing request from blocking subsequent API calls. Applied to the `draft_notes` dependency. --- lua/gitlab/async.lua | 8 +++++++- lua/gitlab/state.lua | 1 + 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/lua/gitlab/async.lua b/lua/gitlab/async.lua index 36905f62..ba0f143b 100644 --- a/lua/gitlab/async.lua +++ b/lua/gitlab/async.lua @@ -37,10 +37,16 @@ function async:fetch(dependencies, i, argTable) -- Call the API, set the data, and then call the next API local body = dependency.body and dependency.body(argTable) or nil + local on_error = nil + if dependency.non_blocking then + on_error = function() + self:fetch(dependencies, i + 1, argTable) + end + end job.run_job(dependency.endpoint, dependency.method or "GET", body, function(data) state[dependency.state] = dependency.key and data[dependency.key] or data self:fetch(dependencies, i + 1, argTable) - end) + end, on_error) end -- Will call APIs in sequence and set global state diff --git a/lua/gitlab/state.lua b/lua/gitlab/state.lua index 3a6df9b5..a30dc78b 100644 --- a/lua/gitlab/state.lua +++ b/lua/gitlab/state.lua @@ -538,6 +538,7 @@ M.dependencies = { key = "draft_notes", state = "DRAFT_NOTES", refresh = false, + non_blocking = true, }, project_members = { endpoint = "/project/members",