openresty / openresty/lua-nginx-module

HTTP/2 protocol error if headers are sent before a Lua error

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

Relevant section of the OpenResty 1.19.9.1 config:

location @error {
	content_by_lua_file /var/www/lua/error.lua;
}

location / {
	error_page 500 @error;
	content_by_lua_file /var/www/lua/content.lua;
}

error.lua:

ngx.say(tostring(ngx.status))

content.lua:

ngx.send_headers()
error('hi')

Trying to curl https://localhost results in:

curl: (92) HTTP/2 stream 0 was not closed cleanly: INTERNAL_ERROR (err 2)

curl https://localhost --http1.1 (or --http1.0):

curl: (52) Empty reply from server

Commenting out the call to ngx.send_headers() results in the request completing successfully and printing 500.

Using echo instead of content_by_lua* in the @error named location doesn't solve the issue.

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

Reproduce the configuration using content.lua and error.lua, starting with the ngx.send_headers() and error('hi') sequence and the @error location. Compare the HTTP/2 and HTTP/1.x curl results; done means the request reaches the error handler and returns 500 without an INTERNAL_ERROR or empty reply.

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
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.