openresty / openresty/lua-nginx-module

[bug] lua_socket_log_errors not working for ngx.socket.tcp():connect()

Open
#2,138 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C
Stars
11.8k
Forks
2.1k
Avg merge
6h 1m
Merged PRs (30d)
6

Description

Version: openresty/1.21.4.

To reproduce:

# other stuff
http {
    include       mime.types;
    # ... other stuff
    lua_socket_log_errors off;

    server {
        listen       80;
        server_name  localhost;

        location / {
            root   html;
            index  index.html index.htm;
            access_by_lua_block {
                local c = ngx.socket.tcp()
                c:connect("unix:/inexist.sock")
            }
        }
    }
}
curl localhost

We see

2022/12/27 18:14:28 [crit] 25707#0: *1 connect() to unix:/inexist.sock failed (2: No such file or directory), client: 127.0.0.1, server: localhost, request: "GET / HTTP/1.1", host: "localhost"

We expect lua_socket_log_errors to mute connect error.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the provided NGINX configuration with lua_socket_log_errors off and the unix:/inexist.sock connection. Trace the ngx.socket.tcp():connect() path and the handling of lua_socket_log_errors; done means the reproduced failed connection no longer emits the shown critical log entry.

Written by the indexing model from the issue text.

Assessment

Tech stack
c, lua, nginx
Domain
backend, networking
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.