openresty / openresty/lua-nginx-module

Require file with coroutine startup causes error

Open
#2,408 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

test.lua:

coroutine.wrap(function() print("hello") end)()

Requiring with luajit:

$ luajit -e "require'test'"
hello

Requiring in content_by_lua_block:

http {
    server {
        listen 8080;
        lua_code_cache off;

        location / {
            content_by_lua_block {
                require("test")
            }
        }
    }
}
$ curl localhost:8080
500 error html page

Error log:

2025/04/06 18:49:55 [error] 2931732#0: *2 lua entry thread aborted: runtime error: attempt to yield across C-call boundary
stack traceback:
coroutine 0:
	[C]: in function 'require'
	content_by_lua(nginx.conf:15):2: in main chunk, client: 127.0.0.1, server: , request: "GET / HTTP/1.1", host: "localhost:8080"

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 with the test.lua coroutine example and reproduce it through the content_by_lua_block configuration, comparing it with direct luajit require behavior. Read the error log's require and lua entry thread traceback first. Done means requiring this module no longer produces the C-call-boundary yield error in the shown NGINX request path.

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
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.