How to run nested async functions?
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 35/100
Research direction
Start by reproducing the nested calls in the issue, then inspect the implementations or entry points for async.wrap, async.run, and async.void. The reported failure is an attempt to yield across a C-call boundary; done means establishing supported nested-call behavior or documenting the required calling pattern.
Written by the indexing model from the issue text.
Description
I'm having trouble figuring out how I can nest async.wrap function calls.
What seems to be working is:
local leaf1 = async.wrap(function(cb)
cb("leaf1")
end, 1)
local leaf2 = async.wrap(function(cb)
cb("leaf2")
end, 1)
local branch = async.wrap(function(cb)
local l1,l2
async.run(leaf1, function(val)
l1 = val
end)
async.run(leaf2, function(val)
l2 = val
end)
cb("branch" .. l1 .. l2)
end, 1)
function run()
local root = async.void(function()
print(leaf1())
print(leaf2())
print(branch())
end)
root()
end
run()
I expected plain function calls to work, but they crash with an error:
local leaf1 = async.wrap(function(cb)
cb("leaf1")
end, 1)
local leaf2 = async.wrap(function(cb)
cb("leaf2")
end, 1)
local branch = async.wrap(function(cb)
local l1,l2
l1 = leaf1()
l2 = leaf2()
cb("branch" .. l1 .. l2)
end, 1)
M.async = function()
local root = async.void(function()
print(leaf1())
print(leaf2())
print(branch())
end)
root()
end
Error:
attempt to yield across C-call boundary
- Dominant language
- Lua
- Stars
- 3.5k
- Forks
- 340
- PR merge metrics
- No merged PRs in 30d
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from nvim-lua/plenary.nvim
-
Difficulty 1/5 Under an hour Newbie friendliness 88/100
nvim-lua/plenary.nvim#682 ·
-
Difficulty 1/5 Under an hour Newbie friendliness 72/100
nvim-lua/plenary.nvim#680 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 45/100
nvim-lua/plenary.nvim#675 ·
-
Difficulty 4/5 3-5 days Newbie friendliness 28/100
nvim-lua/plenary.nvim#672 · 1 comment ·
-
Difficulty 4/5 3-5 days Newbie friendliness 25/100
nvim-lua/plenary.nvim#671 · 1 comment ·
All issues in nvim-lua/plenary.nvim
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
-
Difficulty 1/5 Under an hour Newbie friendliness 94/100
codymikol/multiverse.nvim#320 ·
-
Difficulty 1/5 1-3 hours Newbie friendliness 88/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
-
Good First Issue
Difficulty 1/5 1-3 hours Newbie friendliness 78/100