openresty / openresty/lua-nginx-module
ngx.on_abort not work when register in access phase
Nobody has claimed this yet.
- Dominant language
- C
- Stars
- 11.8k
- Forks
- 2.1k
- Avg merge
- 6h 1m
- Merged PRs (30d)
- 6
Description
Ubuntu18
openresty/1.15.8.1
nginx.conf
http {
tcp_nopush on;
keepalive_timeout 65;
lua_socket_log_errors off;
server {
listen 28002 reuseport;
charset utf-8;
keepalive_disable none;
keepalive_requests 100000;
keepalive_timeout 3600s;
lua_code_cache on;
lua_check_client_abort on;
location /test-on-abort {
access_by_lua_block {
local ok, err = ngx.on_abort(function()
print("in on_abort callback function")
end)
if ok then
print("register success")
else
ngx.log(ngx.ERR, "register failed: ", err)
end
}
content_by_lua_block {
print("in content phase")
ngx.sleep(5)
}
}
}
}
I test by curl, such as curl -i "http://127.0.0.1:28002/test-on-abort" and wait for 2 seconds, then 'Ctrl+C'.
error.log
2020/09/17 15:33:29 [notice] 15860#15860: *1 [lua] access_by_lua(dev-nginx.conf:69):7: register success, client: 127.0.0.1, server: localhost, request: "GET /test-on-abort HTTP/1.1", host: "127.0.0.1:28002"
2020/09/17 15:33:29 [notice] 15860#15860: *1 [lua] content_by_lua(dev-nginx.conf:74):2: in content phase, client: 127.0.0.1, server: localhost, request: "GET /test-on-abort
HTTP/1.1", host: "127.0.0.1:28002"
2020/09/17 15:33:32 [info] 15860#15860: *1 client prematurely closed connection, client: 127.0.0.1, server: localhost, request: "GET /test-on-abort HTTP/1.1", host: "127.0.0.1:28002"
When I move 'ngx.on_abort' from access to content phase, it works well.
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 report with the supplied nginx.conf, lua_check_client_abort on, and the /test-on-abort access_by_lua_block/content_by_lua_block sequence. Start at the ngx.on_abort entry point and compare registration in the access and content phases; done means the callback behavior is consistent when the client closes during the request.
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