openresty / openresty/lua-nginx-module
ngx.run_worker_thread doesn't work outside of content_by_lua*?
Nobody has claimed this yet.
- Dominant language
- C
- Stars
- 11.8k
- Forks
- 2.1k
- Avg merge
- 6h 1m
- Merged PRs (30d)
- 6
Description
Hi guys,
I'm not clear if this is just a documentation issue, or an actual bug. The docs for ngx.run_worker_thread state that it can work inside of rewrite_by_lua*, access_by_lua* and content_by_lua*. Based on my testing just now, it seems as though it actually only works within content_by_lua*.
When you try and use it inside of the other two phases, the function fires but then the request hangs indefinitely and never completes. No error or anything is reported, it just hangs forever.
nginx.conf
server {
set $cache_key "";
location /test {
rewrite_by_lua_block {
local ok, md5_or_err = ngx.run_worker_thread("default", "utils", "md5")
if not ok then
ngx.say(ok, " : ", md5_or_err)
return
end
ngx.var.cache_key = md5_or_err
}
}
}
utils.lua
local function md5()
return ngx.md5("hello")
end
return { md5 = md5 }
However, run the same block within a content_by_lua_block, and everything executes as expected.
So what is it? A documentation issue, or should ngx.run_worker_thread work within these extra phases? This is on OR 1.21.4.1 by the way.
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
Reproduce the behavior from the provided nginx.conf and utils.lua using ngx.run_worker_thread in rewrite_by_lua_block and content_by_lua_block. Start by checking the documented phase support and the module's handling of these request phases; done means either correcting the phase behavior with coverage or updating the documentation to match the verified behavior.
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