openresty / openresty/lua-nginx-module

body_filter_by_lua breaks APIs in other contexts in anything greater then 1.19

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

We've been attempting to upgrade some legacy code to a newer version of openresty and hit a road block getting to anything greater then 1.19

We've found an issue that exists in any version greater then openresty 1.19 when using body_filter_by_lua and content_by_lua_block blocks.

I've created a reproduction case here - https://github.com/cdloh/body_filter_by_lua-bug-openresty

I've used lua-resty-http to make making the request easier.

When using both body_filter_by_lua and content_by_lua_block it's impossible to use APIs like ngx.flush(true) if there is any buffering going on. Eventually even if the flush code is only within content_by_lua blocks openresty complains about that API being disabled in body_filter_by_lua phases.

Note that you don't have to be actually doing anything in the body_filter_by_lua block at all. Simply having it defined causes the bug to occur.

You can run the some reproduction repo against 1.19 docker iamges and it work fine, however anything greater and it breaks.

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 linked reproduction repository and run it against OpenResty 1.19 and later Docker images to compare the behavior of ngx.flush(true). Then inspect how body_filter_by_lua and content_by_lua_block interact across request phases; done means the reproduction no longer reports the API as disabled when buffering is present.

Written by the indexing model from the issue text.

Assessment

Tech stack
c, docker, lua, nginx
Domain
api, 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.