openresty / openresty/lua-nginx-module
Invalid coroutine.resume return values
Nobody has claimed this yet.
- Dominant language
- C
- Stars
- 11.8k
- Forks
- 2.1k
- Avg merge
- 6h 1m
- Merged PRs (30d)
- 6
Description
When I create a coroutine using coroutine.wrap and then resume it, coroutine.resume skips the first "status" value and returns all other values. As docs says it must return the first "status" boolean value.
I use openresty from AUR: aur/openresty 1.27.1.1-1
$ curl http://localhost:8080/1
2, nil, 3, nil, false, cannot resume dead coroutine
$ curl http://localhost:8080/2
true, 2, true, 3, false, cannot resume dead coroutine
worker_processes 1;
error_log error.log notice;
pid nginx.pid;
events {
worker_connections 1024;
}
http {
server {
listen 8080;
lua_code_cache off;
location /1 {
content_by_lua_block {
local co
local function f()
co = coroutine.running()
coroutine.yield(1)
coroutine.yield(2)
return 3
end
assert(coroutine.wrap(f)() == 1)
local ok1, ret1 = coroutine.resume(co)
local ok2, ret2 = coroutine.resume(co)
local ok3, ret3 = coroutine.resume(co)
ngx.say(("%s, %s, %s, %s, %s, %s"):format(
ok1, ret1, ok2, ret2, ok3, ret3
))
}
}
location /2 {
content_by_lua_block {
local co
local function f()
co = coroutine.running()
coroutine.yield(1)
coroutine.yield(2)
return 3
end
do
local c = coroutine.create(f)
local ok, v = assert(coroutine.resume(c))
assert(v == 1)
end
local ok1, ret1 = coroutine.resume(co)
local ok2, ret2 = coroutine.resume(co)
local ok3, ret3 = coroutine.resume(co)
ngx.say(("%s, %s, %s, %s, %s, %s"):format(
ok1, ret1, ok2, ret2, ok3, ret3
))
}
}
}
}
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.
Research direction
Start with the two content_by_lua_block reproductions in the issue and compare coroutine.wrap with coroutine.create and coroutine.resume. Trace how the Lua coroutine results are passed through the OpenResty NGINX module, then verify that both examples return the documented status boolean before the yielded or returned values.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- lua, nginx
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100