Skip to content

ngx_mruby v3.0.0

The local start example binds to loopback and adds mock model routing (#672)

Section titled “The local start example binds to loopback and adds mock model routing (#672)”
  • Before: examples/start/compose.yaml published host port 8080 on all interfaces, and the trial demonstrated only the /hello Ruby handler.
  • Now: the host binding is 127.0.0.1:8080:8080. The trial retains /hello and adds /v1/responses, which checks a public demonstration key and selects one of two loopback mock endpoints by model. The bilingual walkthrough checks route selection, credential replacement, rejected requests, editing, restoration and reload.
  • Why it changed:
    • The reason: the first exercise should demonstrate the model-routing use case without a provider account or real key.
    • Why the old behavior could not be kept: exposing the trial on every host interface is unnecessary for a local-only exercise; /hello remains available.
    • What the documentation promised: the earlier start page showed a Hello response and explained that the host port was broadly published.
  • Affected: users running the development example from examples/start/; no runtime API or stable 2.x configuration is changed.
  • What to do: run the updated walkthrough locally. The bundled keys are demonstration values, and the mock response is not LLM inference, a provider compatibility test or API-format conversion. Do not publish this trial as a service.

The bundled mruby is 4.1.0-rc2 instead of 3.3.0 (#561, #678)

Section titled “The bundled mruby is 4.1.0-rc2 instead of 3.3.0 (#561, #678)”
  • Before: ngx_mruby 2.x bundles mruby 3.3.0 and builds the core gems that full-core.gembox of mruby 3.3.0 selects, mruby-print included.
  • Now: this release bundles mruby 4.1.0-rc2, a release candidate of 4.1.0: the tag 4.1.0-rc2 of mruby (commit c17ffcc24190, 2026-09-11), whose MRUBY_VERSION is 4.1.0. The default build_config.rb takes the core gems that NGX_MRUBY_CORE_GEMS names: the set that full-core.gembox of mruby 3.3.0 selected, without mruby-print (mruby 3.4 removed it; Kernel#print, #puts and #p come from mruby-io). It leaves out these core gems, which full-core.gembox of 4.1.0-rc2 takes: mruby-task, mruby-encoding, mruby-strftime (Time#strftime) and mruby-benchmark (Benchmark), and three of the gems that are new in 4.1, mruby-regexp, mruby-string-bitops and mruby-bin-mrb. It takes the other three new gems, mruby-env, mruby-process and mruby-signal, which define ENV, Process and Signal (see the entries of ENV and Process below, #766). Regexp still comes from the third-party gem mattn/mruby-onig-regexp. It keeps mruby-sleep, which full-core.gembox leaves out. mruby 4.1 compiles Ruby code with Prism. The line that nginx logs at the info level when it reads the configuration ends in (mruby/4.1.0) mechanism enabled. The entries below list the differences that scripts, log monitoring, C extensions and builds see, as far as they were found and measured for ngx_mruby: they are not a complete list of the changes between mruby 3.3.0 and 4.1.0-rc2. mruby lists its user-visible changes in doc/mruby3.4.md, doc/mruby4.0.md and, for 4.1, NEWS.md. The cost per request, measured for ngx_mruby against the bundled mruby 4.0.0 (the callgrind lane, user-space instructions of nginx per request, 2026-10-31, #678): in auth (a server rewrite handler with two Hash lookups and three variable assignments, then a proxy), 44228 → 52761 instructions, 42599 → 45621 without the GC; in headers, 30040 → 34903, and 28044 → 27612 without the GC. At 3 GHz and 1 to 2 instructions per cycle, an instruction takes 0.17 to 0.33 ns, so auth takes about 7.4 to 14.7 µs of CPU per request with 4.0.0 and 8.8 to 17.6 µs with 4.1.0-rc2 (+1.4 to +2.8 µs), and at 10,000 requests per second it uses 8.8% to 17.6% of a core instead of 7.4% to 14.7%. The GC runs more often and does more each time: in auth, 12.2 → 24.4 GC calls per 1000 requests, 134,000 → 293,000 instructions per call. mruby 4.1 runs a full GC instead of adding a heap page when its last mark left room (mruby commit c009f1633, which bounds the heap of small targets), and its VM spends more instructions on the same bytecode (“Known differences” under “Performance comparison with callgrind” in docs/test/README.md).
  • Why it changed:
    • The reason: the v3 plan puts stability, performance and current dependencies before new capabilities, and mruby publishes no maintenance releases of 3.x (docs/proposals/v3-plan.md, sections 3.3 and 6). Decision 1 of the plan (section 7) sets mruby 4.1.0 as the mruby of v3, because 4.1 counts the registrations of mrb_gc_register(): a second mrb_gc_unregister() of an object no longer drops the registration of another owner (mruby/mruby#7277), and Nginx::Async registers its fibers this way. The owner chose on 2026-10-29 to bundle 4.1.0-rc2 instead of waiting for the tag 4.1.0; next moves to 4.1.0 when it is tagged. 4.1.0-rc2 has the fix of mruby/mruby#7032 (commit c6866eed4).
    • Why the old behavior could not be kept: mruby 3.3.0 gets no more fixes. The NEWS.md of 4.1 alone has 20 entries under “Security Fixes” since 4.0, among them a use-after-free in String#lstrip!, #rstrip! and #strip! and one in the incremental GC; keeping 3.3.0 would have kept such defects in every worker.
    • What the documentation promised: the documentation of 2.x said nothing about which version of mruby a later release bundles. docs/install/README.md of 2.7.0 lists the default mrbgems as “mruby/mruby default mrbgems” without a version.
  • Affected: every build of the module, and every Ruby script that it runs.
  • What to do: rebuild the module together with the bundled mruby, then check the entries below and, for the changes that they do not cover, mruby’s three lists; Migrating from ngx_mruby 2.x to 3.0.0 has the steps. ngx_mruby keeps mruby’s GC defaults: GC.interval_ratio did not change the GC share, and a larger heap lowered it but raised the work without the GC.

A build_config.rb of your own needs the core gem changes of mruby 4.1 (#561, #678)

Section titled “A build_config.rb of your own needs the core gem changes of mruby 4.1 (#561, #678)”
  • Before: a build_config.rb of your own could name mruby-print, or take full-core.gembox and get the core gems of mruby 3.3.0, mruby-sleep included.
  • Now: mruby 4.1.0-rc2 has no mruby-print and no hal-* gems, and ngx_mruby_core_gems in build_config.rb stops the build on a name that the bundled mruby does not have. A list written for mruby 4.0.0 that names hal-posix-io, hal-posix-dir and hal-posix-socket stops there too: in 4.1 the POSIX back ends are part of mruby-io, mruby-dir and mruby-socket. full-core.gembox of 4.1.0-rc2 takes mruby-task, which redefines Kernel#sleep, arms a SIGALRM interval timer (setitimer) in every process that opens an mrb_state and allows at most 8 mrb_states (MRB_TASK_MAX_VMS), and mruby-encoding (see the entry of String#valid_encoding?), and leaves out mruby-sleep. It also takes mruby-env, mruby-process and mruby-regexp, which define ENV, Process and Regexp, the classes that iij/mruby-env, iij/mruby-process and mattn/mruby-onig-regexp define; the two gems of iij have the same names as these core gems. for_windows? in mruby/lib/mruby/gem.rb treats a one-letter directory at the root as a Windows drive: a 4.0.0 build whose work directory was mounted at /s in a container chose the Windows back ends by itself and stopped at windows.h: No such file or directory, and the for_windows? of 4.1.0-rc2 makes the same test (read from the source, not measured).
  • Why it changed:
    • The reason: these are changes of mruby 3.4, 4.0 and 4.1 that come with the bundled mruby (see the entry above).
    • Why the old behavior could not be kept: a core gem that the bundled mruby no longer has cannot be built, and ngx_mruby_core_gems stops on such a name on purpose, so that an update of mruby cannot drop a gem from the list unnoticed.
    • What the documentation promised: docs/install/README.md of 2.7.0 lists “mruby/mruby default mrbgems” and says nothing about core gems in a build_config.rb of your own.
  • Affected: builds with a build_config.rb other than the one of this release that name mruby-print or the hal-* gems, or take full-core.gembox.
  • What to do: start from the build_config.rb of this release, or select the core gems by name as NGX_MRUBY_CORE_GEMS does: remove mruby-print, hal-posix-io, hal-posix-dir and hal-posix-socket, and decide on mruby-task and mruby-encoding as Core gems describes. A build that takes full-core.gembox and also iij/mruby-env, iij/mruby-process or mattn/mruby-onig-regexp chooses between them and the core gems mruby-env, mruby-process and mruby-regexp.

Building the bundled mruby needs Ruby 3.0 or later (#678)

Section titled “Building the bundled mruby needs Ruby 3.0 or later (#678)”
  • Before: the rake of mruby 3.3.0, which 2.x bundles, builds with Ruby 2.x: its mrbc builds with Ruby 2.6.10 (the Ruby of macOS).
  • Now: the rake of mruby 4.1.0-rc2 stops while it links mrbc when it runs on Ruby 2.6.10, with ArgumentError: unknown keywords: flags, flags_before_libraries, flags_after_libraries, libs, outfile, objs (mruby/lib/mruby/build/command.rb, line 47). It builds with Ruby 3.0.2 (Ubuntu 22.04, the Ruby of CI and of the test container) and with Ruby 4.0.5. Command::Linker#run passes the parameters of the link as a Hash to _run(options, params={}, chdir: nil), and a Ruby before 3.0 reads a last Hash with Symbol keys as keyword arguments when the method takes keywords. Ruby 2.7 was not measured; by that rule it stops in the same way. mruby’s own doc/guides/compile.md still says “Ruby 2.5 or later”.
  • Why it changed:
    • The reason: the build of mruby 4.1 changed (see “The bundled mruby is 4.1.0-rc2 instead of 3.3.0”); this release bundles mruby 4.1.0-rc2.
    • Why the old behavior could not be kept: keeping Ruby 2.x would have meant changing mruby/, which ngx_mruby updates only from mruby’s own tree.
    • What the documentation promised: docs/install/README.md of 2.7.0 asks for Ruby with rake and names no version.
  • Affected: builds that run on Ruby 2.x, for example the ruby package of Ubuntu 20.04 (2.7) or the Ruby of macOS (2.6).
  • What to do: build with Ruby 3.0 or later; for a version-managed Ruby, put its bin directory on PATH before the build.

The third-party mrbgems are built at the commits that build_config.rb.lock records (#558)

Section titled “The third-party mrbgems are built at the commits that build_config.rb.lock records (#558)”
  • Before: build_config.rb names the third-party mrbgems without a commit, and .gitignore lists the build_config.rb.lock that mruby’s rake writes, so the lock stays out of the repository. A build from a new checkout or a source archive clones the head of each gem’s branch with git clone --depth 1, so two builds of the same ngx_mruby commit made on different days can get different gem code.
  • Now: build_config.rb.lock is committed. It records a commit for each third-party gem of the default build and for each gem that those depend on, for example ksss/mruby-stringio, which the bundled rack-based-api needs. A build from a new checkout or a source archive clones each of them with its whole history and checks the recorded commit out, so every build of an ngx_mruby commit gets the same gem code. A gem that a build_config.rb of your own adds is cloned at the head of its branch, and rake adds its entry to the lock in your tree, which git status then shows as modified. rake does not fetch into a clone that exists: after a change of the lock, a build in a tree that keeps mruby/build stops with fatal: reference is not a tree when a clone does not have the new commit. symisc/vedis, which matsumotory/mruby-vedis clones by itself, is not pinned.
  • Why it changed:
    • The reason: the v3 plan pins every third-party gem by commit and commits build_config.rb.lock, so that the same tag builds the same binary (docs/proposals/v3-plan.md, section 4, Pillar A).
    • Why the old behavior could not be kept: without the pins, the gem code of a build depends on the day of the build. A change in any of the gem repositories reaches every later build of a released tag, and every CI run, without a change in ngx_mruby.
    • What the documentation promised: the documentation of 2.x said nothing about the commits of the third-party gems. docs/install/README.md lists the default mrbgems by name only.
  • Affected: builds from source that expect the newest commits of the third-party gems, build_config.rb files of your own that add gems, and trees that keep mruby/build when the lock changes.
  • What to do: nothing for a new checkout or a source archive. To build a gem at another commit, change its entry in the lock as Gem commits describes. After a change of the lock, for example one that a pull brings in, remove mruby/build before the next build.

Hash#inspect and Hash#to_s use a new format (#561)

Section titled “Hash#inspect and Hash#to_s use a new format (#561)”
  • Before: {"a"=>1} and {:a=>1}.
  • Now: {"a" => 1} and {a: 1} (since mruby 3.4). Everything that prints a Hash with these methods changes with them: string interpolation ("#{h}"), sprintf("%s", h) and Array#inspect.
  • Affected: scripts that put the inspect or to_s of a Hash into a response body or a header, or compare it with a fixed string. The test suite of ngx_mruby saw the change (/async_http_sub_request in test/t/ngx_mruby.rb).
  • What to do: do not use the inspect or to_s of a Hash as a data format, in a response body or in a header. Build the string yourself, or use JSON.generate.

Exception#inspect, and so the mrb_run failed lines of error.log, use a new format (#561)

Section titled “Exception#inspect, and so the mrb_run failed lines of error.log, use a new format (#561)”
  • Before: boom (RuntimeError). ngx_mruby writes the exception of a script with Exception#inspect into the mrb_run failed lines of error.log (level error; the line that an exception in mruby_stream_server_context_code logs while nginx reads the configuration, mrb_run failed: ngx_mruby stream module configuration failed: error: ..., is at level emerg), for example mrb_run failed: return 500 HTTP status code to client: error: boom (RuntimeError).
  • Now: #<RuntimeError: boom>, so the line ends in error: #<RuntimeError: boom>. Exception#message and #to_s are unchanged.
  • Affected: log parsers and alerts that match the old form, and scripts that use Exception#inspect. The test suite of ngx_mruby saw the change in error.log.
  • What to do: update log parsers and alerts that match the old form.

The messages logged while nginx reads the configuration are at the info level instead of notice (#565)

Section titled “The messages logged while nginx reads the configuration are at the info level instead of notice (#565)”
  • Before: while nginx reads the configuration, ngx_mruby logs these messages at the notice level: ngx_mruby/<version> (mruby/<version>) mechanism enabled, once for the http {} block; ngx_mruby NOTICE ...: compile info: ... for each directive with Ruby code, and ngx_mruby-stream-module NOTICE ...: compile info: ... for each one in stream {}; and ngx_mruby NOTICE ...: target variable=(...) for each mruby_set and mruby_set_code. nginx writes what it logs while it reads the configuration to its startup log, at the notice level whatever error_log says, so every start of nginx writes these lines, also with error_log ... warn;.
  • Now: the same messages are logged at the info level, and their text says INFO instead of NOTICE (ngx_mruby INFO ..., ngx_mruby-stream-module INFO ...). A start of nginx writes none of them. nginx -t writes them at [info] to the startup log only: nginx copies a line of the startup log to the terminal only at warn and above, so the output of nginx -t does not show them. A reload writes them to the error_log of the running configuration when that error_log is at info or debug. Errors while nginx reads the configuration, such as a script file that cannot be opened, are still logged at emerg.
  • Why it changed:
    • The defect: every start of nginx wrote these lines, and an error_log at a level above notice did not stop them (#320).
    • Why the old behavior could not be kept: nginx writes what it logs while it reads the configuration to its startup log at the notice level, before the configured error_log takes over, so no error_log setting filters a message at notice. Only a level below notice keeps the lines out of a start.
    • What the documentation promised: the documentation of 2.x said nothing about these messages.
  • Affected: log monitoring and scripts that look for these lines when nginx starts, for example to see that the module is loaded.
  • What to do: to see them, run nginx -t -e stderr, which writes the startup log to the terminal; read the startup log after nginx -t; or reload with error_log at info. The startup log is the file given with -e, or else the error log path compiled into nginx (logs/error.log under the prefix by default), as Messages logged while nginx reads the configuration describes.

Nginx.module_version and the mechanism enabled line give 3.0.0 (#823)

Section titled “Nginx.module_version and the mechanism enabled line give 3.0.0 (#823)”
  • Before: on 2.7.1 to 2.7.8, Nginx.module_version returned 2.7.1; from 2.7.9 on, it returns the version of the 2.x release (v2.7.9.md). The line that ngx_mruby logs while nginx reads a configuration with an http {} block starts with ngx_mruby/2.7.x (mruby/3.3.0) mechanism enabled, with the same value.
  • Now: Nginx.module_version returns 3.0.0, also in the alpha, beta and rc pre-releases of 3.0.0, and the line starts with ngx_mruby/3.0.0 (mruby/4.1.0) mechanism enabled. The line is logged at the info level, as the entry on the messages logged while nginx reads the configuration above describes (#565).
  • Why it changed:
    • The reason: the value names the release that the module was built from. MODULE_VERSION in src/http/ngx_http_mruby_module.h is set to the version of the newest release file in docs/releases/, and the suite fails when it is not (#822); on next that file is v3.0.0.md for the whole 3.0.0 cycle, so the value is 3.0.0 (#823).
    • Why the old behavior could not be kept: a 2.x value would make a 3.0.0 module name a 2.x release, whose behavior differs from 3.0.0 in every entry of this section, so a script or a monitor that reads the value could not tell the two apart.
    • What the documentation promised: Nginx.module_version says that the method returns the ngx_mruby version, and v2.7.9.md says that each release from 2.7.9 on gives its own version.
  • Affected: scripts that compare the string that Nginx.module_version returns, for example to choose code by version, and monitoring that reads the line that starts with ngx_mruby/ and contains mechanism enabled. The pre-releases of 3.0.0 give 3.0.0 as well, so the value does not tell them from one another or from the release 3.0.0.
  • What to do: where a script or a monitor compares this value with a 2.x version, compare it with 3.0.0 as well, or compare its first number. To tell a pre-release of 3.0.0 from another, or from the release, use the tag or the commit that the module was built from, not this value.

The message of NoMethodError names the class of the receiver (#561)

Section titled “The message of NoMethodError names the class of the receiver (#561)”
  • Before: undefined method 'foo'.
  • Now: undefined method 'foo' for NilClass.
  • Affected: scripts and log monitoring that match the message of a NoMethodError.
  • What to do: match on the exception class, not on the message.

private and protected are enforced (#561, #678)

Section titled “private and protected are enforced (#561, #678)”
  • Before: not enforced: a method defined after private or protected, initialize, a method defined with def at the top level, and the Kernel methods could be called with an explicit receiver, Kernel itself included (Kernel.Integer("12") is 12). Module#instance_methods and #methods of an object list private methods too: for a class with a method pub and a private method priv, instance_methods(false) is [:priv, :pub].
  • Now: enforced (since mruby 3.4): these methods raise NoMethodError (private method '<name>' called for <class>) when called with an explicit receiver other than self. This includes the Kernel methods such as raise, sprintf, puts, Integer and rand called on another object (1.Integer("3") raises private method 'Integer' called for Integer), and initialize_copy, respond_to_missing? and method_missing, which mruby 4 defines as private ("a".initialize_copy("b") raises). Called on Kernel itself, the methods of Kernel work as on 2.x (Kernel.Integer("12") is 12; mruby 4.0.0 raised NoMethodError there, and 4.1 calls them again, mruby/mruby#6976). A protected method can be called with an explicit receiver from a method of the same class, as in CRuby, and raises NoMethodError (protected method '<name>' called for <class>) from anywhere else. respond_to? returns true for a private method on both versions, so it does not tell whether such a call works. Module#instance_methods and #methods of an object leave private methods out (instance_methods(false) of the class above is [:pub]); Module#private_instance_methods and #private_methods list them. In handler code, a method defined with def at the top level stays public, so a call of it with an explicit receiver still works (the proposal for #502, section 1.4).
  • Why it changed:
    • The reason: mruby 3.4 enforces the visibility of methods as CRuby does, and mruby 4.1 checks the receiver of a protected method against the class of the caller’s self (mruby/mruby#6975, commit 534efe0 in mruby’s NEWS.md); this release bundles mruby 4.1.0-rc2 (see “The bundled mruby is 4.1.0-rc2 instead of 3.3.0”).
    • Why the old behavior could not be kept: the VM of the bundled mruby checks the visibility; ngx_mruby has no option to turn the check off.
    • What the documentation promised: the documentation of 2.x said nothing about the visibility of methods.
  • Affected: scripts that call such a method with an explicit receiver other than self and Kernel, and scripts that look for private methods in the result of instance_methods or methods.
  • What to do: call them without a receiver, or with send (obj.send(:name) works on both versions). To list private methods, use private_instance_methods or private_methods.

Module#remove_const, #private, #public, #protected, #module_function and the hooks are private (#561)

Section titled “Module#remove_const, #private, #public, #protected, #module_function and the hooks are private (#561)”
  • Before: public: Foo.remove_const(:X), M.included(Foo), M.prepended(Foo) and obj.singleton_method_added(:m) work. The hooks are #included, #extended, #prepended, #inherited and #method_added of Module and Class, and BasicObject#singleton_method_added.
  • Now: private: called with an explicit receiver, they raise NoMethodError: private method ... called. send works, and mruby still calls the hooks itself: prepend calls prepended, and def obj.m calls singleton_method_added.
  • Affected: scripts that call one of these methods with an explicit receiver.
  • What to do: call them in the body of the class or module without a receiver, or with send (Foo.send(:remove_const, :X)).

Overrides of append_features, prepend_features and extend_object are not called (#561)

Section titled “Overrides of append_features, prepend_features and extend_object are not called (#561)”
  • Before: include, prepend and extend call these three methods, so a module can override them.
  • Now: the three methods are gone (Module.new.respond_to?(:append_features, true) is false, and the same for the other two). include, prepend and extend add the module without calling them, so an override is skipped without an error. The hooks included, prepended and extended are still called.
  • Affected: modules that override one of the three methods.
  • What to do: move the code to included, prepended or extended.

allbits?, anybits? and nobits? are methods of Integer only (#561)

Section titled “allbits?, anybits? and nobits? are methods of Integer only (#561)”
  • Before: methods of Numeric, so they work on a Float (1.5.allbits?(1) is true).
  • Now: methods of Integer only; on a Float they raise NoMethodError. On an Integer they work as before (6.allbits?(2) is true).
  • Affected: scripts that call them on a Float.
  • What to do: convert a Float with to_i first.
  • Before: FileTest is a class.
  • Now: FileTest is a module. FileTest.exist? and its other methods are called as before.
  • Affected: scripts that use FileTest as a class, other than by calling its methods.
  • What to do: nothing for calls of its methods.

Assigning a constant in a method body is a SyntaxError (#561)

Section titled “Assigning a constant in a method body is a SyntaxError (#561)”
  • Before: allowed (def m; X = 1; end).
  • Now: SyntaxError (syntax error, dynamic constant assignment), when the script is compiled.
  • Affected: scripts that assign a constant inside a method body. The Rack-style Kernel#run of ngx_mruby sets Server with Kernel.const_set.
  • What to do: use Object.const_set(:X, 1) (or Kernel.const_set).

"#@ivar", "#@@cvar" and "#$global" in a string interpolate the variable (#678)

Section titled “"#@ivar", "#@@cvar" and "#$global" in a string interpolate the variable (#678)”
  • Before: in a double-quoted string, a heredoc or a backquoted command, # followed by @, @@ or $ and a name is plain text: @x = 5; "a#@x" is "a#@x".
  • Now: they interpolate the variable, as in CRuby: "a#@x" is "a5", "#$gv" is the value of $gv, and an instance variable that is not set gives an empty string ("a#@nope" is "a"). #{...} works as before (since mruby 4.1, d4aad5d).
  • Why it changed:
    • The reason: mruby 4.1 adds this form of interpolation (see “The bundled mruby is 4.1.0-rc2 instead of 3.3.0”), as CRuby has it.
    • Why the old behavior could not be kept: the compiler of the bundled mruby reads the form; ngx_mruby has no option to turn it off.
    • What the documentation promised: the documentation of 2.x said nothing about it.
  • Affected: scripts whose double-quoted strings contain #@, #@@ or #$ followed by a name, for example a text such as "Ticket #@id" or "price #$total" meant literally, also in response bodies and headers.
  • What to do: find such strings (see Scripts) and escape the # ("a\#@x") or use a single-quoted string ('a#@x'). The string is the same on both versions.

Syntax errors have the messages of Prism (#678)

Section titled “Syntax errors have the messages of Prism (#678)”
  • Before: the parser of mruby 3.3.0 gives messages such as syntax error, unexpected end of file and dynamic constant assignment.
  • Now: mruby 4.1 compiles with Prism, and a SyntaxError has its messages: eval("1 +") raises SyntaxError with syntax error, unexpected end-of-input; expected an expression after the operator, eval("foo(") with syntax error, unexpected end-of-input; expected a `)` to close the arguments, and eval("x = ") with syntax error, expected an expression after `=` (measured with the mruby command of the build). The messages that mruby reports when ngx_mruby compiles a script file or inline code that does not parse come from the same compiler.
  • Why it changed:
    • The reason: mruby 4.1 replaced its parser generated from parse.y with Prism (NEWS.md, “the compiler is Prism”).
    • Why the old behavior could not be kept: the bundled mruby has no other compiler.
    • What the documentation promised: the documentation of 2.x said nothing about the messages of syntax errors.
  • Affected: log monitoring and scripts that match the text of a syntax error, for example of eval or of a script that nginx fails to load.
  • What to do: match on SyntaxError and the file and line, not on the text after syntax error.

An Array, a Hash or a Struct that holds itself can be compared (#678)

Section titled “An Array, a Hash or a Struct that holds itself can be compared (#678)”
  • Before: == and eql? of two arrays, hashes or structs that hold themselves recurse without end and raise SystemStackError: a = []; a << a; b = []; b << b; a == b raises SystemStackError (stack level too deep).
  • Now: such a comparison works as in CRuby. A pair that is already being compared counts as equal, and the other elements decide: a == b above is true, and with a = [1]; a << a; b = [2]; b << b, a == b is false (since mruby 4.1, mruby/mruby#7425; measured with the mruby command of mruby 3.3.0 and of the host build of this release).
  • Why it changed:
    • The reason: mruby 4.1 changes #== and #eql? of Array, Hash and Struct for containers that hold themselves (see “The bundled mruby is 4.1.0-rc2 instead of 3.3.0”).
    • Why the old behavior could not be kept: the bundled mruby has only the new methods; ngx_mruby has no option to bring the old ones back.
    • What the documentation promised: the documentation of 2.x said nothing about it.
  • Affected: scripts that compare containers that hold themselves and rescue the SystemStackError.
  • What to do: nothing for most scripts. A script that relies on the SystemStackError checks for the container itself before the comparison.

Float values have no bit operations (#561)

Section titled “Float values have no bit operations (#561)”
  • Before: ~, &, | and ^ work on the integer part (1.5 & 1 is 1, ~1.5 is -2). For a shift count from 1 up, << multiplies the Float by that power of two and truncates (1.5 << 1 is 3, -1.5 << 1 is -3, 1.5 << 40 is 1649267441664), and gives a Float when the result is outside the Integer range (1.5 << 70 is 1.77088743107612e+21). For a shift count from 1 to 32, >> divides a positive Float by that power of two and truncates (8.0 >> 1 is 4, 1.5 >> 1 is 0), and returns -1 for every negative Float (-8.0 >> 1 is -1). For a count above 32, >> returns 0 for a positive and -1 for a negative Float (1e20 >> 32 is 23283064365, 1e20 >> 33 is 0). A count of 0 returns the Float unchanged (-1.5 >> 0 is -1.5), and a negative count shifts the other way (1.5 >> -1 is 3).
  • Now: ~, &, |, ^, >> and << raise NoMethodError on a Float (mruby 3.4 removed all six).
  • Affected: scripts that apply one of the six operators to a Float.
  • What to do: for ~, &, | and ^, convert with to_i first. For << and >>, to_i first can give another number (1.5.to_i << 1 is 2, -8.0.to_i >> 1 is -4). Where the old number matters: for << by a count from 1 up, multiply the Float by the power of two and call to_i; for >> by a count from 1 to 32, divide a positive Float by the power of two and call to_i, and use -1 for a negative Float; for >> by a count above 32, use 0 for a positive and -1 for a negative Float (dividing would give another number: (1e20 / 2**40).to_i is 90949470, where 1e20 >> 40 was 0); for a count of 0, keep the Float.

String#valid_encoding? is not in the default build (#561)

Section titled “String#valid_encoding? is not in the default build (#561)”
  • Before: defined by mruby-string-ext. With the default build_config.rb, ngx_mruby 2.x builds mruby without MRB_UTF8_STRING, and the method returns true for every string, even "\xfe". A build whose build_config.rb defines MRB_UTF8_STRING gets false for a string that is not valid UTF-8.
  • Now: since mruby 3.4 only mruby-encoding defines the method, and the default build leaves that gem out, so a call raises NoMethodError (undefined method 'valid_encoding?' for String) and a handler that calls it answers 500.
  • Affected: scripts that call String#valid_encoding?.
  • What to do: with the default build_config.rb of 2.x, drop the call (it never returned false there), or build with mruby-encoding and check the scripts as Core gems says. A 2.x build that defined MRB_UTF8_STRING needs mruby-encoding to keep the check. Why the default build leaves mruby-encoding out: the gem defines MRB_UTF8_STRING for the whole build, so String#size, #[] and #index count characters instead of bytes, and a script that computes a Content-Length from String#size would get another number; the owner decided on 2026-10-04 to leave it out of the default build and keep it opt-in.

A seeded Random gives other numbers (#561)

Section titled “A seeded Random gives other numbers (#561)”
  • Before: Random.new(seed) and srand(seed) give one sequence for a seed (xoshiro).
  • Now: another sequence for the same seed: mruby 4.0 uses PCG instead of xoshiro.
  • Affected: scripts that depend on the numbers of a seeded generator.
  • What to do: do not depend on the numbers of a seeded generator across versions.

Set#inspect and Set#to_s use a new format, and Set#flatten_merge is removed (#561)

Section titled “Set#inspect and Set#to_s use a new format, and Set#flatten_merge is removed (#561)”
  • Before: #<Set: {1, 2}>. Set#flatten_merge is a public method: Set.new([1]).flatten_merge(Set.new([2, Set.new([3])])) is the Set of 1, 2 and 3.
  • Now: Set[1, 2]. Everything that prints a Set with these methods changes with them: string interpolation ("#{set}"), sprintf("%s", set) and Array#inspect. mruby 4.0.0 removed Set#flatten_merge, and a call raises NoMethodError; mruby’s lists of user-visible changes do not name it.
  • Affected: scripts that use the inspect or to_s of a Set as a data format, or compare it with a fixed string, and scripts that call Set#flatten_merge.
  • What to do: as for Hash#inspect: build the string yourself (set.to_a.join(",") gives the same string on both versions). In place of s.flatten_merge(t), call s.merge(Set.new(t).flatten), which gives on both versions the Set that s.flatten_merge(t) gave on 2.x, for a Set and for an Array t.

Hash#default_proc= raises TypeError for an object that is not a Proc (#561)

Section titled “Hash#default_proc= raises TypeError for an object that is not a Proc (#561)”
  • Before: accepted.
  • Now: TypeError.
  • Affected: scripts that pass Hash#default_proc= an object that is not a Proc.
  • What to do: pass a Proc or nil.

yield with keyword arguments to a block with keyword parameters works (#561)

Section titled “yield with keyword arguments to a block with keyword parameters works (#561)”
  • Before: ArgumentError: missing keyword.
  • Now: the block gets the keyword arguments.
  • Affected: scripts that yield keyword arguments to a block that takes keyword parameters, for example a script that rescued the ArgumentError.
  • What to do: nothing; it is a bug fix of mruby.

A return inside a block or a for body of handler code ends the code (#561)

Section titled “A return inside a block or a for body of handler code ends the code (#561)”
  • Before: a return inside a block, such as [0].each do ... end or 3.times { ... }, or inside the body of for, at the top level of handler code raised LocalJumpError, and the handler answered 500 with mrb_run failed: return 500 HTTP status code to client: error: unexpected return (LocalJumpError) in error.log. A content handler that had written output before it answered 500 as well and did not send that output. 2.7.0 sent that output with 200 and only logged the exception; 2.7.1 changed this for every exception after Nginx.rputs (entry 3 of the 2.7.1 release notes). The variable of mruby_set_code got an empty value. A return at the top level of the code, outside a block, ended the code.
  • Now: such a return ends the code, as a return at the top level does. The code after it does not run, and the response is the one that the code set before it: the status that Nginx.return set and the output that Nginx.rputs wrote. In mruby_set_code, the value of a return in a block becomes the variable. error.log has no line for it.
  • Why it changed:
    • The defect: #502: the return that ends a handler early raised LocalJumpError when it was written inside a block or a for body, and the handler answered 500 instead of the response that the code had set.
    • Why the old behavior could not be kept: the error came from mruby 3.3.0. ngx_mruby runs handler code in the first frame of a fiber; mruby 3.3.0 refuses that frame as the frame that such a return leaves, and mruby 4.0.0 and 4.1.0-rc2 accept it (section 1.3 of the proposal for the frame of handler code). Keeping the error would have meant changing the bundled mruby back to the rule of 3.3.0, for a behavior that #502 reports as a defect.
    • What the documentation promised: docs/class_and_method/README.md of 2.x says that ngx_mruby supports the return statement in handler code and that it returns from the handler, with no exception for a block.
  • Affected: handler code with a return inside a block or the body of for at its top level; a return inside a method or a lambda is not affected. Log alerts and scripts that relied on the 500 or on the LocalJumpError line are affected as well.
  • What to do: nothing. The two ways around it on 2.x, a return at the top level of the code and the code in a method or a lambda, work on both versions.
  • Not changed by this release: the frame in which handler code runs. self is main, local variables belong to one run of the code, and constants, globals, instance variables of main and methods defined with def persist in the worker (section 1.4 of the proposal).

A content handler that ends without output answers 200 with an empty body instead of 500 (#574)

Section titled “A content handler that ends without output answers 200 with an empty body instead of 500 (#574)”
  • Before: on 2.7.1 and 2.7.2, a content handler on the main request that ended without output (it wrote nothing, or only "" or nil with Nginx.rputs, or only set response headers) got 500 with nginx’s error page (or the error_page configured for 500) and Connection: close when it set no status, Nginx::HTTP_OK (with Nginx.return, Nginx.send_header or Nginx.status_code=) or another status below 300 other than 201 and 204 (for example Nginx::HTTP_ACCEPTED), also after Nginx::Async::HTTP.sub_request resumed it (entry 13 of the 2.7.1 release notes). error.log got a line at the error level: status code is 200, but response body is empty. return NGX_HTTP_INTERNAL_SERVER_ERROR, status code is not set, and response body is empty. return NGX_HTTP_INTERNAL_SERVER_ERROR or status code is <N>, but response body is empty. return NGX_HTTP_INTERNAL_SERVER_ERROR. On 2.7.0 and earlier, Nginx::HTTP_OK without output got the same 500, and the other cases got no response at all: nginx closed an HTTP/1.0 connection without sending a byte and kept a keep-alive connection open without a response until keepalive_timeout.
  • Now: such a handler answers as nginx’s own return 200; does: with the status it set, 200 when it set none, Content-Length: 0 and an empty body. It sends no Content-Type, as ngx_mruby’s answers with output do not; nginx’s return 200; sends the one of default_type. A HEAD request gets the same header. The header filters and body filters of the location (mruby_output_header_filter, mruby_output_body_filter and their _code forms) run on the empty response. The empty answer discards an unread request body first, as the answer with output does since 2.7.1 (entry 12 of the 2.7.1 release notes), so the next request on a kept connection is the one that the client sent after the body. nginx keeps an otherwise reusable connection for the next request, including a HEAD response finalized by the known-length output body filter. error.log gets none of the lines above for it.
  • Why it changed:
    • The defect: #200: a content handler that ended with Nginx.return Nginx::HTTP_OK and no body answered 500, where nginx’s own return 200; answers 200 with an empty body. HTTP allows that response: “a 200 response is expected to contain message content unless the message framing explicitly indicates that the content has zero length” (RFC 9110, section 15.3.1), which Content-Length: 0 does. 2.7.1 gave the same 500 to no status and to the other statuses below 300 that nginx does not answer by itself, because those requests had got no response at all (#566).
    • Why the old behavior could not be kept: with the 500, a content handler cannot answer 200 with an empty body at all; the only empty answer that it can choose is 204, which is another status for clients and caches. The v3 plan accepts the empty 200 as a behavior change of v3 (section 7, item 8 of docs/proposals/v3-plan.md); the 2.x line keeps the 500 because it puts compatibility first.
    • What the documentation promised: the documentation of 2.7.1 described the old behavior: a content handler that ends without output answers 500, and an empty body takes Nginx::HTTP_NO_CONTENT (Nginx.return of 2.7.1). Before 2.7.1, it said only that Nginx.return “Returns nginx status code to send back HTTP status to the client” (Nginx.return of 2.7.0).
  • Affected: mruby_content_handler and mruby_content_handler_code handlers that can end without output, for example a handler that writes only when a condition holds, one that passes a value that can be empty or nil to Nginx.rputs, one that only sets response headers, and one that ends with Nginx.return Nginx::HTTP_OK and no body, and log monitoring of the lines above. Unchanged: a status below 200 without output (500 and the status code is <N>, but response body is empty line, as on 2.7.1 and 2.7.2), 201, 204 and the statuses from 300 up (nginx answers them), handlers with output, Nginx.redirect, the other handlers (Nginx.return Nginx::HTTP_OK without output in a rewrite or access handler still answers 500 and logs status code is 200, but response body is empty), and subrequests (Nginx::Async::HTTP.sub_request, SSI includes and auth_request): the content handler of a subrequest that returns Nginx::HTTP_OK without output still sets the subrequest’s status to 500. nginx’s own return 200; gives a subrequest 200 instead. Keeping the 500 makes auth_request treat that result as an error, instead of allowing the request as a 2xx result would. A handler that writes nothing and sets no status still ends the subrequest without a response body and without a status.
  • What to do: nothing for most configurations: a handler that should answer with an empty body may now return Nginx::HTTP_OK. A script that relied on the 500 to signal that it had nothing to send must set that status itself, for example Nginx.return Nginx::HTTP_INTERNAL_SERVER_ERROR or Nginx.return Nginx::HTTP_NOT_FOUND, which nginx answers as before. Log monitoring that matches response body is empty. return NGX_HTTP_INTERNAL_SERVER_ERROR finds only the statuses below 200 of content handlers, and Nginx::HTTP_OK in the other handlers and in subrequests.
  • Tests: port 18136 (test/conf/conf.d/54-content-empty-body.conf, test/t/cases/content_empty_body.rb, with two POST requests whose body the handler does not read on one connection), and the cases “Nginx.return 200 dont have body” of test/t/ngx_mruby.rb and “send_header 200 without a body answers 200 with an empty body” of test/t/cases/request_api.rb.

An output body filter that ends with an empty body sends the response instead of closing the connection (#574)

Section titled “An output body filter that ends with an empty body sends the response instead of closing the connection (#574)”
  • Before: when an output body filter (mruby_output_body_filter, mruby_output_body_filter_code) ended with an empty body, because it set "" with Nginx::Filter#body= or Nginx::Filter#output, or because the response had no body and the filter left it empty, nginx logged zero size buf in writer at the alert level and closed the connection before it wrote the status line: the client received no byte. This holds on 2.7.2, 2.7.1 and earlier releases.
  • Now: the response is sent with its status, Content-Length: 0 and an empty body, and error.log gets no alert line for it.
  • Why it changed:
    • The defect: the body filter passed on the empty body as a buffer of zero bytes marked as being in memory, which nginx’s writer rejects (zero size buf in writer), so the response was never sent. nginx’s own return 200; passes an empty last buffer that is not marked so (ngx_http_send_response). The 2.x line has this defect up to 2.7.2: test/t/cases/filter_connection.rb of 2.7.1 records it as the behavior of 2.x (“an empty String closes the connection without a response”). 2.7.3 fixes it on the 2.x line in the same way (entry 8 of the 2.7.3 release notes).
    • Why the old behavior could not be kept: a response that is never sent leaves the client without an answer. The empty 200 of the entry above also passes through the body filter of its location, so without this change such a location would send no response at all instead of the empty 200.
    • What the documentation promised: Nginx::Filter#body= of 2.7.1 says that the response is sent with exactly the body that the filter sets, and that Content-Length is its length, with no exception for an empty String.
  • Affected: locations with an output body filter that can end with an empty body, including a location whose content handler ends without output (the entry above), and log monitoring of the zero size buf in writer line, which these responses no longer log.
  • What to do: nothing.
  • Tests: port 18112 (test/t/cases/filter_connection.rb, “an empty String sends the status with Content-Length: 0”) and the locations with a body filter on port 18136 (test/t/cases/content_empty_body.rb).

The accessors of Nginx::Var become methods of Nginx::Var at their first use in a worker (#610)

Section titled “The accessors of Nginx::Var become methods of Nginx::Var at their first use in a worker (#610)”
  • Before: every v.NAME and v.NAME = value on an Nginx::Var went through Nginx::Var#method_missing. Nginx::Var had three methods of its own, method_missing, exist? and set: v.respond_to?(:request_method) returned false, and Nginx::Var.instance_methods(false) listed only those three. When a script defined a method on Object or Kernel whose name was also the name of a variable, for example with a def at the top level of handler code, v.NAME called that method instead of reading the variable.
  • Now: the first v.NAME or v.NAME = value of a name in a worker process also defines NAME or NAME= as a method of Nginx::Var, and the later accesses of the name in that worker call the method. The method reads and writes the variable as method_missing does: the values, nil for a name that is not a variable, the exceptions and the lines of error.log are the same. A worker defines a getter and a setter for each declared variable that scripts use (the variables of nginx and its modules, and the ones that set declares), and a getter for the first 16 names of prefix variables that scripts use, such as arg_q or http_x_request_id. A name gets a method only when it is made of a to z, 0 to 9 and _, with = at the end for a setter; v.Request_Method keeps reading $request_method through method_missing. A name that is not a variable, a setter of a prefix variable, an instance of a subclass of Nginx::Var, a frozen Nginx::Var, and a name that Nginx::Var or one of its ancestors already has as a method get no method. After the first access, v.respond_to?(:NAME), v.methods, Nginx::Var.instance_methods(false) and Nginx::Var.method_defined?(:NAME) show the method. What they show depends on the requests that the worker has served, so two workers can answer differently. Once the method exists, a method of the same name that a script defines later on Object or Kernel no longer hides the variable from v.NAME.
  • Why it changed:
    • The reason: with mruby 4.0.0, the lookup of a method name that no class defines compares the name with every method of Nginx::Var, Object, Kernel and BasicObject, more than 110 entries, and mruby does not cache a name that it did not find. Each v.NAME paid that search before method_missing ran. In the callgrind comparison of #561, the search made 74% of the difference of the var scenario and 59% of that of the auth scenario against mruby 3.3.0 (section 1.1 of the proposal). A method of the name is found in mruby’s method cache instead.
    • Why the old behavior could not be kept: mruby’s method cache answers only for a method that the lookup found, so a change that lets v.NAME skip the search has to define a method, and introspection shows it. The other ways of the proposal leave the scripts as they are written today on the slow path, or wait for a release of mruby (section 2 of the proposal). The owner accepted the change to introspection as a behavior change of 3.0.0 on 2026-10-15, and confirmed it on 2026-10-19 (the status of the proposal).
    • What the documentation promised: the Nginx::Var class of 2.7.1 says that Nginx::Var#method_missing is called when Nginx::Var#VARNAME or Nginx::Var#VARNAME= is evaluated. It said nothing about respond_to? or the methods of Nginx::Var.
  • Affected: scripts that call respond_to?, methods, instance_methods or method_defined? on Nginx::Var or its instances, for example to tell whether a name is a variable, scripts that define a method on Object or Kernel with the name of a variable that they also read with v.NAME, and scripts that wrap Nginx::Var#method_missing, for example with a module prepended to Nginx::Var whose method_missing calls super: the wrapper runs only for the first access of a name that gets a method.
  • What to do: use v.exist?(name) to tell whether a variable exists. Give the methods of your scripts names that are not names of nginx variables.
  • Tests: port 18159 (test/conf/conf.d/68-var-accessor.conf, test/t/cases/var_method_lookup.rb).

Nginx::Connection, Nginx::Server and Nginx::Request read their variables without calling Nginx::Var (#610)

Section titled “Nginx::Connection, Nginx::Server and Nginx::Request read their variables without calling Nginx::Var (#610)”
  • Before: Nginx::Connection#remote_ip, #remote_port, #local_ip and #local_port, Nginx::Server#document_root, #realpath_root and #path, and Nginx::Request#hostname, #authority, #filename, #user and #get_body called the accessor of their variable (remote_addr, remote_port, server_addr, server_port, document_root, realpath_root, host, http_host, request_filename, remote_user and request_body) on an Nginx::Var that the object created and kept in its instance variable @iv_var. A script that defined such a method on Nginx::Var, defined a method_missing of its own there, or put another object in @iv_var, changed what these methods returned.
  • Now: these methods read the variable from nginx in C. They return the value that nginx has for the variable, whatever methods a script defines on Nginx::Var, and they neither create an Nginx::Var nor set @iv_var. Nginx::Request#var still creates the Nginx::Var of the object and keeps it in @iv_var. Outside a request they raise the same RuntimeError as before.
  • Why it changed:
    • The reason: the names of these variables are fixed, and “Design principles” in AGENTS.md asks that nothing fixed is looked up or allocated per request when it can be prepared once at initialization. The Ruby call looked the method up on Nginx::Var on each call, which takes the search of the entry above, and each object created an Nginx::Var and looked up its class. The names and their hash keys are now prepared once (candidate (d) of the proposal).
    • Why the old behavior could not be kept: the Ruby call on the object in @iv_var is what let a script change the values. Reading the variable without that call removes both the cost and that effect.
    • What the documentation promised: the Nginx::Connection class of 2.7.1 says that remote_ip, remote_port, local_ip and local_port are the same as the nginx variables $remote_addr, $remote_port, $server_addr and $server_port, and Nginx::Server#realpath_root says the same of $realpath_root. That is what they return now in every case.
  • Affected: scripts that change what these methods return by defining methods on Nginx::Var, a method_missing of their own on it, or another object in @iv_var, and scripts that read @iv_var of these objects without calling Nginx::Request#var first.
  • What to do: to return another value, define the method on Nginx::Connection, Nginx::Server or Nginx::Request itself, or call a method of your own. Read variables with Nginx::Var (Nginx::Request#var, Nginx.var or Nginx::Var.new) instead of @iv_var.
  • Tests: port 18159 (test/t/cases/var_method_lookup.rb).

Dir comes from mruby’s core gem, and a closed Dir raises IOError instead of RuntimeError (#559)

Section titled “Dir comes from mruby’s core gem, and a closed Dir raises IOError instead of RuntimeError (#559)”
  • Before: Dir comes from iij/mruby-dir. Reading, iterating or closing a Dir that is closed raises RuntimeError (closed directory), and so does Dir.open with a block when the block closes the Dir. Dir#each and Dir.foreach without a block raise NoMethodError.
  • Now: Dir comes from mruby-dir, a core gem of mruby 4 that started from iij/mruby-dir and has every method of it. Reading, iterating or closing a Dir that is closed raises IOError (closed directory). Dir.open with a block returns the value of the block also when the block closes the Dir. Dir#each and Dir.foreach without a block return an Enumerator. Dir.foreach with a block closes the Dir that it opened (see “Fixes”), and Dir has methods that iij/mruby-dir does not have (see “New features”).
  • Why it changed:
    • The reason: the v3 plan replaces the third-party gems iij/mruby-env, iij/mruby-process and iij/mruby-dir with core gems of mruby (docs/proposals/v3-plan.md, section 4, Pillar A). mruby 4.0.0 had a core gem only for Dir; 4.1 also has mruby-env and mruby-process, which replace the other two gems of iij (#766).
    • Why the old behavior could not be kept: the RuntimeError comes from iij/mruby-dir, which raises it for a closed directory unless it is compiled with ENABLE_IO, and the default build does not define it. Keeping the RuntimeError would have meant keeping iij/mruby-dir, which has had no commit since 2018-09-14 and leaves the Dir that Dir.foreach opens open until the GC frees it.
    • What the documentation promised: docs/class_and_method/README.md of 2.x lists the Dir class among the classes of the default build and links it to iij/mruby-dir, whose README lists the methods and says nothing about the exception for a closed Dir.
  • Affected: scripts that rescue RuntimeError around the methods of a Dir that can be closed, or around Dir.open with a block that closes the Dir. When the rescue RuntimeError no longer catches the exception, the handler answers 500 (mrb_run failed: ... error: #<IOError: closed directory>).
  • What to do: rescue IOError. A script that runs on both versions rescues IOError and RuntimeError, or StandardError.

ENV comes from mruby’s core gem: ENV.to_hash is gone, and ENV is Enumerable (#766)

Section titled “ENV comes from mruby’s core gem: ENV.to_hash is gone, and ENV is Enumerable (#766)”
  • Before: ENV comes from iij/mruby-env. It has [], []=, store, delete, fetch, has_key? (and key?, include?, member?), keys, values, size, to_a, to_hash, inspect, to_s and clear. ENV.each, ENV.to_h, ENV.select, ENV.empty? and ENV.length raise NoMethodError. Setting a variable whose name contains = raises RuntimeError (can't change environment variable), and ENV.freeze returns ENV.
  • Now: ENV comes from mruby-env, a core gem of mruby 4.1. It has the methods above except to_hash, which raises NoMethodError; ENV.to_h returns the variables as a Hash. ENV includes Enumerable and has each (each_pair), each_key, each_value, select (filter), reject, slice, empty?, length, key, has_value? (value?), assoc, rassoc, replace and update (merge!). A name that contains = or a NUL byte, and a value that contains a NUL byte, raise ArgumentError. ENV.freeze raises TypeError. The KeyError of ENV.fetch quotes the name (key not found: "NAME").
  • Why it changed:
    • The reason: the v3 plan replaces iij/mruby-env, iij/mruby-process and iij/mruby-dir with core gems of mruby (docs/proposals/v3-plan.md, section 4, Pillar A, and step 3 of section 6). iij/mruby-env has had no commit since 2018-09-03, and mruby 4.1 has a core gem of the same name, mruby-env, that defines ENV.
    • Why the old behavior could not be kept: to_hash and the RuntimeError come from iij/mruby-env. Keeping them would have meant keeping that gem in place of mruby’s own gem of the same name.
    • What the documentation promised: docs/class_and_method/README.md of 2.x lists ENV among the classes of the default build and links it to iij/mruby-env, whose README lists to_hash among its methods and says nothing about the exceptions.
  • Affected: scripts that call ENV.to_hash, or that rescue RuntimeError around setting a variable with = in its name. nginx removes the environment variables of its workers except TZ and the ones that env directives name, so the variables that a handler sees are those.
  • What to do: call ENV.to_h in place of ENV.to_hash. A script for both versions uses ENV.keys.each_with_object({}) { |k, h| h[k] = ENV[k] }, or reads the variables it needs with ENV[name].

Process comes from mruby’s core gem: Process.fork, Kernel#fork and Kernel#system are gone (#766)

Section titled “Process comes from mruby’s core gem: Process.fork, Kernel#fork and Kernel#system are gone (#766)”
  • Before: Process comes from iij/mruby-process, which also defines Kernel#fork and Kernel#system. A handler can start a child process with fork or Process.fork and run a shell command with system. Process::Status#to_int returns the raw status, and Process::Status.new(pid, status) makes a status, for example to set $?.
  • Now: Process comes from mruby-process, a core gem of mruby 4.1. It has Process.pid, .ppid, .kill, .waitpid, .waitpid2 and $$ as before. $$ is set once, when nginx reads the configuration, so in a worker under a master process it is the pid of the master, as with 2.x; Process.pid is the pid of the worker. Process::Status has the instance methods of 2.x except to_int, and no Process::Status.new: a status comes only from Process.waitpid and its variants, or from IO.popen through $?. Process.fork, Kernel#fork, Kernel#system, Process::Status#to_int and Process::Status.new are gone: a call raises NoMethodError, and the handler answers 500. Process::Status#to_s describes the status as CRuby does (pid 1234 exit 0) instead of returning the raw status as digits, Process::Status#inspect follows it (#<Process::Status: pid 1234 exit 0>, where 2.x printed #<Process::Status: pid=1234,exited(0)>), and Process::Status#success? returns nil instead of false for a process that did not exit. Process::WNOHANG and Process::WUNTRACED keep the values 1 and 2. The new methods are under “New features”. mruby-process depends on the core gem mruby-signal, so scripts also get Signal (Signal.list and Signal.signame; there is no Signal.trap).
  • Why it changed:
    • The reason: the v3 plan replaces iij/mruby-process with mruby’s core gem (see the entry of ENV above). iij/mruby-process has had no commit since 2019-12-25.
    • Why the old behavior could not be kept: fork and system come from iij/mruby-process, and mruby-process of mruby 4.1.0-rc2 does not define them. Keeping them would have meant keeping that gem in place of mruby’s own gem of the same name. A fork in a worker copies the worker, its connections included, and system waits for the command, so neither fits a handler.
    • What the documentation promised: docs/class_and_method/README.md of 2.x lists Process among the classes of the default build and links it to iij/mruby-process, whose README lists fork, exit, exit!, sleep and system under Kernel.
  • Affected: scripts that call fork, Process.fork, system, Process::Status#to_int or Process::Status.new, and log parsers that read Process::Status#to_s or #inspect.
  • What to do: start other processes outside nginx, for example from a service that the handler reaches over the network, or run a command with IO.popen of mruby-io, which waits in the worker as system did. Call Process::Status#to_i in place of to_int. The core gem has no replacement for Process::Status.new: keep the pid and the status in variables of your own. Use Process.pid for the pid of the worker.

exit in a handler raises SystemExit instead of ending the worker process (#766)

Section titled “exit in a handler raises SystemExit instead of ending the worker process (#766)”
  • Before: iij/mruby-process defines Kernel#exit and Kernel#exit!, and its definitions replace those of the core gem mruby-exit, because the build initializes iij/mruby-process after the core gems. exit calls exit(3) of the C library: in a handler, it ends the nginx worker process, and the requests that the worker was serving end without a response. exit! calls _exit(2).
  • Now: exit comes from mruby-exit and raises SystemExit. In a handler, the exception ends the handler like any other exception: the handler answers 500 and error.log has the mrb_run failed line; the worker keeps running. rescue => e does not catch SystemExit, which is not a StandardError. exit! comes from mruby-exit as well and calls exit(3), which ends the process and runs the atexit handlers; without an argument it exits with status 0, where the exit! of 2.x exited with 1 through _exit(2). Outside handlers, in mruby_init, mruby_init_code, mruby_init_worker, mruby_exit_worker and the stream code, exit raises SystemExit as well, and ngx_mruby treats it as an exception of that code: in mruby_init and mruby_init_code, for example, nginx stops reading the configuration with an error, where 2.x ended the nginx that read it.
  • Why it changed:
    • The reason: the definitions of iij/mruby-process left the build with it (see the entry of Process above). With the build of next before this change, mruby -e 'exit 3' ended with status 3 without raising SystemExit, and with this change the same code raises SystemExit. 2.x declares iij/mruby-process after full-core.gembox in the same way, and its mruby sorts the gems by the same rule.
    • Why the old behavior could not be kept: the old exit came only from iij/mruby-process. A worker that ends drops the requests of every client that it serves, and the master starts another worker.
    • What the documentation promised: the documentation of 2.x did not describe exit in a handler. The README of iij/mruby-process lists exit and exit! under Kernel.
  • Affected: scripts that call exit in a handler, whether to stop the worker or to end the handler, scripts that call exit in the code that nginx runs outside requests, and scripts that call exit! without an argument.
  • What to do: remove exit from handlers. To answer with a status, call Nginx.return with it and let the code run to its end. To stop nginx, send nginx’s signals to the master process.

sleep without an argument raises ArgumentError (#766)

Section titled “sleep without an argument raises ArgumentError (#766)”
  • Before: iij/mruby-process defines Kernel#sleep, which replaces the one of the core gem mruby-sleep for the same reason as exit (see the entry above). It takes no argument or one: sleep without an argument waits until the process gets a signal, and in a handler it stops the worker for good.
  • Now: sleep comes from mruby-sleep and takes exactly one argument, an Integer or a Float of seconds. sleep without an argument raises ArgumentError, and the handler answers 500. A negative number raises ArgumentError (time interval must not be negative), where 2.x raised the error of select(2) (Errno::EINVAL). usleep came from mruby-sleep before as well and is unchanged.
  • Why it changed:
    • The reason: the definition of iij/mruby-process left the build with it (see the entry of Process above).
    • Why the old behavior could not be kept: the old sleep came only from iij/mruby-process.
    • What the documentation promised: the documentation of 2.x did not describe sleep without an argument.
  • Affected: scripts that call sleep without an argument, or rescue Errno::EINVAL around sleep with a negative number. A sleep with an argument still waits in the worker; Nginx::Async.sleep waits without blocking it.
  • What to do: give sleep the seconds to wait, or use Nginx::Async.sleep with milliseconds in a handler.

The default build leaves out Vedis and Cache (mruby-vedis and mruby-localmemcache) (#766)

Section titled “The default build leaves out Vedis and Cache (mruby-vedis and mruby-localmemcache) (#766)”
  • Before: the default build has matsumotory/mruby-vedis, which defines Vedis, an embedded key-value store, and matsumotory/mruby-localmemcache, which defines Cache, a key-value store in shared memory on the localmemcache library.
  • Now: the default build has neither gem. A script that uses Vedis or Cache raises NameError, and its handler answers 500 (mrb_run failed: ... error: #<NameError: uninitialized constant Vedis>). Both lines stay in build_config.rb as comments.
  • Why it changed:
    • The reason: the v3 plan drops both gems from the default list (docs/proposals/v3-plan.md, section 4, Pillar A). The build of mruby-vedis clones symisc/vedis at the head of its default branch, which build_config.rb.lock cannot pin and which has had no commit since 2021-11-25. mruby-localmemcache carries a copy of localmemcache, whose repository sck/localmemcache has had no commit since 2013-05-21.
    • Why the old behavior could not be kept: keeping the gems would keep, in every default build, a library that no one updates and, for vedis, a clone that the lock does not pin. AGENTS.md (“Other repositories”) allows removing a gem of the owner when the library under it is no longer maintained.
    • What the documentation promised: docs/class_and_method/README.md of 2.x lists Cache and Vedis among the classes of the default build.
  • Affected: scripts that use Vedis or Cache.
  • What to do: keep the data in Redis (Redis, in the default build) or in a store of your own. To keep using a gem, uncomment its line in build_config.rb, remove mruby/build and build again; the first build clones the head of the gem’s branch and adds its entry to build_config.rb.lock. The test suite of this release does not run with these gems.

Digest and SecureRandom come from gems of ngx_mruby that need OpenSSL 3.0 or later (#771)

Section titled “Digest and SecureRandom come from gems of ngx_mruby that need OpenSSL 3.0 or later (#771)”
  • Before: Digest comes from iij/mruby-digest and SecureRandom from monochromegane/mruby-secure-random. iij/mruby-digest builds with OpenSSL 1.0.2 and later, and on macOS with CommonCrypto instead of OpenSSL. dup and clone of a Digest::SHA256 (or another class of Digest) return an object that has taken no data. With OpenSSL 1.1 and later, Digest::HMAC#digest and #hexdigest end the HMAC: a second call, or a call after update that follows the first, does not return the HMAC of the data. With OpenSSL 3.0.0 to 3.0.6, whose default provider has no RIPEMD160, Digest::RMD160 does not return the RIPEMD160 hash. SecureRandom opens and reads /dev/urandom on every call. SecureRandom.urlsafe_base64(n) ignores n and encodes 16 random bytes. SecureRandom.random_bytes with a negative number raises NameError: the gem rescues the ArgumentError of IO#read and raises File::NoFileError, which mruby-io does not define.
  • Now: Digest comes from mrbgems/digest of this repository, which computes the hashes with the EVP API of OpenSSL 3 and HMAC with EVP_MAC, and SecureRandom from mrbgems/secure-random, which takes the bytes from RAND_bytes of OpenSSL. The classes, methods, arguments and return values are those of the two gems (Digest and SecureRandom in the documentation of the classes), with these differences: dup and clone of a digest copy the data that it has taken; Digest::HMAC#digest and #hexdigest leave the HMAC as it was, so they can be called again and update can follow; Digest::RMD160.new (and new of any class of Digest whose algorithm the OpenSSL of the process does not provide, such as MD5 under the FIPS provider) raises NotImplementedError; SecureRandom opens no file; SecureRandom.urlsafe_base64(n) encodes n bytes; and SecureRandom.random_bytes with a negative number raises ArgumentError. The build of the bundled mruby stops on an OpenSSL older than 3.0 with #error, on LibreSSL and BoringSSL, which have no EVP_MAC, and on macOS without the headers and the libcrypto of an OpenSSL 3. The two gems have the gem names of the gems that they replace, mruby-digest and mruby-secure-random, so a third-party gem that depends on one of these names gets the gem of this repository.
  • Why it changed:
    • The reason: the v3 plan replaces mruby-secure-random with a small gem on RAND_bytes or getrandom and reimplements mruby-digest on the EVP API of OpenSSL 3 (docs/proposals/v3-plan.md, section 4, Pillar A). The list of mruby gems has no maintained replacement: Asmod4n/mruby-sysrandom has another API, and nothing replaces mruby-digest. iij/mruby-digest computes HMAC with HMAC_CTX, which OpenSSL 3 deprecates. Gems in this repository are checked by the test suite, CI and the perf job of ngx_mruby. The v3 plan sets OpenSSL 3.5 as the baseline and drops 1.1.1 and 3.0 (item 3 of section 7).
    • Why the old behavior could not be kept: the differences of dup, Digest::HMAC#digest and urlsafe_base64(n) are defects of the old gems that a script cannot rely on, and keeping them would mean writing them again on purpose. EVP_MAC, which OpenSSL 3 provides in place of HMAC_CTX, does not exist in OpenSSL 1.1.1, LibreSSL or BoringSSL.
    • What the documentation promised: docs/class_and_method/README.md of 2.x lists Digest and SecureRandom among the classes of the default build and links them to the two gems. The README of iij/mruby-digest says that its classes are compatible with those of CRuby, where dup of a digest keeps its data and an HMAC object returns its digest more than once. The README of mruby-secure-random shows urlsafe_base64 without n and says nothing about n.
  • Affected: builds with OpenSSL 1.1.1 or older, LibreSSL or BoringSSL, also with --with-openssl-src, and builds on macOS that took CommonCrypto; scripts that call dup or clone of a digest, digest or hexdigest of a Digest::HMAC more than once, Digest::RMD160 or urlsafe_base64(n), or rescue NameError around random_bytes; and a build_config.rb of your own that adds iij/mruby-digest or monochromegane/mruby-secure-random next to the default gems, which defines the same gem twice.
  • What to do: build with OpenSSL 3.0 or later (3.5 is the baseline of v3); on macOS, install OpenSSL 3, for example with Homebrew, whose /opt/homebrew/opt/openssl and /usr/local/opt/openssl configure finds; give the include and lib directories of an OpenSSL 3 in another place in NGX_MRUBY_CFLAGS and NGX_MRUBY_LDFLAGS. A script that relied on urlsafe_base64(n) returning 22 characters calls urlsafe_base64 without n. A script that relied on dup starting empty calls Digest::SHA256.new (or the class it uses) instead. Remove a line of iij/mruby-digest or monochromegane/mruby-secure-random from a build_config.rb of your own.

nginx 1.30 (stable) and 1.31 (mainline) are the oldest supported versions (#789)

Section titled “nginx 1.30 (stable) and 1.31 (mainline) are the oldest supported versions (#789)”
  • Before: the CI of 2.7.5 builds and tests nginx 1.31.8, 1.30.6, 1.28.3 and 1.26.3, and the source of 2.x keeps nginx_version branches for nginx versions down to 0.8.11. With nginx 1.24.0, 2.x builds only without the stream module: with the default options of build.sh (--with-stream) the build stops while it compiles src/stream/ngx_stream_mruby_core.c, with unknown type name 'ngx_stream_listen_opt_t' (measured on 2026-11-11 with 2.7.5 and with master at 10c4cd927).
  • Now: this release supports nginx 1.30 (stable) and 1.31 (mainline), which its CI builds and tests (1.30.6 and 1.31.8). The oldest supported versions move up every April, when nginx starts a new stable line. The nginx_version branches of src/ for nginx older than 1.25.5 are removed. Neither ./configure nor build.sh checks the version of nginx: on 2026-11-11, build.sh, with and without --with-stream, completed with nginx 1.28.3 and 1.26.3, which CI does not test, and stopped with nginx 1.24.0 while it compiled src/http/ngx_http_mruby_server.c, with 'ngx_http_listen_opt_t' has no member named 'type'.
  • Why it changed:
    • The reason: item 2 of section 7 of the v3 plan sets nginx 1.30 stable and 1.31 mainline as the oldest versions that v3 supports, raised every April, and its Pillar A row removes the branches for nginx older than 1.25.5 (docs/proposals/v3-plan.md). nginx.org lists 1.28.3 and 1.26.3 as legacy versions, and the fixes of nginx after 1.30.0 went only to 1.30.x and 1.31.x (section 3.1 of the plan).
    • Why the old behavior could not be kept: each supported nginx line adds four cells to the build matrix of the nightly run and of the check before a tag, for lines that nginx no longer fixes. The removed branches served nginx versions that CI had not built for years, so no test checked them.
    • What the documentation promised: the README of 2.7.5 says that ngx_mruby supports the nginx mainline and stable lines, without versions, and says that v3 will support 1.30 and 1.31 as the oldest versions.
  • Affected: builds with an nginx older than 1.30: builds with nginx 1.28 or 1.26, which 2.x builds and tests, and builds with nginx 1.24, such as the package of Ubuntu 24.04, which 2.x builds only without the stream module.
  • What to do: build with nginx 1.30 or 1.31. To keep nginx 1.28 or 1.26, stay on 2.x (the branch v2.x or the latest v2.* tag), which is supported for twelve months after v3.0.0 (SECURITY.md). With nginx 1.24, 2.x builds only without --with-stream.

C extensions: an object of a class not declared MRB_TT_DATA cannot wrap C data (#561)

Section titled “C extensions: an object of a class not declared MRB_TT_DATA cannot wrap C data (#561)”
  • Before: mruby 3.x did not check a class whose instance type was not set: a gem that wraps a C struct with Data_Wrap_Struct or mrb_data_object_alloc in an object of its own class got the object.
  • Now: mruby 4.0 raises TypeError: allocation failure of <class> at the allocation, unless the class is declared with MRB_SET_INSTANCE_TT(klass, MRB_TT_DATA).
  • Affected: mrbgems and C extensions that wrap C data in a class without that declaration. matsumotory/mruby-uname at its commits before matsumotory/mruby-uname#1 is one: every method of Uname raises TypeError: allocation failure of Uname, and a handler that calls one answers 500 (the test suite of ngx_mruby saw it, test/t/cases/gem_uname.rb).
  • What to do: declare the class with MRB_SET_INSTANCE_TT(klass, MRB_TT_DATA). The default build pins matsumotory/mruby-uname to a commit that does this (see “Build and test changes”); a build_config.rb of your own that takes mruby-uname needs that commit or a later one.

C extensions: mruby checks the argument count of a C method against its spec (#561)

Section titled “C extensions: mruby checks the argument count of a C method against its spec (#561)”
  • Before: mruby 3.3 checked the argument count of a C method against the argument spec it was defined with (MRB_ARGS_REQ(2) and so on) only when the spec was MRB_ARGS_NONE(). For other specs, only mrb_get_args checked the arguments, against what it reads.
  • Now: mruby 4.0 checks it for every C method before the call: a call with fewer arguments than the spec requires, or, unless the spec has a rest (MRB_ARGS_REST(), MRB_ARGS_ANY()), more than it allows, raises ArgumentError, whatever mrb_get_args would accept. A non-empty keyword hash counts as one argument when the spec takes no keywords. A method defined with MRB_ARGS_REQ(1) that reads "o|o" raises ArgumentError: wrong number of arguments (given 2, expected 1) when called with two arguments, and one defined with MRB_ARGS_REQ(2) that reads "S" raises (given 1, expected 2) when called with one; with mruby 3.3 both calls worked.
  • Affected: C methods of mrbgems and C extensions whose spec differs from what their mrb_get_args reads, in either direction. The C methods of ngx_mruby itself are not affected: for each of the 110 definitions in src/, the spec accepts every argument count that its mrb_get_args accepts.
  • What to do: define the method with the spec that its mrb_get_args reads (for "o|o", MRB_ARGS_ARG(1, 1)).

C extensions: renamed headers and functions, and mrb_open() on failure (#561)

Section titled “C extensions: renamed headers and functions, and mrb_open() on failure (#561)”
  • Before: mruby/ext/io.h, mrb_alloca(), mrb_open_allocf(f, ud) and mrb_open_core(f, ud), which take an allocator of the type mrb_allocf (by default mrb_default_allocf(), which a program could redefine), and mrb_open() returns NULL when a gem initializer fails.
  • Now: mruby/io.h (there is no mruby/ext/io.h), mrb_temp_alloc() (mruby.h keeps mrb_alloca() as a macro for it, “for compatibility”), and no mrb_open_allocf(), mrb_allocf or mrb_default_allocf(): mrb_open_core() takes no arguments, and mruby allocates its memory with mrb_basic_alloc_func(void *ptr, size_t size), which a program can define to replace mruby’s allocator (doc/guides/memory.md of mruby). mrb_open() returns the state with mrb->exc set, instead of NULL, when a gem initializer fails.
  • Affected: C sources of mrbgems and of programs that embed mruby that include mruby/ext/io.h, call mrb_open_allocf() or call mrb_open_core() with arguments (their build stops), that define their own mrb_default_allocf() (mruby no longer calls it), or that test the result of mrb_open() only for NULL. Calls of mrb_alloca() still compile.
  • What to do: include mruby/io.h, call mrb_temp_alloc(), call mrb_open() instead of mrb_open_allocf(f, ud) and mrb_open_core() without arguments, define mrb_basic_alloc_func() instead of mrb_default_allocf() where a program replaces the allocator, and test the result of mrb_open() with MRB_OPEN_FAILURE() (mruby.h), which is true for NULL and for a state with exc set.

C extensions: sources that include mruby.h need the generated headers (#561)

Section titled “C extensions: sources that include mruby.h need the generated headers (#561)”
  • Before: mruby.h did not include mruby/presym.h, so a source that did not use MRB_SYM() compiled with mruby/include alone; presym could also be turned off (MRB_NO_PRESYM). ngx_mruby 2.x compiled its own sources this way: its config.in puts only mruby/src and mruby/include on the include path.
  • Now: mruby.h includes mruby/presym.h, which includes the generated mruby/presym/id.h (mruby/mruby#6733), and MRB_NO_PRESYM is gone, so every source that includes mruby.h needs build/host/include. Compiled with mruby/include alone, such a source stops with fatal error: mruby/presym/id.h: No such file or directory.
  • Affected: C sources compiled outside the mruby build that include mruby.h, among them the sources of ngx_mruby in a build whose ./configure --with-mruby-incdir gives a list of directories without that directory.
  • What to do: add the include directory of the mruby build (mruby/build/host/include) to the include path. The build of ngx_mruby does this for its own sources: the default list of --with-mruby-incdir is <mruby_root>/src <mruby_root>/include <mruby_root>/build/host/include (#559). A list that you give with --with-mruby-incdir needs the directory too, because the sources of ngx_mruby include mruby.h and mruby/presym.h (#572, 3-B. Using Makefile).

The default build leaves out the auto-ssl mrbgem and the classes that came with it (#556)

Section titled “The default build leaves out the auto-ssl mrbgem and the classes that came with it (#556)”
  • Before: the default build_config.rb of 2.x builds the bundled auto-ssl mrbgem (mrbgems/auto-ssl, the Nginx::SSL::ACME classes) and the gems that it depends on: pyama86/mruby-acme-client, pyama86/mruby-polarssl, matsumotory/mruby-httprequest, matsumotory/mruby-simplehttp, mattn/mruby-http, mattn/mruby-base64, takahashim/mruby-forwardable and iij/mruby-tempfile. Scripts can use what these gems define: Nginx::SSL::ACME::Client and Nginx::SSL::ACME::Dehydrated; the classes and modules Acme, CustomHttpRequest, OpenSSL, PolarSSL, HttpRequest, SimpleHttp, HTTP, Base64, Forwardable, FORWARDABLE, Tempfile and TempfilePath; and Dir.tmpdir and Dir.mktmpdir.
  • Now: the default build has none of them. The constants are not defined, Dir.tmpdir and Dir.mktmpdir raise NoMethodError, and a handler that uses one of them answers 500 (mrb_run failed: ... error: #<NameError: uninitialized constant Base64>). The Dir class itself stays. This release has no auto-ssl mrbgem at all (see the next entry).
  • Why it changed:
    • The reason: decision 6 of the v3 plan (docs/proposals/v3-plan.md, section 7) removes auto-ssl from the default build of v3, to be replaced by nginx-acme and by examples that look certificates up in a store. Its ACME client, Nginx::SSL::ACME::Client, speaks ACMEv1, which Let’s Encrypt no longer serves (sections 2.2 and 3.4 of the plan).
    • Why the old behavior could not be kept: the gem cannot get a certificate from Let’s Encrypt, and it brought into every default build eight third-party gems that no other gem of the default build needs, pyama86/mruby-polarssl under the GPL among them. With mruby 4 the default build would also stop, because pyama86/mruby-polarssl includes mruby/ext/io.h (see the next entry).
    • What the documentation promised: docs/class_and_method/README.md of 2.x calls auto-ssl an optional bundled mrbgem in an early phase of development, without saying whether the default build has it. Its example of mruby_set_code under Nginx::Var Class calls Base64.encode, which the default build had only through auto-ssl.
  • Affected: scripts that use one of the constants above, Dir.tmpdir or Dir.mktmpdir inside nginx.
  • What to do: use [s].pack('m0') in place of Base64.encode(s) and s.unpack1('m') in place of Base64.decode(s), both from the core gem mruby-pack, ENV['TMPDIR'] || '/tmp' in place of Dir.tmpdir, and Dir.mkdir(path, 0700) under a name of your own in place of Dir.mktmpdir, as The auto-ssl mrbgem and the classes that came with it shows. For the other constants, add the gem that defines them with a conf.gem line in a build_config.rb of your own; the gems that depend on pyama86/mruby-polarssl do not build with mruby 4. A server that needs Nginx::SSL::ACME keeps a 2.x build (see the next entry).

The auto-ssl mrbgem and NGX_MRUBY_AUTO_SSL are removed (#640)

Section titled “The auto-ssl mrbgem and NGX_MRUBY_AUTO_SSL are removed (#640)”
  • Before: ngx_mruby 2.x bundles the auto-ssl mrbgem (mrbgems/auto-ssl) and takes it in the default build. It defines Nginx::SSL::ACME::Client, a client of the ACME protocol, and Nginx::SSL::ACME::Dehydrated, helpers for the dehydrated ACME client; test/conf/auto-ssl/ has example configurations for both.
  • Now: this release has no mrbgems/auto-ssl and no test/conf/auto-ssl/, and build_config.rb no longer reads NGX_MRUBY_AUTO_SSL, so no build of this release has Nginx::SSL::ACME. A build with NGX_MRUBY_AUTO_SSL=1 in its environment builds the default gems as without it. A script that uses Nginx::SSL::ACME raises NameError, and its handler answers 500 with a mrb_run failed line in error.log.
  • Why it changed:
    • The reason: decision 6 of the v3 plan (docs/proposals/v3-plan.md, section 7) replaces auto-ssl with nginx-acme and with examples that look certificates up in a store, and the gem cannot work with the bundled mruby. It needs pyama86/mruby-polarssl for TLS, a gem that ngx_mruby does not maintain and that has had no commit since 2017-03-03. That gem includes mruby/ext/io.h, which mruby 4.0 renamed to mruby/io.h, so the mruby build with auto-ssl stops with fatal error: mruby/ext/io.h: No such file or directory (#561). Its ACME client, pyama86/mruby-acme-client, speaks ACMEv1, which Let’s Encrypt turned off in 2021-06 (sections 2.2 and 3.4 of the plan).
    • Why the old behavior could not be kept: the gem cannot be built with mruby 4 until pyama86/mruby-polarssl changes, and even built it could not get a certificate from Let’s Encrypt. Keeping it on next would have kept a gem that no build of v3 can use, with an opt-in variable that ends in a stopped build. ngx_mruby 2.x keeps the gem.
    • What the documentation promised: docs/class_and_method/README.md of 2.x calls auto-ssl an optional bundled mrbgem in an early phase of development and points to the scripts in mrbgems/auto-ssl/mrblib for its API. It says nothing about how long the gem is kept.
  • Affected: scripts that use Nginx::SSL::ACME::Client or Nginx::SSL::ACME::Dehydrated, configurations built from the examples in test/conf/auto-ssl/, and builds that set NGX_MRUBY_AUTO_SSL=1.
  • What to do: get certificates from an ACME server with nginx’s own module ngx_http_acme_module (nginx-acme), or keep a 2.x build for a server that needs Nginx::SSL::ACME; the documentation of 2.x describes the gem. Remove NGX_MRUBY_AUTO_SSL from the environment of your builds: it has no effect.

Nginx::Upstream#server= and Nginx::Stream::Connection#upstream_server= raise ArgumentError for a string that cannot be a server (#680)

Section titled “Nginx::Upstream#server= and Nginx::Stream::Connection#upstream_server= raise ArgumentError for a string that cannot be a server (#680)”
  • Before: for an empty string or one of 256 bytes or more, and for a string with a NUL byte (since 2.7.3, entry 9 of the 2.7.3 release notes), Nginx::Upstream#server= raised ArgumentError and Nginx::Stream::Connection#upstream_server= raised RuntimeError. For a string that nginx could not read as an address, such as 192.0.2.1:notaport, both raised RuntimeError, and so did upstream_server= for a host name.
  • Now: both raise ArgumentError for all of these. The messages stay (invalid upstream server (empty or too long), invalid upstream server (contains a NUL byte), invalid port in upstream 192.0.2.1:notaport), except for a host name, whose message is upstream server NAME is not an IP address or a unix: path. The server stays as it was, as before. RuntimeError is left for a failure of nginx while it reads the string, and for an upstream with a zone.
  • Why it changed:
    • The reason: the same argument raised different classes in the two setters, and a script could not tell an argument that it can correct from a failure of nginx. The owner decided on this change for v3 (question 3 of the proposal).
    • Why the old behavior could not be kept: keeping it would leave two rules for one kind of mistake. The 2.x line, which puts compatibility first, keeps them; v3 is the release that can change them.
    • What the documentation promised: #648, for 2.7.3, wrote the old classes into docs/class_and_method/README.md. The documentation of 2.7.2 said nothing about the exceptions (Nginx::Upstream#server=, Nginx::Stream::Connection#upstream_server=).
  • Affected: scripts that rescue RuntimeError around Nginx::Stream::Connection#upstream_server=, or around Nginx::Upstream#server= for a string that nginx cannot read. Such a rescue no longer catches the exception, and the handler ends with it: a handler of a request phase answers 500, and mruby_set leaves its variable empty. A script that rescues ArgumentError around Nginx::Upstream#server= now also catches these cases.
  • What to do: rescue ArgumentError. A script for both versions rescues ArgumentError and RuntimeError, or StandardError.
  • Not changed by this release: TypeError for an argument that is not a String, and RuntimeError for an upstream with a zone, which is about the upstream and not about the argument.

Nginx::Upstream#server= raises ArgumentError for a host name instead of resolving it (#680)

Section titled “Nginx::Upstream#server= raises ArgumentError for a host name instead of resolving it (#680)”
  • Before: Nginx::Upstream#server= resolved a host name with the system resolver when it was called and used the first address. The worker served no other client while it waited for the answer. A name that did not resolve raised RuntimeError (host not found in upstream NAME).
  • Now: the method resolves nothing. A string that is not an IP address or a unix: path raises ArgumentError (upstream server NAME is not an IP address or a unix: path), and the server stays as it was. The worker does not wait. Nginx::Stream::Connection#upstream_server= already refused a host name.
  • Why it changed:
    • The reason: the design principle “No blocking” of AGENTS.md, which listed this setter among the places that block until this change. The owner decided on this change for v3 (question 3 of the proposal).
    • Why the old behavior could not be kept: while the resolver answers, every other request of the worker waits, and a slow resolver stops the worker for as long as it takes. Resolving without waiting would need a resolver for scripts, which ngx_mruby does not have.
    • What the documentation promised: #648, for 2.7.3, wrote the old behavior into docs/class_and_method/README.md, said that the worker waits and said to give an IP address. The documentation of 2.7.2 said nothing about a host name.
  • Affected: scripts that give Nginx::Upstream#server= a host name, localhost included, and scripts that give it an IPv4 address in a form that only the system resolver read, such as 127.1, 2130706433 or 0x7f.0.0.1, or 255.255.255.255; for those strings the worker did not wait. Unless the script rescues the exception, a handler of a request phase answers 500, and mruby_set leaves its variable empty.
  • What to do: give an IP address that the script has without waiting, for example from its configuration, and write an IPv4 address as four decimal numbers. For a name that does not change while nginx runs, write the name in the server line of the upstream {} block, which nginx resolves when it reads the configuration, and do not call the setter. nginx uses all the addresses of such a name: when it has more than one, Nginx::Upstream.new raises RuntimeError for that upstream, so remove that call too, or write an IP address in the server line. A name that does not resolve stops nginx at start.
  • Not changed by this release: the 2.x line still resolves a host name. A host name in a server line of an upstream {} block, which nginx resolves, is not affected.

An access or post_read handler that waits in Nginx::Async.sleep ends as without the wait (#715)

Section titled “An access or post_read handler that waits in Nginx::Async.sleep ends as without the wait (#715)”
  • Before: when the timer of Nginx::Async.sleep fired, ngx_mruby resumed the code and ended the handler itself, with the rules of the content phase instead of those of the handler’s phase. An access handler (under satisfy all or satisfy any) or a post_read handler that ended after the sleep without a result (no Nginx.return, Nginx.send_header or Nginx.status_code=) or with Nginx::OK let the request reach its content, and nginx then closed the connection instead of answering the next request on it. Under satisfy any, a 401 or 403 after the sleep ended the request with that status, where nginx tries the next access handler without the sleep. On a server whose earlier handler had stored Nginx::DECLINED (see the entry “A handler that sets no result does not take the result of an earlier handler”), these ends were hidden.
  • Now: nginx calls the handler again when the sleep ends, the handler goes on with the code after the sleep, and the checker of the handler’s phase handles its result as for a handler that did not wait: without a result, an access handler goes on with the next access handler under satisfy all and allows the request under satisfy any, and a post_read handler goes on with the next phase; the next request on a kept-alive connection is answered. Under satisfy any, a 401 or 403 after the sleep lets nginx try the next access handler, such as allow or auth_request. While the handler waits, nginx does not run its code again.
  • Why it changed:
    • The defect: gap 2 of docs/proposals/archive/core-stabilization.md (section 2.3): the same code ended in another way after Nginx::Async.sleep than without it, because the timer replaced nginx’s phase checker with a copy of the content phase’s. The owner decided the design on 2026-11-01 (section 8, step 3).
    • Why the old behavior could not be kept: a script cannot rely on an end that depends on whether it waited, and closing the connection after the response drops the next request of a kept-alive client.
    • What the documentation promised: Nginx::Async#sleep of 2.7.3 said that the sleep is supported in access handlers and that the code after it runs, and said nothing about how the handler ends.
  • Affected: mruby_access_handler, mruby_access_handler_code, mruby_post_read_handler and mruby_post_read_handler_code handlers that call Nginx::Async.sleep, in particular under satisfy any, where an access handler that sleeps and then ends without a result now allows the request.
  • What to do: an access handler that sleeps and should deny the request returns Nginx::HTTP_FORBIDDEN (or Nginx::HTTP_UNAUTHORIZED) after the sleep. Under satisfy any, nginx then tries the other access handlers, as without the sleep.
  • Tests: ports 18176 and 18178 (test/conf/conf.d/82-async-resume-result.conf, test/t/cases/async_resume_result.rb: every end of access handlers under satisfy all, satisfy any, satisfy any before allow all, and before auth_request, and of post_read handlers, without a wait and after a sleep).

An access or post_read handler that writes output ends the request after the response (#715)

Section titled “An access or post_read handler that writes output ends the request after the response (#715)”
  • Before: an access or post_read handler that wrote output with Nginx.rputs or Nginx.echo and set no other status sent the response, and nginx then went on with the phases of the request: the content phase tried to answer again, nginx logged header already sent, and it closed the connection before it answered the next request on it. After Nginx::Async.sleep, the same handler ended the request after the response.
  • Now: with or without a wait, the request ends after the response, as after the output of a rewrite or content handler, and nginx answers the next request on a kept-alive connection.
  • Why it changed:
    • The defect: the handler returned NGX_OK to nginx after the response, which the access and post_read phases read as “go on”. This is the end of a run with output that step 3 of section 8 of docs/proposals/archive/core-stabilization.md makes the same with and without a wait.
    • Why the old behavior could not be kept: the response of the handler was already sent, and the later phases could only fail on it and close the connection.
    • What the documentation promised: Nginx.rputs of 2.7.3 said “Puts response text” for every handler, and said nothing about the phases after it.
  • Affected: mruby_access_handler* and mruby_post_read_handler* handlers that write output, and log monitoring of the header already sent lines that they caused.
  • What to do: nothing; a handler that wrote output to answer the request now answers it once.
  • Tests: ports 18176, 18178 and 18179 (test/t/cases/async_resume_result.rb and test/t/cases/async_result_isolation.rb, the cases “that ends with output”).

A handler that sets no result does not take the result of an earlier handler (#715)

Section titled “A handler that sets no result does not take the result of an earlier handler (#715)”
  • Before: Nginx.return, Nginx.send_header and Nginx.status_code= stored their value in the status of the response, also a return code below 0 such as Nginx::DECLINED, and a later handler of the same request that set no result returned that value. On a server whose mruby_server_rewrite_handler returned Nginx::DECLINED for every request, a content handler that ended without output and without a status went on to the next content handler or to the static module, which answered 404 when no file matched; under satisfy any, an access handler without a result was taken to have declined, and deny refused the request with 403. After a handler that its timer resumed (Nginx::Async.sleep) or that the end of its subrequest resumed, ngx_mruby itself stored 500 for every result but Nginx::OK, Nginx::DECLINED included, so that a later content handler without output and without a status answered 500.
  • Now: the result of a handler is its own. A handler that sets none has no result, whatever an earlier handler of the request set: a content handler of the main request without output answers 200 with an empty body (see “A content handler that ends without output answers 200 with an empty body instead of 500”), and an access or post_read handler goes on as with Nginx::OK. A rewrite or server rewrite handler without a result goes on to the next phase handler (see “A rewrite or server rewrite handler that ends without a result goes on to the next phase handler”).
  • Why it changed:
    • The defect: gap 3 of docs/proposals/archive/core-stabilization.md (section 2.1): what a handler did depended on handlers that it does not contain, and the same script behaved in another way on two servers. The owner decided on 2026-11-01 that the result of a handler is its own (Q6 of section 9).
    • Why the old behavior could not be kept: a script cannot see what an earlier handler of the request returned, so it cannot know how it ends without a result.
    • What the documentation promised: Nginx.return of 2.7.3 said that it returns a status to the client or controls nginx’s request processing, and did not say that the value carries over to later handlers.
  • Affected: configurations with an mruby_server_rewrite_handler*, mruby_rewrite_handler*, mruby_post_read_handler* or mruby_access_handler* that returns Nginx::DECLINED or another value for every request, together with a content handler that can end without output and without a status, or an access handler under satisfy any that can end without a result.
  • What to do: a content handler that should go on to the next content handler returns Nginx::DECLINED itself; an access handler under satisfy any that should leave the decision to the other access handlers returns Nginx::DECLINED itself.
  • Tests: port 18179 (test/conf/conf.d/82-async-result-isolation.conf, test/t/cases/async_result_isolation.rb: a server rewrite handler returns Nginx::DECLINED, and the later access and content handlers end by their own result).

An mruby_set handler that waits in Nginx::Async.sleep sets its variable, and the request goes on (#715)

Section titled “An mruby_set handler that waits in Nginx::Async.sleep sets its variable, and the request goes on (#715)”
  • Before: when the sleep ended, ngx_mruby set the variable and then ended the request without a response, unless an earlier handler of the request had stored Nginx::DECLINED (as the server rewrite handler of a server that returns it for every request). A status that the code set with Nginx.return after the sleep ended the request with that status; without the sleep, such a status does not end it.
  • Now: when the code returns, the variable is set and the request goes on with the next handler of the phase, as without the sleep, so the later phases read the value (a content handler, proxy_pass). A status that the code sets does not end the request. An exception after the sleep answers 500, as before.
  • Why it changed:
    • The defect: gap 2 of docs/proposals/archive/core-stabilization.md (section 2.3): the end of an mruby_set handler after the sleep depended on a status stored by another handler (section 4.4 of the proposal, step 3 of section 8, decided by the owner on 2026-11-01).
    • Why the old behavior could not be kept: a request that ends without a response leaves the client waiting until a timeout, and the end of the handler cannot depend on handlers that it does not contain.
    • What the documentation promised: Nginx::Async#sleep of 2.7.3 said that the sleep is supported in set handlers, and said nothing about how the request goes on.
  • Affected: mruby_set and mruby_set_code whose code calls Nginx::Async.sleep.
  • What to do: nothing for most configurations. Code that ended the request with a status after the sleep returns that status from a later handler instead, for example a rewrite handler that reads the variable. The directives of the same rewrite script after the mruby_set still run before the sleep ends, without the value.
  • Tests: port 18182 (test/conf/conf.d/83-async-set-var.conf, test/t/cases/async_set_var.rb).

A rewrite or server rewrite handler that ends without a result goes on to the next phase handler (#720)

Section titled “A rewrite or server rewrite handler that ends without a result goes on to the next phase handler (#720)”
  • Before: an mruby_rewrite_handler* or mruby_server_rewrite_handler* handler that ended without output and without Nginx.return, Nginx.send_header or Nginx.status_code=, or with Nginx.return Nginx::OK, returned NGX_OK to the rewrite phase, and nginx finalized the request without a response: with Connection: close it closed the connection without a byte, and a kept-alive connection stayed open until keepalive_timeout; error.log had no line at the error level. On a server whose earlier handler had returned Nginx::DECLINED for every request, such a handler took that value and went on. Nginx.return with a return code below 0, such as Nginx::DECLINED, also stored the code in the status of the response.
  • Now: such a handler goes on to the next phase handler, as with Nginx::DECLINED, with or without a wait in Nginx::Async.sleep or Nginx::Async::HTTP.sub_request, whatever an earlier handler of the request set. A return code below 0 is the result of the handler only, and the status of the response does not change. A handler with output, with a status from 100 up or with an exception ends as before.
  • Why it changed:
    • The defect: gap 1 of docs/proposals/archive/core-stabilization.md (section 2.3): an end without a response helps no script. The owner decided on 2026-10-04 that a rewrite handler that ends with no output and no Nginx.return goes on, as with NGX_DECLINED, on next (decision (b), recorded in docs/HANDOFF.md), and extended it to server rewrite handlers on 2026-11-01 (Q6 of section 9 of the proposal).
    • Why the old behavior could not be kept: the client got no response at all, and nothing in error.log said why.
    • What the documentation promised: the documentation of 2.7.3 did not say what a rewrite handler without Nginx.return does.
  • Affected: mruby_rewrite_handler* and mruby_server_rewrite_handler* handlers that can end without a result or with Nginx::OK, for example a handler that only sets variables or headers; they now let the request go on to the content of the location. The test of 2.x behavior “rewrite handler without output or DECLINED sends no response” in test/t/cases/request_api.rb expects the content handler’s 200 now.
  • What to do: nothing for a handler that should let the request go on; a handler that should end the request returns the status it means, for example Nginx.return Nginx::HTTP_FORBIDDEN.
  • Tests: ports 18176, 18177 and 18179 (test/t/cases/async_resume_result.rb and test/t/cases/async_result_isolation.rb: rewrite and server rewrite handlers without a result and with Nginx::OK, without a wait, after a sleep and after a subrequest), and port 18111 (test/t/cases/request_api.rb).

Nginx::Async::HTTP.sub_request works in a content handler, also after Nginx::Async.sleep (#722)

Section titled “Nginx::Async::HTTP.sub_request works in a content handler, also after Nginx::Async.sleep (#722)”
  • Before: since 2.7.3, Nginx::Async::HTTP.sub_request in a content handler (mruby_content_handler*) that had waited in Nginx::Async.sleep raised a RuntimeError (Nginx::Async::HTTP.sub_request is not available after Nginx::Async.sleep in a content handler), and the request got 500. Without a sleep before, a content handler could call it, although the documentation named only the set, rewrite and access handlers.
  • Now: a content handler waits for the subrequest, before or after a sleep, and answers with the output or the status that its code sets after the call; nginx answers the next request on a kept-alive connection.
  • Why it changed:
    • The defect: gap 4 of docs/proposals/archive/core-stabilization.md (section 2.3). 2.7.3 raised there because nothing would finalize the request after the subrequest. Since the end of a subrequest wakes the request through nginx, which calls the handler again (gap 5, step 5 of section 8), the checker of the content phase finalizes it. The owner decided on 2026-11-01 that 3.0.0 supports it (Q1 of section 9).
    • Why the old behavior could not be kept: a content handler that answers from a subrequest is the base of the plan’s row on calls from a handler to other services, and the raise is not needed any more.
    • What the documentation promised: Nginx::Async::HTTP#sub_request of 2.7.3 said that it raises in a content handler after a sleep, and entry 2 of the 2.7.3 release notes said the same.
  • Affected: content handlers that call Nginx::Async::HTTP.sub_request after Nginx::Async.sleep, and code that rescued its RuntimeError.
  • What to do: remove such a rescue; the call returns the response of the subrequest.
  • Tests: ports 18133 (test/t/cases/async_sleep_in_content.rb, the case “Nginx::Async::HTTP.sub_request after a sleep in a content handler waits for the subrequest, and the handler answers”) and 18183 (test/conf/conf.d/84-async-subrequest-return.conf, test/t/cases/async_subrequest_return.rb).

A handler that waits for Nginx::Async::HTTP.sub_request runs its code once and ends as without the wait (#722)

Section titled “A handler that waits for Nginx::Async::HTTP.sub_request runs its code once and ends as without the wait (#722)”
  • Before: when the subrequest ended, ngx_mruby resumed the code inside the end of the subrequest and ended the handler there, with the rules of the content phase instead of those of the handler’s phase. While it waited, the handler returned NGX_AGAIN; for an access or post_read handler, nginx then ran the phases of the request again when it went on after the subrequest, which ran the handler’s code again from its start, with another subrequest.
  • Now: the handler returns NGX_DONE while it waits, and nginx ignores the events of the request until the subrequest ends. Then nginx wakes the request and calls the handler again, which goes on with the code after the call, and the checker of the handler’s phase handles its result as for a handler that did not wait. The code of the handler runs once for the request, and its subrequest is sent once.
  • Why it changed:
    • The defect: gap 5 of docs/proposals/archive/core-stabilization.md (section 2.3): the end of the subrequest and the end of the parent’s handler ran as one call, outside nginx’s phase checker. Step 5 of section 8, decided by the owner on 2026-11-01, moves the resume into the parent’s own run of the phases.
    • Why the old behavior could not be kept: a handler whose code runs again repeats what the code does, its subrequest included, and its end depended on the handler kind of another phase.
    • What the documentation promised: Nginx::Async::HTTP#sub_request of 2.7.3 said “Sends a sub request in non-blocking way” and that it is supported in access handlers, and nothing about how the handler ends.
  • Affected: mruby_access_handler* and mruby_post_read_handler* handlers that call Nginx::Async::HTTP.sub_request, and the other handlers that call it, whose results nginx now handles in their own phase.
  • What to do: nothing for most scripts. A script that counted on its code running again after the subrequest does the work after the call instead, where the response of the subrequest is available.
  • Tests: ports 18176 to 18179 (test/t/cases/async_resume_result.rb and test/t/cases/async_result_isolation.rb: every end of access, post_read and content handlers after a subrequest), and ports 18183 and 18184 (test/t/cases/async_subrequest_return.rb: an access or post_read handler that waits for a subrequest and sets no result, or returns Nginx::DECLINED, runs once, sends one subrequest, and the request goes on).

A UDP stream session runs its code once: datagrams that arrive while the code waits do not start it again (#727)

Section titled “A UDP stream session runs its code once: datagrams that arrive while the code waits do not start it again (#727)”
  • Before: nginx called the stream handler for each datagram from the client of a UDP session (listen ... udp), and while the code of the session waited in Nginx::Stream::Async.sleep, each datagram started the code again from its start, in another fiber of the same session. The sleep of the newer run replaced the pending one, so only the last run went on after its sleep.
  • Now: a session runs its code once. A datagram that arrives while the code waits does not start it again; nginx gives the datagram to the handler only during that call, so the code does not see it. The first datagram remains available to the next phase; payloads received during each wait are discarded and are not queued or replayed. Once the session reaches proxy_pass, subsequent datagrams are handled normally. The session goes on, or ends, by the result of the code after the sleep, as for a session whose code does not wait.
  • Why it changed:
    • The defect: gap 9 of docs/proposals/archive/core-stabilization.md (section 2.5): the code of a session ran several times at once, in fibers of one session. The owner decided on 2026-11-01 that a UDP session runs its code once (Q4 of section 9).
    • Why the old behavior could not be kept: the runs shared the session and its result, and only the last one decided how the session went on.
    • What the documentation promised: Nginx::Stream::Async#sleep of 2.7.3 said that the session goes on after the sleep by the result of the code, and nothing about datagrams during the sleep.
  • Affected: mruby_stream and mruby_stream_code of a listen ... udp server whose code calls Nginx::Stream::Async.sleep and whose clients send more than one datagram during the sleep.
  • What to do: nothing for most configurations. Code that counted on running once for each datagram does not sleep, or handles one datagram per session.
  • Tests: port 12392 (test/conf/conf.d/stream/47-async-sleep-udp-once.conf, test/t/cases/stream_async_sleep_udp_once.rb) checks one, ten and then one datagram in separate sessions, with one start, one resume and the exact reply in each. test/t/cases/stream_async_sleep_udp_session.rb checks consecutive waits, exact proxy payloads and shutdown on ports 12393-12396.

A stream session that waits when worker_shutdown_timeout expires ends then (#727)

Section titled “A stream session that waits when worker_shutdown_timeout expires ends then (#727)”
  • Before: when worker_shutdown_timeout expired in a worker that shut down (after a reload or SIGQUIT), nginx marked the connections to be closed and called their read handlers, but a stream session whose code waited in Nginx::Stream::Async.sleep went on: the code ran again from its start in another fiber, and the worker ran until the code ended.
  • Now: such a session ends when the timeout expires. The code after the sleep does not run, error.log gets the line shutdown timeout at the info level, and the worker exits, as it does for a session of proxy_pass.
  • Why it changed:
    • The defect: gap 10 of docs/proposals/archive/core-stabilization.md (section 2.5): the handler did not look at the close that nginx asks for, so worker_shutdown_timeout did not bound the life of an old worker with such a session. Step 6 of section 8, decided by the owner on 2026-11-01.
    • Why the old behavior could not be kept: worker_shutdown_timeout is the setting that bounds how long an old worker runs after a reload.
    • What the documentation promised: the documentation of 2.7.3 said nothing about worker_shutdown_timeout and stream code that sleeps.
  • Affected: stream servers whose code calls Nginx::Stream::Async.sleep, in configurations with worker_shutdown_timeout.
  • What to do: nothing; code that must finish keeps its sleeps shorter than worker_shutdown_timeout. Without worker_shutdown_timeout, an old worker still finishes the sleeps in flight.
  • Tests: test/t/cases/workers.rb, mode shutdown (test/conf/workers/shutdown.conf, ports 18185 and 12393).

Nginx::Stream::Connection.proxy_protocol_addr and proxy_protocol_ip return nil for a connection without a PROXY source address

Section titled “Nginx::Stream::Connection.proxy_protocol_addr and proxy_protocol_ip return nil for a connection without a PROXY source address”
  • Before: with nginx 1.17.6 and later, Nginx::Stream::Connection.proxy_protocol_addr and Nginx::Stream::Connection.proxy_protocol_ip, as class and as instance methods, did not return a value for a connection that had no source address from a PROXY protocol header: on a listen without proxy_protocol, and after the header PROXY UNKNOWN (version 1) or a version 2 header with the command LOCAL.
  • Now: the methods return nil for such a connection. After a header that carries addresses, they return its source address as before. 2.7.4 makes the same change.
  • Why it changed:
    • The defect: the methods returned no value for such a connection, as “Before” describes. The advisory GHSA-xjh6-6vgm-56wj describes the defect, the affected versions and the conditions.
    • Why the old behavior could not be kept: such a connection has no address to return, and nil tells it apart from a connection with one. In HTTP code, Nginx::Var#proxy_protocol_addr returns nil in the same case.
    • What the documentation promised: the methods were not documented. docs/class_and_method/README.md describes them now.
  • Affected: mruby_stream and mruby_stream_code code that calls these methods on a connection without a PROXY source address.
  • What to do: nothing for code that compares the result with a String. Code that calls a String method on the result handles nil, for example with to_s.
  • Tests: ports 12385 and 12386 of the mode stream_master of test/t/cases/_second_instance.rb, a second nginx with a master process and one worker.

On a listen with proxy_protocol, a stream session whose code sleeps reads nothing from the client, and worker_shutdown_timeout ends it

Section titled “On a listen with proxy_protocol, a stream session whose code sleeps reads nothing from the client, and worker_shutdown_timeout ends it”
  • Before: while the code of a session on a listen with proxy_protocol waited in Nginx::Stream::Async.sleep, the read events of the connection were handled as before the code ran: bytes that the client sent during the sleep could end the session (status 400 in the access log), and when worker_shutdown_timeout expired during the sleep, the session did not end then.
  • Now: while the code sleeps, nginx reads nothing from the client on such a listen, as on the other listens. The bytes that the client sends then stay for the phase after the code: proxy_pass sends them to the upstream. A client that closes the connection during the sleep is seen by the phase after the code, as on the other listens. When worker_shutdown_timeout expires during the sleep, the session ends, as the entry “A stream session that waits when worker_shutdown_timeout expires ends then” describes. 2.7.4 makes the same change for TCP sessions.
  • Why it changed:
    • The defect: the read events during the sleep were handled as before the code ran, as “Before” describes. The advisory GHSA-xjh6-6vgm-56wj describes the defect, the affected versions and the conditions.
    • Why the old behavior could not be kept: the bytes after the header belong to the protocol that the later phases carry. A session that does not end at worker_shutdown_timeout keeps the old worker process after the time that the directive sets.
    • What the documentation promised: docs/class_and_method/README.md said nothing about reads during the sleep. nginx’s documentation of worker_shutdown_timeout says that nginx tries to close the open connections when the timeout expires.
  • Affected: stream servers on a listen with proxy_protocol whose mruby_stream or mruby_stream_code code calls Nginx::Stream::Async.sleep: the clients that send bytes or close the connection during the sleep, and a worker that shuts down (a reload, an upgrade, a stop) with worker_shutdown_timeout while the code sleeps.
  • What to do: nothing. The phase after the code gets the bytes of the client, as on a session whose code does not sleep.
  • Tests: port 12384 (test/conf/conf.d/stream/48-proxy-protocol-wait.conf, test/t/cases/stream_proxy_protocol_wait.rb: the reply after bytes during the sleep), and ports 12387 and 12388 of the mode stream_master of test/t/cases/_second_instance.rb (sessions with and without proxy_protocol when worker_shutdown_timeout expires).

Nginx.redirect with a local URI takes effect when the handler ends (#728)

Section titled “Nginx.redirect with a local URI takes effect when the handler ends (#728)”
  • Before: Nginx.redirect with a local URI made the internal redirect inside the call: nginx ran the phases of the target location there, and its mruby handlers ran inside the fiber of the calling handler. The calling handler went on after the call and returned its own result, so two handlers could answer one request: output or a status that the calling handler set after the call answered first and the target’s output followed it, a content handler of the target ended the request at Nginx::Async.sleep without its output, and after a sleep and Nginx.redirect in a content handler the client got the target’s 200 while the access log had 500. An exception of the calling handler after the call left the target’s answer.
  • Now: in a post_read, server rewrite, rewrite, access or content handler, the call records the URI, the code goes on to its end, and then nginx runs the phases of the target, whose handlers run outside the caller’s fiber and can wait like any handler. One handler answers the request. The output and the status of the calling handler are not sent; when its code writes output or sets a status after the call, error.log gets a line at the warn level that ends with set after Nginx.redirect are not sent. Response headers that the calling handler sets and changes that it makes to the request (its arguments, for example with Nginx::Request#args=) stay, also when they come after the call: the target’s answer carries those headers, and the target sees those arguments. An exception of the calling handler answers 500, and the redirect does not take effect. Nginx.redirect with a URL, and a local redirect from an mruby_set* handler, a log handler or a filter, are unchanged.
  • Why it changed:
    • The defect: gap 6 of docs/proposals/archive/core-stabilization.md (section 2.4): the three cases above. The owner decided on 2026-11-01 that Nginx.redirect takes effect when the handler ends (Q2 of section 9).
    • Why the old behavior could not be kept: two handlers that answer one request send two responses or none, and a target that waits ran inside another handler’s fiber.
    • What the documentation promised: Nginx.redirect of 2.7.3 said that the internal redirect runs the handlers of the other location before the call returns, and that the calling code goes on after the call.
  • Affected: handlers that call Nginx.redirect with a local URI and then write output, set a status, set response headers, change the arguments of the request or raise, handlers that rely on the target having run when the call returns, and log monitoring of the 500 in the access log of a redirected request.
  • What to do: write nothing after Nginx.redirect that is meant for the client; return from the handler after the call when the code after it should not run. Code that read what the target set (a variable, a header) after the call moves to the target.
  • Tests: port 18186 (test/conf/conf.d/85-redirect-async.conf, test/t/cases/redirect_async.rb), and the cases of test/t/cases/async_sleep_in_content.rb and test/t/cases/async_exception_state.rb with Nginx.redirect.

Nginx.rputs, Nginx.echo, Nginx.redirect and Nginx::Filter#body= raise TypeError when to_s of the argument does not return a String (#776)

Section titled “Nginx.rputs, Nginx.echo, Nginx.redirect and Nginx::Filter#body= raise TypeError when to_s of the argument does not return a String (#776)”
  • Before: Nginx.rputs, Nginx.echo, Nginx.redirect, Nginx::Filter#body= and Nginx::Filter#output converted an argument that is not a String with its to_s and used the result as a String without checking its type. Up to 2.7.5, a to_s that returns an Integer ended the worker process with a segmentation fault, with the other requests of that worker, and a to_s that returns another object that is not a String made the method read the memory of that object as a String. A to_s that is missing or raises made these methods raise its exception, as it does now. 2.7.6 (#775) makes the same change as this entry.
  • Now: these methods raise TypeError (... cannot be converted to String) when to_s of the argument returns something other than a String, as the setter of Nginx::Var does (#735). The exception ends the handler like any other exception of the script: a rescue in the script catches it, and otherwise ngx_mruby logs it and the request gets 500. Nothing is written, no redirect is made, and the body of the filter stays as it was.
  • Why it changed:
    • The defect: these methods read the result of to_s as a String without checking its type. #735 fixed the same reading for mruby_set and Nginx::Var, and the tests of the 2.x form of that change (#768) found it in these methods.
    • Why the old behavior could not be kept: the old behavior ended the worker process, with the other requests of that worker, or read memory that was not a String. These methods need a String, and such a value gives none, so they raise the exception that the setter of Nginx::Var raises for the same value.
    • What the documentation promised: Nginx.rputs in 2.7.5 said that an argument that is not a String is converted with to_s, and said nothing about a to_s that does not return a String. The documentation of Nginx.echo, Nginx.redirect and Nginx::Filter#body= said nothing about arguments that are not Strings.
  • Affected: calls of Nginx.rputs, Nginx.echo, Nginx.redirect, Nginx::Filter#body= and Nginx::Filter#output with an argument whose to_s does not return a String.
  • What to do: pass a String, nil or a value whose to_s returns a String to these methods.
  • Tests: port 18191 (test/conf/conf.d/88-output-value-to-s.conf, test/t/cases/output_value_to_s.rb), the same cases as on 2.x (#775).

Nginx::Async::HTTP.sub_request raises a RuntimeError in an mruby_set handler (#735)

Section titled “Nginx::Async::HTTP.sub_request raises a RuntimeError in an mruby_set handler (#735)”
  • Before: in an mruby_set or mruby_set_code handler, Nginx::Async::HTTP.sub_request started the subrequest, but nginx did not wait for it. The directives after the mruby_set and the later phases ran before the code had set the variable, and the code after the call ran when the subrequest ended. An exception of that code left the client without a response.
  • Now: the call raises a RuntimeError with the message Nginx::Async::HTTP.sub_request is not available in an mruby_set handler. The handler ends as after any exception there: without a wait, error.log gets the exception, the variable is empty, and the request goes on; after Nginx::Async.sleep, the request gets 500. Nginx::Async.sleep in an mruby_set handler works as before.
  • Why it changed:
    • The defect: gap 7 of docs/proposals/archive/core-stabilization.md (section 2.3): nginx does not wait for a subrequest of an mruby_set handler. The owner decided on 2026-11-01 that the call raises there (Q5 of section 9).
    • Why the old behavior could not be kept: the rewrite module runs an mruby_set handler inside its script and goes on when the handler returns, so the value of a handler that waits for a subrequest arrives after the phases that read it. A raise tells the script at once, as in log handlers since 2.7.1.
    • What the documentation promised: Nginx::Async::HTTP#sub_request of 2.7.3 said that the method is supported in set handlers, and Nginx.rputs of 2.7.3 said that nginx goes on without waiting for the variable and that an exception after the call leaves the client without a response.
  • Affected: mruby_set and mruby_set_code whose code calls Nginx::Async::HTTP.sub_request.
  • What to do: call Nginx::Async::HTTP.sub_request in a rewrite or access handler, which waits for the subrequest, and set the variable there with Nginx::Var#set.
  • Tests: port 18182 (test/conf/conf.d/83-async-set-var.conf, test/t/cases/async_set_var.rb: the cases with sub_request).

An mruby_set value that cannot be converted to a String answers 500 (#735)

Section titled “An mruby_set value that cannot be converted to a String answers 500 (#735)”
  • Before: ngx_mruby converted a value of an mruby_set or mruby_set_code handler that is not a String with its to_s, and used the result without checking that it is a String. Up to 2.7.5, a value whose to_s returned an object that is not a String ended the worker process with a segmentation fault, without a wait and after Nginx::Async.sleep. For a value without to_s, such as a BasicObject, and for a value whose to_s raised, ngx_mruby read the exception object as a String, and the exception stayed in the mrb_state of the worker. With the values that #768 ran, a BasicObject and a value whose to_s raised, the request got 500 without a wait and ended without a response after the sleep; other values without to_s were not run. The next handler that the worker ran, in the same request or a later one, could fail with that exception. The setter Nginx::Var#<name>= with a value, and Nginx::Var#set with a name or a value, whose to_s returned an object that is not a String ended the worker process; for a to_s that is missing or raises, they raised its exception, as they do now. 2.7.6 (#768) checks the result of to_s as well, but treats a value of the handler that cannot be converted as an exception of the code: without a wait the variable is empty and the request goes on with 200, and after the sleep the request gets 500.
  • Now: a value whose to_s raises, is missing, or returns an object that is not a String ends the handler with the exception in error.log, a TypeError for the object that is not a String, and the request gets 500, without a wait and after a sleep. Nginx::Var#set and Nginx::Var#<name>= raise that exception in the script.
  • Why it changed:
    • The defect: the result of to_s was used without the check, and an exception of the conversion was not handled where an mruby_set handler ends after its code.
    • Why the old behavior could not be kept: a value that is not a String cannot become the value of an nginx variable, and the value of a script must not end the worker process. The same value also gave a different result depending on whether the code had waited: 500 or no response up to 2.7.5, and 200 with an empty variable or 500 on 2.7.6.
    • What the documentation promised: mruby_set of 2.7.3 said that the directive sets a variable, and said nothing about a value that is not a String.
  • Affected: mruby_set and mruby_set_code whose code returns a value that is not a String and whose to_s is missing, raises or does not return a String, and Nginx::Var#set and Nginx::Var#<name>= with such a name or value.
  • What to do: return a String from the code, for example with to_s on a value whose to_s returns a String, and give a class of your own a to_s that returns a String.
  • Tests: port 18182 (test/conf/conf.d/83-async-set-var.conf, test/t/cases/async_set_var.rb: the cases to_s_raises, no_to_s, to_s_not_string and var_set_not_string), and port 18189 (test/conf/conf.d/83-var-value-to-s.conf, test/t/cases/var_value_to_s.rb), the cases of the 2.x fix (#768) with the expectations of 3.0.0.

access_log writes the variables that mruby log handlers set, and the status that was sent (#770)

Section titled “access_log writes the variables that mruby log handlers set, and the status that was sent (#770)”
  • Before: ngx_mruby added its log handlers (mruby_log_handler and mruby_log_handler_code) at the end of the log phase, after the log handler of nginx’s log module, so nginx ran them after access_log had written the line of the request. The line had the values of the variables from before the log handlers: a variable that a log handler assigned with Nginx::Var showed the value that the request had before, for example the value of its set. A log handler that raised set the status of the response to 500, and one that called Nginx.return set that status; access_log did not see either, but the log-phase handlers of the modules whose postconfiguration ran after ngx_mruby’s saw the changed status.
  • Now: the mruby log handlers run first in the log phase, before access_log and before the log-phase handlers of the other modules whose postconfiguration runs before ngx_mruby’s. Modules whose postconfiguration runs later still add their log-phase handlers after them. access_log writes the values that the log handlers assigned. After each mruby log handler, the status of the response is put back to the status that was sent, also when the handler raised or set a status, so access_log and the later log-phase handlers write the status that the client got. An exception of a log handler is still written to error.log.
  • Why it changed:
    • The reason: the agent proxy of v3 computes the cost and the tokens of a response in a log handler, and access_log has to write them on the line of the same request (item 15 of section 7 and the Pillar B row “Log handlers before access_log” of docs/proposals/v3-plan.md; section 2.10 of docs/proposals/core-alpha1.md).
    • Why the old behavior could not be kept: with the log handlers after access_log, a value that a log handler computes cannot reach the access log line of its request. Moving them first without putting the status back would make access_log write 500 after an exception of a log handler, for a response that the client got with another status.
    • What the documentation promised: mruby_log_handler of 2.7.5 said that the handlers are called at the end of request processing for logging, and said nothing about their order against access_log.
  • Affected: an access_log whose log_format writes a variable that an mruby log handler assigns, which now writes the assigned value; a log handler that changes a variable after access_log was meant to write it; log-phase handlers of other modules whose postconfiguration runs before ngx_mruby’s, which now run after the mruby log handlers; and log handlers that raise or set a status, whose status no longer reaches the later log-phase handlers.
  • What to do: nothing for most configurations. To log the value of a variable from before the log handler, copy it into another variable with set in the location and write that variable. A log handler that passed a status to a later log-phase handler passes the value in a variable of its own instead.
  • Tests: port 18195 (test/conf/conf.d/87-log-before-access-log.conf, test/t/cases/log_before_access_log.rb).

Nginx.redirect with a local URI raises a RuntimeError in a log handler (#770)

Section titled “Nginx.redirect with a local URI raises a RuntimeError in a log handler (#770)”
  • Before: in a log handler (mruby_log_handler and mruby_log_handler_code), Nginx.redirect with a local URI made the internal redirect inside the call: nginx ran the phases of the target location there, and the code of the log handler went on after the call.
  • Now: the call raises a RuntimeError with the message Nginx.redirect with a local URI is not available in a log handler, and nginx makes no internal redirect. The log handler ends as after any other exception: error.log gets the exception, and the response, which was sent before the log phase, does not change. access_log writes the status that was sent. Nginx.redirect with a URL (http://, https://, $scheme) works in a log handler as before.
  • Why it changed:
    • The reason: decision 1 of docs/proposals/core-alpha1.md (2026-11-09): Nginx.redirect with a local URI takes effect when the handler ends, and raises in a handler whose end cannot take it. With the change of the previous entry, the mruby log handlers run first in the log phase, and access_log and the other log-phase handlers then run on the same request. The internal redirect inside a log handler is therefore made an exception in this pull request.
    • Why the old behavior could not be kept: the log-phase handlers that run after the mruby log handlers run on the same request, so an internal redirect inside a log handler would run the phases of another location in the middle of the log phase.
    • What the documentation promised: Nginx.redirect of 2.7.5 said that the method is designed to be used in the rewrite handlers, and that the internal redirect runs the handlers of the other location before the call returns. It said nothing about log handlers.
  • Affected: log handlers whose code calls Nginx.redirect with a local URI.
  • What to do: remove the call from the log handler. To send a request to another location, call Nginx.redirect in a rewrite, access or content handler, where the redirect takes effect when the handler ends.
  • Tests: port 18195 (test/conf/conf.d/87-log-before-access-log.conf, test/t/cases/log_before_access_log.rb: the case /redirect).

Output is sent with the status that the handler set, and error_page does not apply to it (#779, #783)

Section titled “Output is sent with the status that the handler set, and error_page does not apply to it (#779, #783)”
  • Before: a handler that wrote output with Nginx.rputs or Nginx.echo and then set a status with Nginx.return, Nginx.send_header or Nginx.status_code= sent the output only with some statuses. A content handler of the main request sent it with 200 and with the statuses below 300 other than 201 and 204, a status below 200 included (since 2.7.2). For 201, 204 and the statuses from 300 up, nginx dropped the output and sent its own response for the status, and an error_page of the location for that status applied: Nginx.rputs '{"error":"no key"}' followed by Nginx.return Nginx::HTTP_UNAUTHORIZED answered nginx’s 401 page, or the page of the error_page. For Nginx::HTTP_CLOSE (444), nginx closed the connection without a response. In post_read, server rewrite, rewrite and access handlers and in subrequests, the output went out only with 200, or when no status was set after it. 201, 204 and the statuses from 300 up got nginx’s response in the same way, and for the other statuses below 300, for example 202 after output in an access handler, nginx ended the request without sending anything; a subrequest ended without a response body, and its parent read status 0. A status set before the first output did not apply to it: in every handler, Nginx.status_code = 401 followed by Nginx.rputs sent the output with 200.
  • Now: in post_read, server rewrite, rewrite, access and content handlers, on the main request and in subrequests, also after Nginx::Async::HTTP.sub_request resumed the handler, output followed by a status from 200 up is sent with that status and the Content-Length of the output, as nginx’s own return 401 "text"; sends its text, without its Content-Type. An error_page of the location for the status does not apply to the response, as it does not apply to nginx’s return with a text. For 301, 302, 303, 307 and 308, ngx_mruby adds no Location. For 204 and 304, nginx sends the header without the output. A HEAD request gets the header with the Content-Length of the output. Output followed by a status below 200 answers 500 with nginx’s error page, through an error_page for 500 if the location has one, without the output, and error.log gets a line at the error level: status code <N> with the output is not the status of a final response. return NGX_HTTP_INTERNAL_SERVER_ERROR. A status set before the first output follows the same rule: the output goes out with it from 200 up, and a status below 200 answers 500. When a handler sets a status more than once, the last call decides, before or after the output. The exception is Nginx::HTTP_CLOSE (444), nginx’s value for closing a connection without a response: with output before or after it, the output is not sent, and nginx closes the connection without a response, as for 444 without output.
  • Why it changed:
    • The reason: decision 5 of docs/proposals/core-alpha1.md (2026-11-09): the output of a handler is sent with its status, as for the statuses other than 301, 302, 303, 307 and 308 nginx’s return with a text does (section 2.12 there). Decision 6 there (2026-11-10) applies the same rule to a status set before the first output, as section 2.12 says (“before or after the output”), and decision 7 (2026-11-10) keeps 444 a way to drop a client: a client that the handler decided to refuse does not get the output built before that. The agent proxy of v3 answers 401, 403 and 429 with JSON bodies that Ruby builds, and item 8 of section 7 of docs/proposals/v3-plan.md accepted a body with any status as a behavior change of v3.
    • Why the old behavior could not be kept: a status set before the first output gives 200, and a status set after it dropped the output, so a script could not answer a status from 300 up with a body of its own, and whether its output was sent depended on the handler and on the status. Keeping 200 for a status set before the output would leave two rules for one call, Nginx.return, whose result depended on where the script calls it. Letting error_page apply when the location has one for the status would make what a script sends depend on directives elsewhere in the configuration.
    • What the documentation promised: Nginx.return of 2.7.5 described the old behavior of a content handler of the main request: 201, 204 and the statuses from 300 up got nginx’s own response without the output, and in a subrequest a status other than 200 after output ended the subrequest without a response body. It said nothing about the other handlers, and nothing about a status set before the output.
  • Affected: handlers that write output and then set 201, 204, 304 or a status from 300 up, and post_read, server rewrite, rewrite and access handlers and subrequests that write output and then set another status below 300 other than 200. A location with an error_page for such a status now sends the output of the handler instead of the page of the error_page. Handlers that set a status below 200 after output now answer 500 instead of that status. Handlers that set a status other than 200 before the first output, with Nginx.return, Nginx.send_header or Nginx.status_code=, now send the output with that status instead of 200, or answer 500 for a status below 200; with Nginx::HTTP_CLOSE (444), they close the connection without a response instead. In a subrequest, 444 with output closes the client’s connection, as nginx’s own return 444 does in the location of a subrequest and as 444 after the output did on 2.x; output written after 444 reached the parent with 200 before. Unchanged: Nginx::HTTP_CLOSE after the output (the connection is closed without a response, as on 2.x), 0 and 200 before the first output (200 with the output), a return code below 0 before the first output (it does not apply to the output), output followed by Nginx.redirect with a URL (200 with the output and the Location, also when the handler set a status before the output), Nginx::DECLINED and the other return codes below 0 after the output (the output is not sent, and the phase gets the code), an exception (500 without the output), Nginx.return 0 (no status; a content handler sends the output with 200), log handlers and output filters.
  • What to do: nothing for a handler that means to send its output with the status. A handler that relied on nginx’s page or on the error_page of the location sets the status without writing output, for example Nginx.return Nginx::HTTP_UNAUTHORIZED alone. A handler that sets 301, 302, 303, 307 or 308 after output sets Location itself with Nginx::Headers_out. A handler that sets a status below 200 with output sets the final status it means. A handler that sets a status before its output and means to send the output with 200 calls Nginx.return Nginx::HTTP_OK after the output.
  • Tests: port 18197 (test/conf/conf.d/89-body-with-status.conf, test/t/cases/body_with_status.rb), port 18154 (test/t/cases/output_then_status.rb: the cases /created, /not_found, /continue and /sub_request_to_accepted, whose expectations change in #779, and /status_before_output, whose expectation changes in #783), and port 18110 (test/t/cases/request_api.rb: the cases send_header 404 after rputs and send_header 201 after rputs, whose expectations change). On port 18138, the case of /deny_rputs_slow in test/t/cases/output_filters_with_content_handler.rb gets nginx’s 403 page from deny all after Nginx::DECLINED, because output followed by Nginx.return 403 is now sent.

A stream session or stream hook that raises logs the backtrace of the exception in a build with --with-debug (#796)

Section titled “A stream session or stream hook that raises logs the backtrace of the exception in a build with --with-debug (#796)”
  • Before: in an nginx built with --with-debug, the HTTP module wrote the backtrace of an exception of Ruby code after its mrb_run failed line, one line at the error level per frame (for example /path/to/handler.rb:10:in bar). The stream module wrote only the mrb_run failed line for an exception of mruby_stream, mruby_stream_init, mruby_stream_init_worker and mruby_stream_exit_worker, of their _code forms, and of mruby_stream_server_context_code.
  • Now: the stream module writes the backtrace in the same way: after the mrb_run failed line, one line at the error level per frame, with the client and the server of the session for the code of a session. The mrb_run failed lines of both modules keep their text and their level. A build without --with-debug, which build.sh makes by default, writes no backtrace, as before.
  • Why it changed:
    • The reason: the two modules now write the exception of Ruby code with one function, ngx_mrb_log_exception in src/common/ngx_mruby_log.c, so that both log it in the same way and a change of how an exception is logged is made once (section 2.8 of docs/proposals/core-alpha1.md).
    • Why the old behavior could not be kept: keeping stream without the backtrace would need a second path through the shared function for stream only, and an exception of a stream session would stay harder to locate than one of a request in the same debug build.
    • What the documentation promised: the documentation of 2.7.5 said nothing about the backtrace in either module.
  • Affected: nginx built with --with-debug and with stream code that raises: error.log gets more lines at the error level, one per frame of each exception, and alerts or log parsers that count the lines at the error level see more of them.
  • What to do: nothing for most builds. To count exceptions, match the mrb_run failed lines instead of every line at the error level.
  • Tests: port 12380 (test/conf/conf.d/stream/49-exception-log.conf, test/html/exception_log_stream.rb, test/t/cases/exception_log.rb).

An exception whose inspect raises or does not return a String is logged with the name of its class (#799)

Section titled “An exception whose inspect raises or does not return a String is logged with the name of its class (#799)”
  • Before: ngx_mruby writes an exception of Ruby code to error.log with the inspect of the exception, for example mrb_run failed: return 500 HTTP status code to client: error: #<RuntimeError: boom>. When a script had redefined inspect of the exception class so that it raised, or returned an object that is not a String, ngx_mruby wrote no such line: the handler still ended as after any exception (a request got 500, a stream session was closed), but error.log had no line of the exception. When the handler ran inside another mruby call, for example in the location that Nginx.redirect runs from an mruby_set handler, an inspect that raised did not return to the logging at all (see “Fixes”).
  • Now: the line is written in both cases, at the same level and with the same text before the exception, and names the class of the exception in place of its inspect: error: #<MyError> (inspect raised ArgumentError) when inspect raised (the class of the exception of inspect comes last), and error: #<MyError> (inspect did not return a String) otherwise. The exception of inspect itself is not logged. An exception whose inspect returns a String is logged as before.
  • Why it changed:
    • The defect: when a script had redefined inspect of an exception class so that it raised or returned an object that is not a String, the exception of the handler left no line in error.log; and inside another mruby call, an exception of inspect or backtrace went on to the outer call past the nginx functions between the two calls, so that nginx did not finish the request (#799). The calls of inspect and backtrace in the logging now run under the same protection as the resumed fiber in ngx_mrb_fiber_resume (section 2.8 of docs/proposals/core-alpha1.md moved the logging into src/common/ngx_mruby_log.c).
    • Why the old behavior could not be kept: an exception that leaves no line in error.log cannot be found from the log. With the protection, the logging gets the exception of inspect on every path, so it can name the class instead of writing nothing.
    • What the documentation promised: the documentation of 2.7.5 said nothing about the line of an exception whose inspect raises.
  • Affected: scripts that redefine inspect of an exception class so that it raises or returns an object that is not a String. error.log gets one line at the level of the mrb_run failed lines for each such exception (error, or emerg for mruby_stream_server_context_code).
  • What to do: nothing. To see the message of such an exception in error.log, make its inspect return a String.
  • Tests: port 18198 and the stream port 12382 (test/conf/conf.d/93-exception-log-raising-methods.conf, test/conf/conf.d/stream/51-exception-log-raising-methods.conf, test/t/cases/exception_log_raising_methods.rb).

Methods that have no effect in a handler raise a RuntimeError there (#826)

Section titled “Methods that have no effect in a handler raise a RuntimeError there (#826)”
  • Before: a method of the HTTP module checked only that a request was being processed, not which handler ran it. In a log handler, which runs after the response was sent, the setters of the request (Nginx::Request#uri=, #args=, #method=, #request_line=, Nginx::Headers_in#[]= and #delete) changed the request, and the methods of the response head (Nginx::Headers_out#[]= and #delete, Nginx.status_code=, Nginx.return and Nginx.send_header with a status, Nginx::Request#content_type=) changed the response, without an effect on what the client got; Nginx.rputs and Nginx.echo converted their argument and returned. In header and body filters, which run while nginx sends the response, the setters of the request changed the request in the same way, and in a header filter Nginx.rputs and Nginx.echo added their text to the output of the handler that started the response. In an mruby_set handler, Nginx.rputs and Nginx.echo added their text to the output that a later handler of the location sent. Nginx::Filter#body outside a body filter returned an empty String, or the body that a body filter of the request had read. In a handler that nginx runs after it has sent the response header, such as a handler of a post_action location, the methods of the response head changed the response without an effect on what the client got, as in a log handler.

  • Now: these calls raise a RuntimeError whose message names the method and the handler, for example Nginx::Headers_out#[]= is not available in a log handler or Nginx.rputs is not available in a header filter, and the handler ends as after any other exception: a log handler logs it and the response stays as it was sent, a filter answers 500, and an mruby_set handler logs it and gives the variable an empty value. The methods of the response head also raise in the other handlers once nginx has sent the response header (... is not available after the response header is sent). Nginx::Filter#body outside a body filter raises Nginx::Filter#body can only be used in an output body filter, as #body= and #output did since 2.7.1; the message of #output now names #output instead of #body=. The table of “Where the methods work” in docs/class_and_method/README.md lists where each method works:

    Methods Where they work New raise
    Reading the request: the getters of Nginx::Request, Nginx::Headers_in#[], the reads of Nginx::Var, Nginx::Connection, the getters of Nginx::Server every handler and filter of a request none
    Changing the request: uri=, args=, method=, request_line=, Nginx::Headers_in#[]= and #delete mruby_set handlers, the post_read, server rewrite, rewrite, access and content handlers log handlers, header and body filters
    Assigning variables: Nginx::Var#NAME=, #set every handler and filter of a request none
    The response head: Nginx::Headers_out#[]= and #delete, Nginx.status_code=, Nginx.return and Nginx.send_header with a status, content_type= every handler and filter of a request but a log handler, while nginx has not sent the response header log handlers, and the other handlers after the response header is sent
    Output: Nginx.rputs, Nginx.echo the post_read, server rewrite, rewrite, access and content handlers, and body filters mruby_set handlers, log handlers, header filters
    The body of a body filter: Nginx::Filter#body, #body=, #output body filters #body elsewhere (#body= and #output raised there before)

    Outside a request, the methods of these rows raise this method can only be used while processing a request, as since 2.7.1. Nginx::Async, Nginx::SSL, Nginx::Server#add_listener, Nginx.log and the methods of the stream module work where they worked, with the same messages. Nginx.redirect with a local URI raises in mruby_set handlers, log handlers and output filters (Nginx.redirect with a local URI is not available in ...), as the entries of #770 and #833 say, and works with a URL in every handler and filter of a request.

  • Why it changed:

    • The reason: item 8 of section 7 of docs/proposals/v3-plan.md accepted that a method called in a handler where it has no effect raises in v3, and section 2.1 of docs/proposals/core-alpha1.md gives each method the handlers where it works. A script that sets a response header in a log handler, or writes output in a header filter, learns from the exception that the call did nothing, instead of a response without the header or the text.
    • Why the old behavior could not be kept: the methods found their request through a process-wide pointer and could not tell the handlers apart, so a call without an effect looked like one that worked. Each method now reads one execution context of the request, which says which handler runs; keeping the silent calls would leave a method that works in some handlers and does nothing in others without a sign of which.
    • What the documentation promised: the documentation of the classes and methods of 2.7.5 said that the request-scoped methods raise outside a request, and said nothing about the handlers of a request where they have no effect.
  • Affected: log handlers (mruby_log_handler and mruby_log_handler_code) that set a response header or a status, write output, or change the request; output filters (mruby_output_header_filter* and mruby_output_body_filter*) that change the request, and header filters that write output; mruby_set and mruby_set_code handlers that write output; handlers that run after nginx has sent the response header, such as those of a post_action location, and set a response header or a status; and code that reads Nginx::Filter#body outside a body filter. Builds: ngx_mruby keeps the execution context in mrb->ud of its mrb_state, of the http module as of the stream module, so an mrbgem that puts a pointer of its own in mrb->ud cannot be added to the build; on 2.x only the state of the stream module was like that.

  • What to do: remove such calls, or move them to a handler where they work: set the response head in a phase handler or a filter, write output in a phase handler, and change the request in a phase handler or an mruby_set handler. A log handler that passes a value to access_log assigns a variable with Nginx::Var, which works there. A build_config.rb of your own leaves out an mrbgem that sets mrb->ud (for example one that keeps a C pointer of its own there).

  • Tests: port 18119 (test/conf/conf.d/98-api-phases.conf, test/t/cases/api_phases.rb). The cases of Nginx::Filter#body in a header filter (port 18080, test/t/ngx_mruby.rb) and in a content handler (port 18112, test/t/cases/filter_connection.rb) now expect the RuntimeError instead of an empty String. The log handlers of /directives/log (port 18114) write their output after they store their value. The case /post_action of port 18119 checks the raise after the response header is sent.

Nginx.redirect with a local URI raises a RuntimeError in mruby_set handlers and output filters (#833)

Section titled “Nginx.redirect with a local URI raises a RuntimeError in mruby_set handlers and output filters (#833)”
  • Before: in an mruby_set or mruby_set_code handler, an output header filter (mruby_output_header_filter*) and an output body filter (mruby_output_body_filter*), Nginx.redirect with a local URI made the internal redirect inside the call: nginx ran the phases of the target location there, inside the Ruby call of the handler, and the code of the handler went on after the call. A handler of the target that waited in Nginx::Async.sleep or Nginx::Async::HTTP.sub_request was resumed by its timer or by the end of its subrequest, outside nginx’s phases, and a content handler there did not keep the request, so the request ended at the sleep.
  • Now: the call raises a RuntimeError with the message Nginx.redirect with a local URI is not available in an mruby_set handler (... in a header filter, ... in a body filter), and nginx makes no internal redirect. The handler ends as after any other exception: an mruby_set handler logs it and gives the variable an empty value, and the request goes on in its own location; a filter that does not rescue it answers 500. Nginx.redirect with a URL (http://, https://, $scheme) works there as before. In a post_read, server rewrite, rewrite, access or content handler, Ruby code that runs outside the fiber of the handler, such as the inspect of its exception, raises as well (Nginx.redirect with a local URI is not available without a running handler fiber): it has no end that could take the redirect, which would otherwise be made inside that call. With the raise in log handlers (#770), only the post_read, server rewrite, rewrite, access and content handlers make an internal redirect, when they end (#728), and no handler of a request runs inside the Ruby call of another one.
  • Why it changed:
    • The reason: decision 1 and section 2.9 of docs/proposals/core-alpha1.md (2026-11-09): Nginx.redirect with a local URI takes effect when the handler ends, and raises in a handler whose end cannot take it. An mruby_set handler runs inside the script of the rewrite module, which goes on after the handler, and a filter runs while nginx sends the response, so neither can end with a redirect. With no handler inside the Ruby call of another one, every wait of a handler ends through nginx’s phase checker, and the code that resumed a fiber from its timer or from the end of its subrequest outside nginx’s phases is removed.
    • Why the old behavior could not be kept: the handlers of the target ran inside the Ruby call of the calling handler, where nginx cannot call a handler that waits again, so such a wait ended the request outside nginx’s phases, and the calling handler went on with a request that the target was answering.
    • What the documentation promised: Nginx.redirect of 2.7.5 said that the method is designed to be used in the rewrite handlers, and that the internal redirect runs the handlers of the other location before the call returns. It said nothing about mruby_set handlers or filters.
  • Affected: mruby_set and mruby_set_code handlers, output header filters and output body filters whose code calls Nginx.redirect with a local URI, and Ruby code that ngx_mruby runs for a phase handler outside its fiber and that calls it, such as an inspect or a backtrace that an exception class redefines.
  • What to do: call Nginx.redirect with a local URI in a rewrite or access handler, where the redirect takes effect when the handler ends. An mruby_set handler that chooses the target can return it as the value of its variable, for a rewrite handler or nginx’s rewrite to redirect to. A filter cannot send the request elsewhere: choose the location before the response, in a phase handler. Do not call Nginx.redirect from inspect or backtrace of an exception class.
  • Tests: port 18126 (test/conf/conf.d/99-redirect-nested.conf, test/t/cases/redirect_nested.rb). The six cases of test/t/cases/exception_log_raising_methods.rb (port 18198) and test/t/cases/exception_log_script_methods.rb (port 18091) that logged an exception inside another mruby call, through Nginx.redirect from an mruby_set handler, are removed, with the approval of the owner of 2026-11-16: no configuration can make such a call any more.

Assigning a variable that nginx does not know, or does not let scripts change, raises (#854)

Section titled “Assigning a variable that nginx does not know, or does not let scripts change, raises (#854)”
  • Before: Nginx::Var#<name>= and Nginx::Var#set wrote a line at the error level to error.log and returned nil when nginx could not take the assignment, and the code and the request went on with the variable unchanged: for a name that nginx does not know (ngx_mruby ERROR ngx_mrb_var_set_vector:<line>: <name> is not found, with ngx_mrb_var_set_func for set), for a variable that nginx does not let scripts change, such as $uri or $http_host (... <name> not changeable), and for a variable that nginx keeps no value of in the request (... <name> is not assinged).
  • Now: the assignment raises, and the message names the variable as the script wrote it: NameError with nginx variable $<name> is not defined (declare it with set or mruby_variable) for a name that nginx does not know, a name that begins with a prefix of nginx such as arg_ or http_ included; RuntimeError with nginx variable $<name> cannot be changed by a script for a variable that nginx does not let scripts change; and RuntimeError with nginx variable $<name> cannot be assigned by a script: the configuration does not refer to it for a variable without a set handler, such as one of map or geo, that nothing in the configuration refers to, so that nginx keeps no value of it in the request. A handler that does not rescue the exception ends as after any other exception: its request answers 500 (a log handler logs the exception, after the response was sent), and error.log has the mrb_run failed line of the exception. The worker goes on. nginx -t cannot find these mistakes, because the code decides the name when it runs; they show at the first request that runs the assignment. An assignment that nginx takes works as before, with the same value and the same return value. Nginx::Var#<name>=, Nginx::Var#set and the end of an mruby_set handler that waited in Nginx::Async.sleep assign through one function, which does what nginx’s set directive does.
  • Why it changed:
    • The reason: decision 3 and section 2.3 of docs/proposals/core-alpha1.md (2026-11-09). A misspelled variable name, or an assignment to a variable that nginx does not let scripts change, now fails at the first request that runs it, with its exception in error.log, instead of losing the value with only an error line while the request goes on. A handler that wants to go on rescues the exception, and mruby_variable declares every variable that a script means to assign, so a correct configuration does not reach it.
    • Why the old behavior could not be kept: the request went on as if the variable had the value, so a later handler, proxy_pass or access_log used the old value of the variable without a sign in the response, and the code that assigned it could not tell from the result alone whether a nil came from the failure; the two copies of the assignment also differed in how they converted and lowercased the name.
    • What the documentation promised: Nginx::Var of 2.7.11 said that a variable has to be declared in nginx.conf and that a script cannot add one, and showed v.http_host = "192.168.0.1", an assignment to a variable that nginx does not let scripts change. It said nothing about what an assignment to such a variable does.
  • Affected: Nginx::Var#<name>= (the accessors and method_missing) and Nginx::Var#set in every handler and filter of a request, for a name that nginx does not know or a variable that it does not let scripts change or keeps no value of; log monitoring that matches the old error lines. Reading a variable is not affected: v.<name> still returns nil for a name that is not a variable. The end of an mruby_set handler assigns a variable that its directive declared, which nginx takes.
  • What to do: declare the variables that scripts assign, with set in the location, or with mruby_variable in the http block, and assign them by their names; do not assign variables of nginx that scripts cannot change, such as $uri or $http_host (to change the URI or a request header, use the setters of Nginx::Request and Nginx::Headers_in). A handler that should go on after a failed assignment rescues NameError and RuntimeError. In log monitoring, match the mrb_run failed line with #<NameError: nginx variable $ or #<RuntimeError: nginx variable $ in place of the old lines.
  • Tests: port 18107 (test/conf/conf.d/99-var-assign.conf, test/t/cases/var_assign.rb). The cases /unknown of test/t/cases/var_method_lookup.rb and /set_shared_key of test/t/cases/var_input.rb expect NameError where they expected nil.

nginx -t refuses a stream hook given twice in one context (#834)

Section titled “nginx -t refuses a stream hook given twice in one context (#834)”
  • Before: the stream module accepted a second directive for a hook in the same context, and the later one replaced the earlier one without a message: mruby_stream and mruby_stream_code in one server {} (or in the stream {} block), either of them twice, and the file and the inline form of mruby_stream_init, mruby_stream_init_worker and mruby_stream_exit_worker (for example mruby_stream_init and mruby_stream_init_code) in the stream {} block. Only the code of the later directive ran. The HTTP module refused a second directive for the same code with "NAME" directive is duplicated already.
  • Now: nginx -t, and a start or a reload of nginx, fail on the second directive with [emerg] "mruby_stream_code" directive is duplicated (the name is that of the second directive), as for the HTTP directives. One hook in the stream {} block and one in a server {} are not a duplicate: the code of the server is the handler of the server, as before. When the file of a stream directive cannot be read or its code does not compile, the emerg line has the form of the HTTP module, ngx_mruby-stream-module : ngx_stream_mruby_code_directive mrb_file(PATH) open failed or ... mrb_string(CODE) load failed, instead of mrb_string(PATH) load failed for both forms. The same lines of the HTTP directives, and the compile info line at the info level of both modules, name the directive function of the table (ngx_http_mruby_handler_directive, ngx_http_mruby_hook_directive, ngx_stream_mruby_code_directive) where they named a function of each directive, such as ngx_http_mruby_rewrite_phase, with the same text otherwise and at the same level.
  • Why it changed:
    • The reason: the code that a configuration means to run is the code that runs, and both modules set the code of a directive with one function and one rule, ngx_mrb_code_set in src/common/ngx_mruby_code.c (decision 4 and section 2.5 of docs/proposals/core-alpha1.md).
    • Why the old behavior could not be kept: a configuration with two directives for a hook ran one of them without a word, so a hook left from an earlier edit, or added in an included file, replaced the code that the operator read in the configuration. Keeping the replacement would also keep a rule of its own for stream in the shared function.
    • What the documentation promised: the directives of 2.7.5 said nothing about giving a stream hook twice.
  • Affected: stream configurations with two of mruby_stream and mruby_stream_code in one context, or with both forms of mruby_stream_init, mruby_stream_init_worker or mruby_stream_exit_worker, or one of them twice; nginx does not start or reload with them. Alerts or log parsers that match the mrb_string(...) load failed line of a stream file directive, or the name of a directive function in the emerg lines of the directives with Ruby code.
  • What to do: keep one directive of each hook in a context, the one whose code ran on 2.x (the later one), and remove the others. To match the error line of a directive whose code cannot be loaded, match mrb_file( and mrb_string(, not the name of the function.
  • Not changed by this release: mruby_stream_server_context_code runs its code while nginx reads the configuration and keeps nothing, so each such directive of a server still runs. The HTTP directives keep their behavior, but for the function name in the lines above: the same arguments and contexts, a second directive for the same code is refused as before, and the file and the inline form of a phase handler are two handlers, which both run.
  • Tests: test/t/cases/stream_duplicate_hooks.rb (nginx -t with port 12398) and the case of mruby_stream_init and mruby_stream_init_code in test/t/cases/stream.rb, which expects the refusal instead of the later hook. test/conf/nginx.stream.conf, the second nginx of test/t/cases/_second_instance.rb and the nginx -t case of test/t/cases/config_time_log.rb give each stream hook once.

Output filters given at http or server level, or in a location, run in the locations below them (#835)

Section titled “Output filters given at http or server level, or in a location, run in the locations below them (#835)”
  • Before: an output filter (mruby_output_header_filter, mruby_output_body_filter and their _code forms) ran only at the level of its directive. One given in the http {} block ran for no request; one given in a server {} block ran only for the requests of the server that matched none of its locations; one given in a location ran in that location, but not in the locations nested in it nor in its if blocks. nginx copied the code of the filter to the levels below, but not the handler that runs it. The phase handler directives (mruby_rewrite_handler and the others) given at those levels ran in the locations below them already.
  • Now: a location, a nested location or an if block without a filter directive of its own runs the filter of the level above it: that of the location around it, of its server, or of the http {} block. The header filter and the body filter are inherited each on its own: a level with a directive of one kind runs its own filter of that kind instead of the one above it, and still runs the filter of the other kind from above, so a location with only a body filter runs the header filter of its server as well. Such a location reads its responses through the filter as the location of the directive does: with an mruby body filter, ngx_mruby sets r->filter_need_in_memory, so nginx reads a file of the response into memory, and the body filter sends the body that it made instead of the file; with a header filter alone, nginx passes the file on unread, and sends it with sendfile when sendfile is on (#847); a body filter collects a body with Content-Length before its code runs, and holds the header until then; a body without Content-Length, such as a chunked response of an upstream, passes the body filter unread, with the notice line body filter don't support chunked response, go to next filter in error.log. Subrequests, such as those of SSI includes, run the filters of their locations in the same way.
  • Why it changed:
    • The defect: a filter directive that nginx accepted in the http {} and server {} blocks did nothing in their locations, unlike the other directives with Ruby code of the same blocks. The merge of the location configuration, ngx_http_mruby_merge_loc_conf, merged the code of each filter but not the pointer to its handler, which only the directive set. Section 2.4 of docs/proposals/core-alpha1.md and the Pillar B row on the filter handler pointers of docs/proposals/v3-plan.md record it.
    • Why the old behavior could not be kept: a filter given for a server or for every server had no effect on the responses that its configuration named, and nothing reported it: nginx -t accepted the directive, and the filter ran only for the requests that fell through every location. Keeping it would leave the filter directives the only directives with Ruby code that a level below does not inherit.
    • What the documentation promised: the directives of 2.7.5 gave server and location as the context of the four filter directives, as for the phase handlers, and said nothing about the locations of a server.
  • Affected: configurations with a filter directive in the http {} block or in a server {} block, and those with a filter directive in a location that has nested locations or if blocks. The responses of those locations, also those that a static file, an upstream or a return makes, go through the filter: its code runs for each of them, a header filter changes their headers, and a body filter replaces their bodies.
  • What to do: check that each filter given at http or server level, and each filter of a location with nested locations or if blocks, can run for every response of the levels below it. A filter that should run in some locations only moves into those locations. A location keeps the filter of the level above it unless it gives a filter of the same kind of its own; there is no directive that turns an inherited filter off.
  • Not changed by this release: the phase handlers. ngx_mruby now adds to nginx’s phases only the handler of each phase and form (file or inline) that a directive of the configuration uses, with mruby_add_handler on counting as a content handler of the file form, where it added all twelve before. The handlers that are added run in the same order as before, and a handler that is not added would only have passed the request on, so no configuration or script sees a difference.
  • Tests: port 18108 (test/conf/conf.d/99-filter-inherit.conf, test/t/cases/filter_inherit.rb), and the mode http_filter of the second nginx of test/t/cases/_second_instance.rb (port 18116) for a filter in the http {} block, a content handler that only mruby_add_handler on uses and a log handler of one form.

A location with an mruby header filter and no body filter does not read files into memory (#847)

Section titled “A location with an mruby header filter and no body filter does not read files into memory (#847)”
  • Before: in a location with mruby_output_header_filter or mruby_output_header_filter_code and without mruby_output_body_filter or mruby_output_body_filter_code, ngx_mruby set r->filter_need_in_memory, as in a location with a body filter. nginx then read each file of a response, such as a static file, into memory, in the buffers of output_buffers, before it passed the body on. With sendfile on, the buffers kept the position of the file, and nginx sent their data with sendfile as before, but one set of those buffers at a time: a file larger than them was read and sent in pieces of their size.
  • Now: such a location passes a file of the response on unread, as a location without an mruby filter does: with sendfile on, nginx sends it with sendfile without reading it first, and output_buffers does not apply to it. The status, the headers and the body that the client receives are the same. A location with an mruby body filter, its own or one that it inherits (#835), still gets its responses in memory, because the body filter reads the body from memory.
  • Why it changed:
    • The defect: only the body filter reads the body; the header filter changes the headers and needs no body in memory, so the flag cost a read of every file of the response into memory that nothing in such a location used. The review of #835 reports the flag in such a location.
    • Why the old behavior could not be kept: since #835, a header filter given at http or server level runs in every location below it, so one header filter, for example one that adds a header to every response, made nginx read every static file of the server into memory.
    • What the documentation promised: the directives of 2.7.5 said nothing about how nginx reads a file in a location with an output filter.
  • Affected: locations with an mruby header filter and no mruby body filter, with sendfile on, whose responses are files, such as static files: nginx no longer reads them into the buffers of output_buffers, and sends them as a location without an mruby filter does. This does not apply where nginx already reads the file into memory for another reason: on an HTTPS connection without kernel TLS (r->main_filter_need_in_memory, set by nginx when the connection cannot use sendfile), and when a filter such as gzip, SSI or sub handles the response. With sendfile off, nginx reads a file into those buffers in any case, and nothing changes.
  • What to do: nothing; the responses are the same.
  • Tests: test/t/cases/filter_sendfile.rb, with the mode http_sendfile of the second nginx of test/t/cases/_second_instance.rb (port 18116), which counts, for each request, the lines of nginx’s debug log for a read of the file into memory and for a call of sendfile.

The measurement builds include stream sessions

Section titled “The measurement builds include stream sessions”
  • Before: the soak and callgrind builds omitted --with-stream, and neither default set exercised a TCP stream session. The soak checked that the stream counter keys existed but did not judge their values.
  • Now: both measurement builds include stream. Their default sets add stream_sleep, one TCP session that waits 1 ms and returns exact bytes through EOF. Soak samples check and print stream_timers and stream_fibers, and add a sessions column. The performance row reports instructions per completed session.
  • Why it changed:
    • The reason: the planned stream coverage needs to observe pending timers and held fibers and measure the work of a completed wait.
    • Why the old behavior could not be kept: an HTTP-only measurement binary cannot execute the stream handler or detect a change in its cost.
    • What the documentation promised: the measurement rules described a comparison without stream support.
  • Affected: test/build_release.sh, the default soak and performance comparisons, and consumers of their reports. Runtime APIs, build.sh and test.sh are unchanged.
  • What to do: rerun both measurement scripts without ONLY_RUN after updating; the build stamp reconfigures and rebuilds both sides. Accept the additional soak columns and interpret the new performance row per TCP session. Keep the existing HTTP rows and thresholds when comparing results.

A HEAD response with an output body filter keeps its connection available

Section titled “A HEAD response with an output body filter keeps its connection available”
  • Before: a HEAD request to a location with mruby_output_body_filter or mruby_output_body_filter_code, whose response had a known content length, received its response headers, but nginx then closed the connection even when the headers advertised keep-alive. A following GET on that connection received no response. This occurred with both empty and nonempty replacement bodies.
  • Now: for those responses, after the HEAD headers are sent successfully, the filter sends no body bytes and leaves an otherwise reusable connection available for the next request. GET responses and header-filter errors keep their behavior. 204 and 304 responses through such a filter keep their connection as well (“A 204 or 304 response through an mruby output filter keeps its connection available” below).
  • Why it changed:
    • The defect: the body-filter finalizer returned NGX_ERROR after a successful header-only response. nginx treated that return as an output error and closed the connection. The review of #574 recorded the HEAD case, and the review of #628 confirmed it with a following GET.
    • Why the old behavior could not be kept: a successfully sent HEAD response did not represent an output error, and closing the connection prevented the next request advertised by keep-alive.
    • What the documentation promised: Nginx::Filter#body= described replacement bodies and their content length, but did not describe a HEAD connection-close exception.
  • Affected: HEAD responses with a known content length that are finalized by an mruby output body filter, when the connection can otherwise be kept alive.
  • What to do: nothing. To close a connection deliberately, configure nginx’s keep-alive policy rather than relying on this filter error.

A HEAD response through an mruby header filter alone, or through a body filter without Content-Length, keeps its connection available (#848)

Section titled “A HEAD response through an mruby header filter alone, or through a body filter without Content-Length, keeps its connection available (#848)”
  • Before: a HEAD request to a location with mruby_output_header_filter or mruby_output_header_filter_code and without an mruby body filter received the response header, with the changes that the header filter code made, and nginx then closed the connection, also when the header said Connection: keep-alive. A request that the client sent next on that connection got no response. The same happened to a HEAD request to a location with mruby_output_body_filter or mruby_output_body_filter_code whose response had no Content-Length, such as a listing of autoindex or a response of an upstream without a length; the body filter passes such a response on without running its code. Since #835, a header filter given at http or server level runs in every location below it, so with such a filter every HEAD request to the server ended this way.
  • Now: after nginx has sent the header of such a HEAD response, ngx_mruby returns the result of sending it and passes no body on, as nginx’s own handlers do for HEAD, and nginx keeps an otherwise reusable connection for the next request. The header that the client receives is the same. GET responses and an error of the header filter code keep their handling. 204 and 304 responses on the same paths keep their connection as well (“A 204 or 304 response through an mruby output filter keeps its connection available” below).
  • Why it changed:
    • The defect: for a HEAD request, nginx’s header filter sets r->header_only when it sends the header. ngx_mruby passes the header on after the code of a header filter in a location without a body filter, and, in the body filter, for a response without a length; in both places it returned NGX_ERROR when that flag was set, although the header had been sent. nginx’s handlers, such as the static file handler, return and autoindex, return that result, so nginx ended the request as failed and closed the connection. The comment of test/t/cases/head_body_filter.rb names both paths as outside the fix of the body filter with a known length (“A HEAD response with an output body filter keeps its connection available” above).
    • Why the old behavior could not be kept: a HEAD response that nginx sent successfully is not an output error, and closing the connection lost the next request that keep-alive announced. Since #835, one header filter at http or server level, for example one that adds a header to every response, made every HEAD request to the server close its connection.
    • What the documentation promised: the directives of 2.7.10 said nothing about HEAD requests in a location with an output filter, or about closing the connection after one.
  • Affected: HEAD requests to a location with an mruby header filter and no mruby body filter, its own or one that it inherits (#835), and HEAD requests to a location with an mruby body filter whose response has no Content-Length, when the connection can otherwise be kept alive.
  • What to do: nothing. To close a connection deliberately, configure nginx’s keep-alive policy (keepalive_timeout, keepalive_requests) instead of relying on this error.
  • Tests: port 18112 (test/conf/conf.d/20-filter-connection.conf, test/t/cases/head_header_filter.rb): HEAD, and a GET control, through a header filter alone on a response of return and on a static file, and HEAD through a body filter on a listing of autoindex, also sent at 50 bytes a second (limit_rate 50) so that its header needs more than one write, each followed by a GET on the same connection, with a GET control of the listing.

A 204 or 304 response through an mruby output filter keeps its connection available (#849)

Section titled “A 204 or 304 response through an mruby output filter keeps its connection available (#849)”
  • Before: a response that ends at its header without a HEAD request, a 304 that nginx answers to a GET with If-Modified-Since or If-None-Match or a 204 such as that of return 204;, received its header with Connection: keep-alive when it passed an mruby output filter, and nginx then closed the connection. A request that the client sent next on that connection got no response. This happened in a location with mruby_output_header_filter or mruby_output_header_filter_code and no mruby body filter, and in a location with mruby_output_body_filter or mruby_output_body_filter_code, both when the response had a Content-Length (the 204 of return 204;, which nginx gives the length 0) and when it had none (a 304 of a static file, whose length nginx removes). Since #835, a header filter given at http or server level runs in every location below it, so with such a filter every conditional GET that nginx answered with 304 from a static file of the server ended this way.
  • Now: after nginx has sent the header of a response that ends at it (HEAD, 204 or 304), ngx_mruby returns the result of sending it and passes no body on, whatever the method of the request, as nginx’s own handlers do when the header ends the response. nginx keeps an otherwise reusable connection for the next request. The status and the header that the client receives are the same, and no body bytes follow the header. When nginx cannot send the header in one write, as with limit_rate or a client that reads slowly, the branch for a response without a length passes nginx’s later calls on without the body, so the rest of the header goes out. A result of NGX_ERROR from sending the header, and an error of the code of the header filter, keep their handling.
  • Why it changed:
    • The defect: nginx’s header filter sets r->header_only when the status is 204 or 304, as it does for HEAD. The three places where ngx_mruby passes the header on (after the code of a header filter in a location without a body filter; in the body filter, for a response without a length; and after the code of a body filter, in ngx_mrb_finalize_body_filter) returned NGX_ERROR when that flag was set for a request other than HEAD, although the header had been sent. nginx’s handlers, such as the static file handler and return, return that result, so nginx ended the request as failed and closed the connection. The review of #848 recorded the 304 and the 204 with a header filter alone.
    • Why the old behavior could not be kept: a 204 or 304 that nginx sent successfully is not an output error, and closing the connection lost the next request that keep-alive announced. With a header filter at http or server level (#835), every conditional GET of a static file that the client could answer from its cache closed its connection.
    • What the documentation promised: the directives of 2.7.10 said nothing about 204 or 304 responses in a location with an output filter, or about closing the connection after one.
  • Affected: 204 and 304 responses that pass an mruby output header filter or body filter, its own or one that the location inherits (#835), when the connection can otherwise be kept alive.
  • What to do: nothing. To close a connection deliberately, configure nginx’s keep-alive policy (keepalive_timeout, keepalive_requests) instead of relying on this error.
  • Tests: port 18112 (test/conf/conf.d/20-filter-connection.conf, test/t/cases/header_only_keepalive.rb): a 304 of a static file to a GET with If-Modified-Since and a 204 of return 204;, each through a header filter alone and through a body filter, the 304 to GET and to HEAD of a static file that a body filter location reads through an output buffer smaller than the file (output_buffers 1 8), and a GET without If-Modified-Since of each static file as the control, each followed by a GET on the same connection.

The integration test build enables Nginx::Debug

Section titled “The integration test build enables Nginx::Debug”
  • Before: the default test.sh build did not define NGX_MRUBY_DEBUG_STATS, so handler scripts could not call Nginx::Debug.stats or Nginx::Debug.gc in that build.
  • Now: test.sh defines NGX_MRUBY_DEBUG_STATS for nginx and ngx_mruby, enabling those methods and the counters they expose. The default build.sh build and the performance comparison keep their existing flags.
  • Why it changed:
    • The reason: the repeated-sleep integration test needs the pending-timer and held-fiber counters to check that one handler releases them after 1,000 waits.
    • Why the old behavior could not be kept: leaving the counters out of the test binary would omit these assertions from the normal suite and its build-matrix cells.
    • What the documentation promised: the test guide described Nginx::Debug as absent from the default test.sh and build.sh builds.
  • Affected: binaries built by test.sh, including static and dynamic module builds. Production builds made with build.sh and the performance-comparison builds are unchanged.
  • What to do: for an existing test build, remove build/nginx-X.Y.Z/objs/Makefile (build_dynamic/nginx-X.Y.Z/objs/Makefile for a dynamic module, with X.Y.Z from nginx_version), then run sh test.sh without ONLY_BUILD_NGX_MRUBY; use BUILD_DYNAMIC_MODULE=1 sh test.sh for the dynamic build. This regenerates nginx’s configuration and recompiles with the counters before an incremental run. A fresh test build needs no extra step.
  • Nginx::Async::HTTP.sub_request returns the response of the subrequest, an Nginx::Async::HTTP::Response with the same status, headers and body as Nginx::Async::HTTP.last_response; on 2.x it returns nil (#722)
  • Scripts can use the additions of mruby 3.4, 4.0 and 4.1: pattern matching (case/in), with strings as patterns since 4.1, Array#rfind, trailing commas in method parameters, &nil in method parameters, and it for the first parameter of a block ([1, 2].map { it * 2 } is [2, 4]) (#561, #678)
  • Scripts can call methods that mruby 3.3.0 does not have, for example Kernel#public_send, String#b, Hash#slice!, Array#fetch_values, Integer#bit_length, Integer.sqrt and Module#private_instance_methods. mruby 4.1 adds String#scrub. mruby’s lists of user-visible changes (doc/mruby3.4.md, doc/mruby4.0.md, NEWS.md) name more (#561, #678)
  • Dir.children and Dir#each_child list the entries of a directory without . and .., as in CRuby, and Dir.empty? tells whether a directory has no entries (#559, #561). ngx_mruby 2.x took Dir from iij/mruby-dir, which has none of the three methods. Dir now comes from mruby’s core gem mruby-dir (see Class and Method), and with the bundled mruby the two methods leave out . and .. (since mruby 3.4, mruby/mruby#6265). With mruby 3.3.0, which no release of ngx_mruby combined with mruby-dir, they were aliases of Dir.entries and Dir#each and included . and ..; the test suite of ngx_mruby saw the change (test/t/cases/gem_dir.rb). A script written for such a build that skipped . and .. after these calls can drop that code, or keep using Dir.entries. Dir also includes Enumerable, which iij/mruby-dir does not, so Dir.open(path) { |d| d.select { |name| name.end_with?(".txt") } } works; Dir.open with a block closes the Dir when the block ends.
  • Process.clock_gettime and Process.clock_getres with Process::CLOCK_REALTIME, CLOCK_MONOTONIC, CLOCK_PROCESS_CPUTIME_ID and CLOCK_THREAD_CPUTIME_ID, Process.times (a Process::Tms), and Process.wait and Process.wait2, from mruby’s core gem mruby-process, which replaces iij/mruby-process; Signal.list and Signal.signame from mruby-signal, which mruby-process depends on (#766)
  • ENV includes Enumerable and has each, to_h, select, reject, slice, empty?, length, key, has_value?, assoc, rassoc, replace and update, from mruby’s core gem mruby-env, which replaces iij/mruby-env (#766)
  • mruby_variable $name [value]; in the http block declares a variable for scripts to assign with Nginx::Var, without a set that runs in the request. A set at the server level runs after the server rewrite handler and overwrites the value that the handler assigned; mruby_variable runs in no phase of the request. Until a script or a set assigns the variable in a request, it reads as value, which may contain variables, or as the empty string without one. nginx computes value when the request first reads the variable, not in a phase as set does, and keeps it for the request, which subrequests share: with "$request_time" as value, an access_log that alone reads the variable writes the time of the whole request, and a server rewrite handler that reads it first fixes 0.000 for the rest of the request; "$upstream_addr" gives the upstream’s address to a log_format, where set assigns the empty string, because no upstream is chosen yet in the rewrite phase. nginx -t refuses a name that nginx or another module defines with a value of its own, such as $uri, $args, $http_NAME or a variable of map; see mruby_variable (#780)
  • Nginx::Request#store returns a Hash that is the same object in every handler and filter of a request, so that a handler passes values to a later handler of the same request without an nginx variable. The first call creates it, empty. It stays after an internal redirect (error_page, try_files, a named location, Nginx.redirect with a local URI) and until nginx frees the request, after the log handlers. A subrequest gets an empty store of its own. A request whose handlers do not call the method allocates nothing for it; see Nginx::Request#store (#832)
  • Dir.foreach with a block closes the Dir that it opened. With iij/mruby-dir of 2.x, that Dir kept a file descriptor of the worker open until the GC freed it (#559)
  • When mrb_open() fails while nginx reads the configuration, the http module logs ngx_mruby: mrb_open() failed and the stream module ngx_mruby-stream-module: mrb_open() failed at the emerg level, followed by : <class> raised while initializing mruby when the initialization of mruby or of a gem raised an exception. nginx stops as before; ngx_mruby 2.x logged no line of its own (#559)
  • A handler that calls Nginx::Async.sleep several times keeps one timer and one cleanup in the request pool instead of one of each per call. An HTTP handler that never waits no longer stores its fiber in the GC root holder or adds a cleanup, and a stream handler that never sleeps no longer adds a cleanup; the fiber is stored at its first wait. The compiled code of a handler is prepared once, when it is compiled or loaded, instead of on every run. Nginx::Async.sleep, Nginx::Stream::Async.sleep and Nginx::Async::HTTP.sub_request add their cleanup and check each allocation before they arm the timer or post the subrequest, so that a failed allocation raises a RuntimeError with nothing armed (#714)
  • When a handler writes its response with Nginx.rputs in a location with mruby_output_body_filter or mruby_output_body_filter_code, and nginx cannot send the response in one write (for example with limit_rate or sendfile_max_chunk, or to a client that reads slowly), nginx now sends the rest of the response, also when the handler set the status of the output before or after it. Before, the client received the header with the full Content-Length and only the part of the body that the first write sent, and nginx closed the connection when send_timeout passed (#784, #785)
  • In a build with --with-debug, a script that redefines backtrace on an exception class so that it returns elements that are not Strings no longer makes the logging of the backtrace read those elements as Strings, which was undefined behavior: such an element is skipped, and the Strings of the backtrace are logged as before (#796)
  • When a script redefines inspect or backtrace of an exception class so that they raise, and the handler that raised the exception runs inside another mruby call (for example in the location that Nginx.redirect runs from an mruby_set handler), the exception of inspect or backtrace stops in the logging of the exception, as an exception of a resumed fiber stops in ngx_mrb_fiber_resume. Before, it went to the outer mruby call past the nginx functions between the two calls: nginx did not finish the request, the client waited for the response until it gave up, and error.log had the exception of inspect or backtrace, logged by the outer call, instead of the exception of the handler. A backtrace that raises is logged, in a build with --with-debug, as a backtrace that is not an Array (#799)
  • Extend the UDP session tests with single-datagram controls around the multi-datagram case, consecutive sleeps, exact binary proxy payloads and bounded shutdown. CRuby helpers use the staged suite path, including when TEST_SH_PORT_OFFSET moves the ports. These tests cover the existing next implementation; no runtime code changes.

  • Add normal TCP sleep coverage to the default soak and callgrind comparisons. The shared client requires exact bytes and EOF within a total deadline; the soak checks active and released stream counters and collects the stream VM before RSS samples. The callgrind window requires exactly one stream fiber start per measured session.

  • New regression case: test/t/cases/head_body_filter.rb sends HEAD and then GET on one TCP connection, covering both output origins, an empty replacement and ordinary HEAD/GET controls. Its raw helper uses the suite path so the same cases run with TEST_SH_PORT_OFFSET.

  • New test case: test/t/cases/head_header_filter.rb sends HEAD, or a GET control, and then GET on one TCP connection, with the helper of head_body_filter.rb, to new locations of the server on port 18112: a header filter alone on a response of return and on a static file, and a body filter on a listing of autoindex, which has no Content-Length (#848). A location of the same server sends the listing at 50 bytes a second (limit_rate 50, send_timeout 3s), so that the header of the HEAD response needs more than one write (#856).

  • New test case: test/t/cases/header_only_keepalive.rb sends a GET that nginx answers with 304 (If-Modified-Since to a static file with if_modified_since before) or 204 (return 204;), through a header filter alone and through a body filter, and then GET on the same TCP connection, to new locations of the server on port 18112; one of them reads its file through an output buffer smaller than the file, with send_timeout 3s, so that a body filter that keeps the dropped buffer of a 304 or HEAD response fails the case within seconds. test/t/cases/_head_filter_client.rb takes request header lines as an optional third argument, and ends the first response at its header for 204 and 304 as for HEAD (#849).

  • test/t/cases/async_sleep_many.rb checks that one HTTP content handler sleeps 1,000 times for 1 ms, answers 200 with slept:1000, and restores the timers and gc_root_fibers counters. Its server uses port 18188 and each request has a 60-second limit. test.sh enables Nginx::Debug for these assertions; reconfigure an existing test build as described in “The integration test build enables Nginx::Debug” above before using ONLY_BUILD_NGX_MRUBY=1. The default build.sh build is unchanged.

  • The Markdown link check accepts explicit HTML anchors, so a renamed heading can retain its existing links.

  • The index pages of the site (/, /ja/, /v2/, /v2/ja/) show a strip of development-practice badges below the hero, or below the page title on the 2.x pages: the workflows test, nginx-tests (3.x pages only), valgrind-nightly, CodeQL and zizmor of the branch that the page describes, OpenSSF Best Practices and the MIT license. The status line of the home pages names the newest stable release with a badge that the build draws from the git tags, and the GitHub link of the header shows the repository’s star count, which the site workflow reads from the GitHub API before the build. The site checks verify the links, image URLs, sizes and alt text of the strip, the release badge and the star count, and in a browser at 1440px and 402px, in light and dark, the size and position of each badge, the keyboard order, and that the strip keeps its box when the external images fail. The checks before the deploy serve local stand-ins at the external badge URLs, so they never wait on GitHub or bestpractices.dev; the check after the deploy fetches the real images, with retries (#687, #718, #725).

  • Pull requests to next do not run the site workflow site.yml. It runs on every push to next and on a dispatch: it builds the site from a fresh clone and again with the network blocked, builds the 2.x pages from master, runs the checks that need no browser, publishes the site and checks the published site. The browser checks of the site run locally only: npm run check:ci in site/ runs the checks of the build job of site.yml and then every browser check on every page, in Chromium and WebKit, with Japanese text in the served Noto Sans JP, and the author of a pull request quotes it. When the base of a pull request moves, CI runs again only when both the pull request and the new commits of the base change the code or the tests (condition 2 of “Review and merge” in AGENTS.md; “Site CI” in docs/test/README.md) (#677, #737).

  • The site workflow checks initial Copy controls and Japanese maintenance-entry line layout, and records desktop/mobile reader journeys. After a successful production deployment, read-only checks compare the same-run artifact and deployment SHA, verify the public branch policy and live HTML/HTTPS/Lighthouse, and retain a small set of actual public-page screenshots. A PR-only preview can inspect the stable-entry candidate; production always builds stable docs from master (#672).

  • After a deploy, the check of the published site (site/scripts/screenshots-live.mjs in the verify-live job of site.yml) no longer fails on the short burst of 503 answers that GitHub Pages gives right after a deploy. When the only errors of a browser context are 5xx answers of the site and failed requests of the same URLs, it fetches those URLs until they answer 200, at most 240 seconds in a run, and checks that context again, once; every other error still fails at once, and each retry is printed and recorded in evidence.json. site/scripts/test-screenshots-live.mjs, which npm run check:ci runs, checks the retry against a proxy that answers 503 or 404 (#836).

  • The installation guide integrates the corrected 2.x build/install lifecycle from #660 while selecting the next development branch, retaining v3 core-gem and lock-file contracts. English/Japanese examples use the same commands; a fresh development build and loopback HTTP trial are recorded with their revision and limits.

  • The site exports version-specific Markdown pages and a JSON documentation index from the same source as HTML, with language, source revision/hash and dirty-preview metadata. Full-body, source and fallback-link checks cover both release lines; display word breaks and SVG are omitted while literal code, tested sample bytes and diagram provenance remain. This does not make a development API stable or certify historical examples as current measurements.

  • The English and Japanese site home pages present the tested nginx configuration, Ruby handler and HTTP exchange together, with a homepage palette and responsive layout. The site checks cover its colors, text scale and shared code highlighting; the rebrand preview extends the navy/graphite surfaces and copper accents to documentation pages.

  • build_config.rb.lock records mruby 4.1.0 (version: 4.1.0, release_no: 40100, written by rake for 4.1.0-rc2, #678) and no longer has an entry for luisbebop/mruby-polarssl, which the test build no longer clones (#561)

  • The lock pins matsumotory/mruby-uname, in the host and the test build, to 50031c81b101f44e89bf482f5c31213b6c07af36 on the gem’s master (branch: master): the merge commit of matsumotory/mruby-uname#1, which declares the instances of Uname as data objects (MRB_SET_INSTANCE_TT(uname, MRB_TT_DATA)). Its tree is that of the fix commit c82f8a6, and a build no longer depends on the gem’s branch mruby-4 (#561)

  • The test client (the test build of build_config.rb) is built with NO_SSL (ENV['NO_SSL'] ||= '1'), because matsumotory/mruby-simplehttp depends on mruby-polarssl unless NO_SSL is set, and luisbebop/mruby-polarssl depends on mruby-print. SimpleHttp and HttpRequest of the test client cannot send https requests; the tests send HTTPS with curl -k and openssl s_client (docs/test/README.md). rake loads the gems of all builds in one process, so NO_SSL also reaches a host build of your own that has mruby-simplehttp (#561)

  • The default build makes 14 clones (8 in mruby/build/repos/host, 6 in mruby/build/repos/test, about 8.5 MiB), and the build script of matsumotory/mruby-redis clones the hiredis tag v1.5.0 into mruby/build/host/mrbgems/mruby-redis/hiredis-v1.5.0; luisbebop/mruby-polarssl with its submodule ARMmbed/mbedtls, mruby/mgem-list, iij/mruby-env, iij/mruby-process, matsumotory/mruby-vedis with symisc/vedis, matsumotory/mruby-localmemcache, iij/mruby-digest and monochromegane/mruby-secure-random are no longer cloned (#561, #606, #766, #771)

  • build_config.rb.lock has no entries for iij/mruby-env (host and test builds), iij/mruby-process, matsumotory/mruby-vedis and matsumotory/mruby-localmemcache, which the default build no longer takes (#766)

  • build_config.rb.lock has no entries for iij/mruby-digest and monochromegane/mruby-secure-random, which the default build no longer takes (#771)

  • CI builds OpenSSL 3.5.9 in every cell of the build matrix of test.yml, in place of 1.1.1w: it installs it into /usr/local, and the cells with --with-openssl-src build it into nginx as well. configure reads the version of an OpenSSL 3 source tree from VERSION.dat, where it stopped with Can't find openssl version information, and the OpenSSL that ngx_mruby builds for --with-openssl-src installs its libraries into lib; an OpenSSL 3 is built with build_sw, then installed with install_sw without parallel jobs, because the two goals in one parallel make compiled the same objects twice at the same time. With --with-openssl-src, configure gives the mruby build the headers and the libraries of that OpenSSL (NGX_MRUBY_CFLAGS and NGX_MRUBY_LDFLAGS), so that the gems of mrbgems/ do not take those of the system; on macOS, it also looks for the OpenSSL of Homebrew under /opt/homebrew/opt/openssl (#771)

  • New test case and the port of its server: test/t/cases/gem_digest_secure_random.rb (Digest, Digest::HMAC and SecureRandom, 18196) (#771)

  • The default build includes matsumotory/mruby-redis again, as the default build of 2.7.2 does (“Redis is in the default build again” in the 2.7.2 notes, #604). The lock pins it, in the host build, to 8d939104923bc86bb16d2c203d91e22bfa3196df on the gem’s master (branch: master): the merge commit of matsumotory/mruby-redis#109, which keeps the connection of Redis.connect_set_udptr in the mrb_state instead of mrb->ud (“Redis.connect_set_udptr and Redis.new without arguments keep the connection in the mrb_state” in the 2.7.2 notes). From matsumotory/mruby-redis#108, the build of that commit clones the hiredis tag v1.5.0, checks its commit 5bb7f030f6631b243438cf0fdd3be84352b905bb and builds it with USE_WERROR=0, and the gem declares Redis#ttl with one argument: mruby 4.0.0 checks the argument count of a C method against its declaration, and with the gem’s earlier declaration r.ttl "key" raised ArgumentError. The lock also pins matsumotory/mruby-pointer, which mruby-redis depends on and which adds no class, to 8b46506dfdb12a79a16be1d1172ef3c9324bef96 on its master (#606)

  • mruby/ holds the tree of the mruby tag 4.1.0-rc2 (commit c17ffcc24190), merged as a subtree squash that records git-subtree-split: c17ffcc24190b71682bc611fa80053bb252ad482, so the next update-mruby-subtree merges from that commit. docs/DEVELOPMENT.md describes how to finish an update-mruby-subtree that stops with conflicts under mruby/: replace the subtree with the exact tree of the ref with git read-tree, check that git write-tree --prefix=mruby/ and git rev-parse REF^{tree} print the same id, and commit the merge alone, with the build changes in the commits that follow (#561, #678)

  • mruby/mrbgems/mruby-compiler/lib/prism holds 48 files of ruby/prism at the commit c0e37816e97e that mruby 4.1.0-rc2 names for its submodule there: src/, include/, config.yml, the templates that the build renders with templates/template.rb, and LICENSE.md. A checkout or a source archive of ngx_mruby therefore builds without fetching the submodule. The new script vendor-mruby-prism writes them after the merge commit of an mruby update and stops unless each file is the blob of that commit (docs/DEVELOPMENT.md, “Prism”). The build of mruby needs Ruby, which it needed before, to render the templates (#678)

  • NGX_MRUBY_ALLOW_MISSING_CORE_GEMS=1 in the environment of the mruby build skips, with a notice, the names in NGX_MRUBY_CORE_GEMS that the mruby being built does not have, where the build would otherwise stop. It is meant for the time of an update of the bundled mruby (docs/DEVELOPMENT.md) (#559)

  • The memory soak test: sh test/soak/run.sh builds ngx_mruby in build_soak/ with -DNGX_MRUBY_DEBUG_STATS, which adds the class Nginx::Debug (Nginx::Debug.gc, and Nginx::Debug.stats with the GC registrations that ngx_mruby counts), and runs its scenarios against it. It listens on 12360 and 12361, and starts a mock LLM upstream on 12362 for the agent proxy scenarios. The default build of build.sh does not have Nginx::Debug; test.sh enables it for the integration suite. The soak job of CI runs the test, and on next the required check ci-ok needs that job (“Soak test for memory” in docs/test/README.md) (#542, #554, #557)

  • The performance comparison: sh test/perf/compare.sh BASE_DIR builds the checkout in BASE_DIR and this checkout in build_perf/, and compares the instructions per request that callgrind counts in each scenario. It listens on 12370 and 12371, and starts the mock LLM upstream on 12372. The perf job of CI runs it for pull requests that change an input of the measured binary, the measurement or the workflow (“Performance comparison with callgrind” in docs/test/README.md) (#549, #554)

  • The agent proxy tests: test/t/cases/agent_proxy.rb sends requests to the agent proxy recipes of test/conf/conf.d/60-agent-proxy.conf on port 18132, with a mock LLM upstream (test/soak/mock_llm.rb) that test/t/cases/_agent_proxy_client.rb starts on 12372 and 12373 (“Mock LLM upstream” in docs/test/README.md) (#554)

  • The mock LLM upstream test/soak/mock_llm.rb also answers POST /v1/responses as the OpenAI Responses API does, with and without a stream. A stream ends with response.completed, response.incomplete or response.failed, chosen with --terminal or the request header x-mock-terminal. The perf lane measures responses_stream_plain_50 in its default set and responses_stream_plain_1000 when PERF_SCENARIOS names it, the soak test runs agent_responses_stream, and test/t/cases/agent_proxy.rb checks its recipes on /v1/responses as well. No port is added (“Mock LLM upstream” in docs/test/README.md) (#600)

  • New test cases and the ports of their servers: test/t/cases/gem_dir.rb (Dir, 18127) and test/t/cases/gem_uname.rb (mruby-uname, 18128) (#559), test/t/cases/config_time_log.rb (the messages logged while nginx reads the configuration, 18140) (#565), test/t/cases/return_in_block.rb (a return inside a block or a for body of handler code, 18117) (#584), test/t/cases/var_method_lookup.rb (the accessors of Nginx::Var and the methods that read variables, 18159) (#610), test/t/cases/home_example.rb (the example of the home page of the site, 18160) (#617), and test/t/cases/guides.rb (the samples of the guides and use cases of the site, 18161 to 18168 and the stream port 12364) (#619), and test/t/cases/gem_env_process.rb (ENV, Process, Signal, sleep and exit in a handler, and that Vedis and Cache are not defined, 18118) (#766)

  • dependence/ngx_devel_kit/ holds the tree of the ngx_devel_kit tag v0.3.4 (commit bd44d1630), with the one change of ngx_mruby kept: in src/ndk_set_var.c, an NGX_DONE that the variable handler of mruby_set returns becomes the status of nginx’s script engine. The tree was merged with update-devkit-subtree v0.3.4 as a subtree squash that records git-subtree-split: bd44d16302273052d6005d7bdb55f74e23813de3, so the next update-devkit-subtree merges from that commit. The tree before was the tag v0.3.1 (a22dade76), whose src/ndk.h said 0.2.15. ngx_mruby enables only the set_var part of NDK (have=NDK_SET_VAR in config.in). Of the files that such a build compiles, the commits since v0.3.1 change only src/ndk.h and src/ndk_string_util.h, in lines that produce no machine code: the version macros of src/ndk.h are used nowhere, NDK’s config always defines NDK, so the removed #error never applied, and ndk_memcpyp is a macro whose only user, src/ndk_conf_file.c, is not compiled. The commits fix the argument that ndk_conf_set_http_complex_path_slot passes to its post handler and the size that ndk_memcpyp copies, correct the type in the size of the bucket array that ndk_upstream_list allocates (the number of bytes stays the same), remove the #error that src/ndk.h raised in a build without NDK, and set NDK_VERSION to “0.3.4”. A build that also adds a module which enables those parts of NDK compiles the fixed code (#597)

  • nginx’s own test suite: sh test/nginx-tests/run.sh runs nginx-tests at a pinned commit with prove on nginx built with ngx_mruby by test.sh and on nginx of the same version and configure options without ngx_mruby, and writes the counts of both builds and the test files that fail on each to build_nginxtests/summary.md. It needs Linux, a user other than root and perl, and the test files listen on ports from 8000 to 8999. TEST_SH_SKIP_TESTS=1 sh test.sh stops after the build and the install. The nginx-tests workflow of CI runs it on pull requests to next that change the nginx binary, test.sh or the runner; the required check ci-ok does not need it (“nginx’s own test suite (nginx-tests)” in docs/test/README.md) (#602)

  • The memory soak test also checks Nginx::Debug itself: in each scenario of test/soak/nginx.conf it requests the new location /debug/check once before the warmup, and the scenario fails unless Nginx::Debug.stats has the documented keys with Integer values, Nginx::Debug.gc returns nil, and the full GC of Nginx::Debug.gc frees the objects that nothing references (“Soak test for memory” in docs/test/README.md) (#605)

  • gc_root and gc_root_fibers of Nginx::Debug.stats in the soak build count the objects that ngx_mruby keeps from the GC: the holder of each mrb_state, which is registered with mrb_gc_register() once, and the fibers stored in it. ngx_mruby no longer calls mrb_gc_register() and mrb_gc_unregister() for each fiber of a handler; it stores the fiber in the holder and frees the slot when the fiber ends (“The soak build and Nginx::Debug” in docs/test/README.md) (#682). In the stream module, each fiber of a session has its own slot and its own connection pool cleanup (ngx_stream_mrb_fiber_t), so that a second fiber of a UDP session, started by a second datagram while the first fiber sleeps, is kept from the GC as well, as 2.7.3 keeps it with a GC registration of its own (#698)

  • The example of the start page of the site: examples/start/ holds a compose.yaml and a Dockerfile that build nginx with ngx_mruby from the checkout, with an nginx.conf and a Ruby script, and its README.md is the page /start/. The examples workflow of CI runs the commands of that README in order with examples/check_example.py and compares their output with what the README states, on pull requests to next that change examples/, the workflow or the inputs of the build (src/, mrbgems/, mruby/, dependence/, build.sh, build_config.rb, build_config.rb.lock, nginx_version, configure, config.in, Makefile.in); the required check ci-ok does not need it (#618)

  • test/t/cases/agent_proxy.rb reads the values that it compares for the recipes of the Messages API from test/html/agent_proxy_auth.expected, agent_proxy_route.expected, agent_proxy_limit.expected and agent_proxy_log.expected, one key=value per line, or key~=text for a value that contains the text, which the agent proxy page of the site shows; test/t/cases/_agent_proxy_client.rb takes the port of nginx as an optional third argument (#622)

  • test.sh stops only the nginx that it started, by its pid. It no longer runs killall nginx (pkill nginx on NetBSD, FreeBSD and CentOS) before it starts the test nginx, which stopped every nginx on the machine. Before the start, it stops the nginx that an earlier run in the same build directory left running, by the pid in logs/nginx.pid, when that process runs the sbin/nginx of this build. When it exits, also after a failure and on SIGHUP, SIGINT or SIGTERM (once the command that runs at that moment, such as the wait for nginx or the current test file, has ended), it sends SIGTERM to the test nginx and sends it again 1, 3, 7, 15 and 31 seconds later while the process still runs, because a single nginx process can miss a SIGTERM that arrives right before it waits for events; after NGINX_STOPTIME seconds (default 60) it sends SIGKILL and exits 1. Before each signal, it checks that the pid still runs the sbin/nginx of this build, so a pid that another process took after nginx ended gets no signal. test/t/cases/_second_instance.rb sends the SIGQUIT to its nginx again in the same way (“Stopping nginx” in docs/test/README.md) (#635)

  • TEST_SH_PORT_OFFSET=N (an integer from -2345 to 47336, default 0) moves every port of the test suite by N, so that two checkouts can run test.sh at the same time on one machine, each with its own offset. The ports of the suite are the numbers from 12345 to 12399 and from 18080 to 18199 in test/t, test/conf, test/html and the two files of test/soak that the agent proxy tests load. test.sh copies these files with the new script test/t/cases/_stage.rb to build/nginx/harness/test/, moving each such number written as five digits by N, and installs the configuration and the hook scripts and runs the tests from that copy; the tests run the CRuby helpers of the copy through the new method suite_path of test/t/cases/_prelude.rb. With offset 0 the copy is the same as the source. _stage.rb fails for such a number written with an underscore and for an offset that would move a port out of 10000 to 65535 (“Ports” in docs/test/README.md) (#641)

  • The message that test.sh prints when it sends SIGKILL to the test nginx appears only when it sent the signal: when the pid no longer runs this build’s nginx at that moment, the stop ends without the signal and counts as ended, so test.sh keeps the exit status of the tests. Before, it printed that it sent SIGKILL, and test.sh exited 1; at the start, the stop of the nginx left by an earlier run ended the run (#641)

  • valgrind fails the CI cell that runs nginx under it: such a cell runs nginx with valgrind --error-exitcode=99 --leak-check=full --errors-for-leak-kinds=definite,indirect and the suppressions of the new file test/valgrind.supp, and its step “Check the valgrind reports” fails the cell when the ERROR SUMMARY of a valgrind log counts an error: a memory error, or a definitely or indirectly lost block that the file does not suppress. The file suppresses the environment array that nginx leaves allocated at exit (ngx_set_environment(), 8 bytes). Possibly lost blocks are printed but are not errors. In a run that starts the build matrix, one cell (nginx 1.31.8, static module) runs nginx under valgrind, and the other cells without a sanitizer run it directly. A manual run of test.yml with the new input valgrind runs every cell except the sanitizer cell under valgrind; the new workflow valgrind-nightly.yml starts such a run every day from its copy on master, the default branch (#674). test.sh still does not take valgrind’s errors into its exit status (“valgrind in CI” in docs/test/README.md) (#634)

  • The site is deployed: the job deploy of .github/workflows/site.yml publishes the site that the job build built and checked to GitHub Pages at https://ngx.mruby.org/, on a push to next and on a workflow_dispatch on next, never for a pull request. It uses actions/configure-pages, actions/upload-pages-artifact and actions/deploy-pages, pinned by commit, with the permissions pages: write and id-token: write only, and stops unless the Pages settings give the origin https://ngx.mruby.org. The site serves the Google verification file googleba3435e4002729b6.html of the old site at the same URL and loads no analytics script, which site/scripts/check-deploy.mjs checks on every run; site/scripts/check-live.mjs checks the live site after a deployment, by hand (“The site” in AGENTS.md) (#653)

  • The site builds the documentation of 2.x under /v2/ from docs/ of master: node site/scripts/build-v2.mjs --tree DIR (npm run build:v2 in site/), after npm run build, writes the 2.x pages into site/dist/v2/ with a search index of their own, and site/scripts/check-v2.mjs checks the 2.x banner on every 2.x page, the version links between /v2/ and /docs/, and that the search of each version shows only its own pages. The site workflow checks out master and builds /v2/ on every run. The site-v2 workflow runs on “Run workflow” to build and check the 2.x pages of the selected branch, and the site-dispatch workflow starts the site workflow on next after every push to master (#657, #656)

  • CI runs only the jobs that a change needs. The new script test/ci/changes.sh sorts the files of a change (a renamed file with its old and its new path) into the categories code, tests, docs, site, examples and workflows, a file of no category counting as code, and the workflows read it. In a ready pull request, a change of the code runs four cells of the build matrix of test.yml (the entry of #702 below), soak and perf; a change of test/, test.sh or test.yml alone runs the same four cells, and soak or the comparison of perf only when their own files changed; any other change runs none of them, and the job changes of test.yml decides. A draft pull request runs no CI: test.yml names its job ci-ok (draft) instead of the required ci-ok, the other workflows skip their jobs, and marking the pull request ready for review starts the run. A push to master or next runs no build or test job, only the deploy of the site and the scans of CodeQL; nginx-tests, examples and zizmor run on pull requests only. A push of a tag and “Run workflow” run the whole matrix and soak (perf runs on pull requests only), and “Run workflow” with the new input base decides as for a pull request against that branch, with the result ci-ok (dry run); any other “Run workflow” reports ci-ok (manual), so that only the run of a pull request or a push gives the required ci-ok. ci-ok counts a skipped job as passed only when changes decided to skip it. The run of every cell under valgrind is nightly only: valgrind-nightly.yml no longer runs on pull requests, its run names the job ci-ok (valgrind), and it reads the result of the run with retries, so that a failed call of the API does not fail the job. The new workflow codeql.yml runs CodeQL for C and C++ (without a build), Ruby and the workflows on ready pull requests and pushes to master and next that change src/, mrbgems/ or .github/workflows/, and weekly, in place of GitHub’s default setup (“Which jobs a run starts” and “CodeQL” in docs/test/README.md) (#676, #685, #686)

  • CI: a cancelled run reports no result for ci-ok, where it reported a failure. CodeQL leaves out the vendored trees mruby/ and dependence/ (.github/codeql/codeql-config.yml), and the alerts on them were dismissed as vendored upstream code. AGENTS.md and docs/test/README.md say that CI is the final check in a clean environment and that the author runs the checks that a change touches locally before the pull request is marked ready (#692)

  • The performance comparison applies the accepted differences of the new file test/perf/accepted.txt. A line names a condition (mruby-version: the MAJOR.MINOR of the bundled mruby in the base and in the head), a scenario, and an allowance on the change of Ir per request without GC, in percent. When both builds match a line, a WARN or FAIL row of its scenario within the allowance shows as ok (accepted: ...) and does not fail the run; a change above the allowance keeps its WARN or FAIL. The first line accepts auth up to +8% from mruby 4.0 to 4.1, the difference accepted on #678, so that a comparison with a base on next from before #678 does not report it as FAIL. No line covers mruby 3.3 (2.7.2) against 4.1. The report prints the mruby version of both builds and the accepted differences that applied, and PERF_ACCEPTED_FILE names another file (“Known differences” in docs/test/README.md) (#696)

  • CI: a ready pull request that changes the code or the tests runs four cells of the build matrix of test.yml, not every cell (the 8 combinations of nginx version, link mode and --with-openssl-src, and the sanitizer cell). The four cells are nginx 1.31.8 with the static module and --with-openssl-src, nginx 1.30.6 with the dynamic module, the sanitizer cell (AddressSanitizer and UndefinedBehaviorSanitizer) and the cell under valgrind; the last two build nginx 1.31.8 with the static module. Every cell, and soak, runs in the nightly run under valgrind, on the push of a tag, on a pull request with the new label full-matrix (the check pull request before a tag), and on “Run workflow” without the input base or with the input valgrind. A push to a v*.x branch runs no build, as a push to master or next does not. test/ci/changes.sh takes the run as options (--label, --draft, --push, --tag, --dispatch, --valgrind) and gives build standard, full or none (“Which jobs a run starts” in docs/test/README.md) (#702)

  • The test suite runs nginx with a master process and several worker processes, and reloads it. test/t/cases/workers.rb runs the CRuby helper test/t/cases/_workers.rb through the prelude helper workers_nginx. The helper starts nginx with master_process on from a configuration of test/conf/workers/, with four workers on port 18180 or two workers on 18181 and the stream port 12379, sends requests that reach every worker, reloads nginx with SIGHUP while an Nginx::Async.sleep and an Nginx::Stream::Async.sleep are in flight, and stops the master and every worker, the master by the pid of its pid file. The case asserts that each worker answers from an mrb_state of its own that its requests share; that after the reload the new configuration and script answer while the old workers finish the two sleeps and then end; and that the error log has no line at the level error or above, no sanitizer report and, under valgrind, no error in the report of any process. The test nginx of test.sh stays a single process (“Several workers and reloads” in docs/test/README.md). test/valgrind.supp suppresses the connection and event arrays that nginx allocates in ngx_event_process_init() of a worker process and never frees, which valgrind reports as lost when such a worker ends on SIGTERM on x86-64 (#706)

  • Nginx::Debug.stats of the soak build has stream_timers (the Nginx::Stream::Async.sleep timers that are pending) and stream_fibers (the stream fibers kept in the GC root holder), next to timers of the http module (#714)

  • The merge of the 2.x changes adds the regression cases of test/t/cases/async_rewrite_declined.rb and its server on port 18187 (#740). The existing v3 handler implementation already preserves the status after a resumed decline. site-v2.yml now runs only on “Run workflow”; authors check the 2.x pages locally before a PR is ready, and a push to master still starts the site build on next (#739).

  • New test case: test/t/cases/output_value_to_s.rb, with the server of test/conf/conf.d/88-output-value-to-s.conf on port 18191 (#776)

  • New test case: test/t/cases/mruby_variable.rb, with the server of test/conf/conf.d/89-mruby-variable.conf on port 18171 (#780)

  • New test case: test/t/cases/request_store.rb, with the server of test/conf/conf.d/99-request-store.conf on port 18094 (#832)

  • New test case: test/t/cases/var_assign.rb, with the server of test/conf/conf.d/99-var-assign.conf on port 18107: the assignments of Nginx::Var#<name>=, Nginx::Var#set and mruby_set give a variable the same value, and an assignment that nginx cannot take raises (#854)

  • New test cases: test/t/cases/body_filter_split_write.rb, with the server of test/conf/conf.d/89-body-filter-split-write.conf on port 18141, from the merge of the 2.x changes (#784), and test/t/cases/body_filter_split_write_status.rb, with the server of test/conf/conf.d/90-body-filter-split-write-status.conf on port 18142, for output sent with a status that the handler set before or after it (#785)

  • CI builds and tests nginx 1.31.8 and 1.30.6 only: the full build matrix of test.yml, which the nightly run, the push of a tag, the check pull request before a tag and “Run workflow” without the input base use, no longer has the cells of nginx 1.28.3 and 1.26.3, and has 8 combinations of the nginx version, the module type and --with-openssl-src, and the sanitizer cell (#789)

  • CI: on next, the required check ci-ok of test.yml needs the perf job, so a FAIL or ERROR row of the performance comparison fails it, and a WARN row does not. test/perf/accepted.txt has a second condition, pull-request: its line names the base branch and the number of a pull request (for example pull-request next 812 stream_sleep 7) and applies only in the perf job of that pull request, which passes both to perf.rb in PERF_BASE_REF and PERF_PULL_REQUEST. A pull request adds such a line after the owner has accepted its FAIL in a comment, and the run passes. The comparison judges the Ir per request without the GC and without the constant lookups that miss the constant cache of mruby (w/o GC/const), whose misses depend on where the ireps were allocated and differed between two runs of the same commits on #766. A scenario whose head clears that cache more often than its base (mrb_const_set, mrb_const_remove, mrb_define_const_id, include, prepend, extend), or clears it and misses more lookups than its base, is judged with the lookups counted (w/o GC), and the column judged of the report says which number judged each row. The report prints the misses and the clears per request (const_misses, const_clears) for both builds, and notes a scenario where the Ir of the difference of misses makes half of the WARN threshold or more of the base w/o GC/const (“What it measures” and “In CI” under “Performance comparison with callgrind” in docs/test/README.md) (#794, #795)

  • New test case: test/t/cases/exception_log.rb checks the level and the text of the error.log line of an exception of a content handler (port 18192), of an SSL handshake handler (port 18193), of a stream session (port 12380), of mruby_init_code and of mruby_stream_server_context_code under nginx -t, the backtrace of a stream session in the debug build of test.sh, and the lines for a redefined backtrace that returns elements that are not Strings or no Array. test/t/cases/log_negative_level.rb checks the line of Nginx.log (port 18194) and of Nginx::Stream.log (port 12381) for a negative level. The exit hooks of the nginx of test/t/cases/config_hooks.rb raise after their lines, and a case there checks the line of each exception (#796)

  • New test case: test/t/cases/exception_log_raising_methods.rb checks the line of an exception whose inspect or backtrace raises, in a content handler (port 18198), in a stream session (port 12382) and in the location that Nginx.redirect runs from an mruby_set handler, and that the worker answers the next request (#799)

  • The test nginx of test.sh (test/conf/nginx.conf) has worker_connections 1024 instead of 200. nginx counts each of its 125 listening sockets as a connection, and under valgrind the connections that test.sh opens to every port before the cases used up the rest, so nginx closed the connection of the first request of the suite (#818)

  • New test case: test/t/cases/code_reload.rb, with the server of test/conf/conf.d/98-code-reload.conf on port 18125, sends two requests to a content handler file without cache that sleeps, the second while the first waits, so that the second compiles the code again meanwhile, and checks that both answer with the values of their code and that gc_root of Nginx::Debug.stats is the same afterwards. gc_root now also counts the compiled code of each directive, which the GC root holder keeps for the life of the mrb_state (“The soak build and Nginx::Debug” in docs/test/README.md) (#825)

  • New test case: test/t/cases/stream_duplicate_hooks.rb runs nginx -t on stream configurations that give a hook twice in one context, with a server on port 12398, which nginx -t opens for a moment when it accepts the configuration. The directives with Ruby code of the http and the stream module are rows of a table in their module header, NGX_HTTP_MRUBY_CODE_TABLE and NGX_STREAM_MRUBY_CODE_TABLE: a new directive of such a kind is a row there (“Adding a directive with Ruby code” in docs/DEVELOPMENT.md) (#834).

  • New test case: test/t/cases/filter_inherit.rb checks that output filters given at server level and in a location run in the locations and if blocks below them, with a server on port 18108, and, with the new mode http_filter of the second nginx of test/t/cases/_second_instance.rb (port 18116), a filter in the http {} block and the phase handlers that only mruby_add_handler on or one form of a log handler uses (#835).

  • New test case: test/t/cases/filter_sendfile.rb checks, with the new mode http_sendfile of the second nginx of test/t/cases/_second_instance.rb (port 18116), which has sendfile on and an error log of its own at the debug level, that nginx sends a static file with sendfile and does not read it into memory in a location with an mruby header filter alone, and reads it into memory in a location with an mruby body filter (#847).

  • Rebuild the soak and performance binaries without ONLY_RUN to include stream support. Account for the new sessions, stream_timers and stream_fibers soak columns and the session unit of the stream_sleep performance row.
  • For an existing test.sh build, remove the selected nginx source tree’s objs/Makefile and run the full suite without ONLY_BUILD_NGX_MRUBY, preserving BUILD_DYNAMIC_MODULE=1 for a dynamic module. Fresh test builds and production build.sh builds need no step for the debug counters.

Supported nginx versions: nginx 1.30 (stable) and 1.31 (mainline), raised every April (see README.md). Read the release notes of the 2.x releases newer than the version you run first, then this file. Rebuild the module together with the bundled mruby 4.1.0-rc2; a build_config.rb of your own needs the changes of “A build_config.rb of your own needs the core gem changes of mruby 4.1”. Migrating from ngx_mruby 2.x to 3.0.0 has the steps for finding the scripts and builds that each entry affects. Check these before upgrading:

  • The bundled mruby 4.1.0-rc2: rebuild the module together with it, and check mruby’s lists for the changes that these entries do not cover (#561, #678).

  • A build_config.rb of your own: remove mruby-print, hal-posix-io, hal-posix-dir and hal-posix-socket, decide on mruby-task and mruby-encoding, and with full-core.gembox choose between the core gems mruby-env, mruby-process and mruby-regexp and the third-party gems of the same classes (#561, #678).

  • Ruby: build with Ruby 3.0 or later (#678).

  • nginx: build with nginx 1.30 or 1.31; to keep nginx 1.28 or 1.26, stay on 2.x, which builds with nginx 1.24 only without --with-stream (#789).

  • build_config.rb.lock: nothing for a new checkout or a source archive; to build a gem at another commit, change its entry, and remove mruby/build after a change of the lock (#558).

  • Hash#inspect and Hash#to_s: do not use them as a data format; build the string yourself, or use JSON.generate (#561).

  • Exception#inspect: update log parsers and alerts that match the old form of the mrb_run failed lines (#561).

  • "#@ivar", "#@@cvar" and "#$global": escape the # of such strings that are meant literally, or use single quotes (#678).

  • Syntax errors: match on SyntaxError and the file and line, not on the text of the message (#678).

  • An Array, a Hash or a Struct that holds itself: nothing, unless a script relies on the SystemStackError of the comparison (#678).

  • The messages logged while nginx reads the configuration: to see them, run nginx -t -e stderr, read the startup log after nginx -t, or reload with error_log at info (#565).

  • Nginx.module_version and the mechanism enabled line: where a script or a monitor compares the value with a 2.x version, compare it with 3.0.0 as well; use the tag or the commit of the build to tell the pre-releases of 3.0.0 apart (#823).

  • NoMethodError: match on the exception class, not on the message (#561).

  • private and protected: call such methods without a receiver, or with send; list private methods with private_instance_methods or private_methods (#561, #678).

  • Module#remove_const, #private, #public, #protected, #module_function and the hooks: call them in the body of the class or module without a receiver, or with send (#561).

  • Overrides of append_features, prepend_features and extend_object: move the code to included, prepended or extended (#561).

  • allbits?, anybits? and nobits? on a Float: convert with to_i first (#561).

  • FileTest: nothing for calls of its methods (#561).

  • A constant assigned in a method body: use Object.const_set (or Kernel.const_set) (#561).

  • Bit operations on a Float: convert with to_i first, or compute the old number as the entry says (#561).

  • String#valid_encoding?: drop the call, or build with mruby-encoding and check the scripts (#561).

  • A seeded Random or srand: do not depend on its numbers across versions (#561).

  • Set#inspect, Set#to_s and Set#flatten_merge: do not use the first two as a data format; call s.merge(Set.new(t).flatten) in place of s.flatten_merge(t) (#561).

  • Hash#default_proc=: pass a Proc or nil (#561).

  • yield with keyword arguments: nothing (#561).

  • A return inside a block or a for body of handler code: nothing (#561).

  • A content handler that ends without output: a handler that relied on the 500 sets the status it means, for example Nginx::HTTP_INTERNAL_SERVER_ERROR; log monitoring that matches response body is empty. return NGX_HTTP_INTERNAL_SERVER_ERROR no longer sees such handlers of the main request with no status or a status from 200 to 299 that nginx does not answer by itself (#574).

  • An output body filter that ends with an empty body: nothing (#574).

  • The accessors of Nginx::Var: use v.exist?(name) to tell whether a variable exists, and give the methods of your scripts names that are not names of nginx variables (#610).

  • Nginx::Connection, Nginx::Server and Nginx::Request: to return other values, define the methods on those classes; read variables with Nginx::Var instead of @iv_var (#610).

  • Dir: rescue IOError instead of RuntimeError around a Dir that can be closed; a script for both versions rescues both (#559).

  • ENV: call ENV.to_h in place of ENV.to_hash (#766).

  • Process: start other processes outside nginx instead of fork and system, or run a command with IO.popen; call Process::Status#to_i in place of to_int; keep the pid and the status in variables of your own instead of Process::Status.new (#766).

  • exit in a handler: remove it; to answer with a status, call Nginx.return and let the code run to its end (#766).

  • sleep without an argument: give the seconds, or use Nginx::Async.sleep (#766).

  • Vedis and Cache: keep the data in Redis or a store of your own, or uncomment the gem’s line in build_config.rb (#766).

  • Digest and SecureRandom: build with OpenSSL 3.0 or later; call urlsafe_base64 without n where a script relied on 22 characters, and new where it relied on dup of a digest starting empty; remove a line of iij/mruby-digest or monochromegane/mruby-secure-random from a build_config.rb of your own (#771).

  • C extensions: declare classes that wrap C data with MRB_SET_INSTANCE_TT(klass, MRB_TT_DATA), define C methods with the spec that mrb_get_args reads, use mruby/io.h, mrb_temp_alloc() and MRB_OPEN_FAILURE(), call mrb_open() or mrb_open_core() without an allocator and define mrb_basic_alloc_func() for a custom one, and add mruby/build/host/include to the include path, also in a list given with --with-mruby-incdir (#561, #572).

  • The classes that came with the auto-ssl mrbgem: use pack('m0') and unpack1('m') in place of Base64, ENV['TMPDIR'] || '/tmp' in place of Dir.tmpdir and Dir.mkdir in place of Dir.mktmpdir, or add the gems to a build_config.rb of your own (#556).

  • The auto-ssl mrbgem: get certificates with ngx_http_acme_module, or keep a 2.x build for a server that needs Nginx::SSL::ACME; remove NGX_MRUBY_AUTO_SSL from the build environment (#640).

  • Nginx::Upstream#server= and Nginx::Stream::Connection#upstream_server=: rescue ArgumentError for a string that cannot be a server; a script for both versions rescues ArgumentError and RuntimeError, or StandardError (#680).

  • Nginx::Upstream#server= with a host name: give an IP address that the script has without waiting, with an IPv4 address as four decimal numbers, or write the name in the server line of the upstream {} block and do not call the setter; for a name with more than one address, Nginx::Upstream.new raises for that upstream, so remove that call too (#680).

  • An access or post_read handler that waits in Nginx::Async.sleep: an access handler that should deny the request after the sleep returns Nginx::HTTP_FORBIDDEN or Nginx::HTTP_UNAUTHORIZED (#715).

  • An access or post_read handler that writes output: nothing (#715).

  • A handler that sets no result after an earlier handler returned a value for every request: a content handler or an access handler under satisfy any that should go on returns Nginx::DECLINED itself (#715).

  • An mruby_set handler that waits in Nginx::Async.sleep: code that ended the request with a status after the sleep returns that status from a later handler (#715).

  • A rewrite or server rewrite handler that ends without a result: a handler that should end the request returns the status it means (#720).

  • Nginx::Async::HTTP.sub_request in a content handler after Nginx::Async.sleep: remove a rescue of its RuntimeError (#722).

  • A handler that waits for Nginx::Async::HTTP.sub_request: do the work that counted on the code running again after the call (#722).

  • A UDP stream session whose code sleeps: code that counted on running once for each datagram does not sleep (#727).

  • A stream session that waits when worker_shutdown_timeout expires: keep the sleeps that must finish shorter than the timeout (#727).

  • Nginx::Stream::Connection.proxy_protocol_addr and proxy_protocol_ip: nothing for code that compares the result with a String; code that calls a String method on the result handles nil, for example with to_s.

  • The reads of a stream session on a listen with proxy_protocol during Nginx::Stream::Async.sleep: nothing.

  • Nginx.rputs, Nginx.echo, Nginx.redirect, Nginx::Filter#body= and Nginx::Filter#output with an argument whose to_s does not return a String: pass a String, nil or a value whose to_s returns a String (#776).

  • Nginx.redirect with a local URI: write nothing after the call that is meant for the client, and move code that read what the target set to the target (#728).

  • Nginx::Async::HTTP.sub_request in mruby_set and mruby_set_code: call it in a rewrite or access handler and set the variable there with Nginx::Var#set (#735).

  • An mruby_set value that cannot be converted to a String: return a String from the code (#735).

  • access_log and mruby log handlers: nothing for most configurations; to log the value that a variable had before the log handler, copy it into another variable with set (#770).

  • Nginx.redirect with a local URI in a log handler: call it in a rewrite, access or content handler instead (#770).

  • Output and a status: a handler that relied on nginx’s page for the status, or on the error_page of the location, sets the status without output; one that sets 301, 302, 303, 307 or 308 with output sets Location itself (#779); one that sets a status before its output and means to send the output with 200 calls Nginx.return Nginx::HTTP_OK after the output (#783).

  • Methods that have no effect in a handler: remove the calls that now raise, or move them to a handler where they work, as the table of the entry and “Where the methods work” in docs/class_and_method/README.md say; in a log handler, pass values to access_log through Nginx::Var (#826).

  • Nginx.redirect with a local URI in mruby_set and mruby_set_code handlers and in output filters: call it in a rewrite or access handler instead (#833).

  • An assignment with Nginx::Var#<name>= or Nginx::Var#set to a variable that nginx does not know, does not let scripts change or keeps no value of: declare the variable with set or mruby_variable, do not assign variables such as $uri or $http_host, rescue NameError and RuntimeError where the handler should go on, and match the mrb_run failed line in log monitoring (#854).

  • A stream hook given twice in one context: keep one directive of each hook in a context, the later one, which ran on 2.x, and remove the others (#834).

  • Output filters given at http or server level, or in a location with nested locations or if blocks: check that each can run for every response of the levels below it, and move a filter that should run in some locations only into those locations (#835).

  • A location with an mruby header filter and no body filter: nothing; nginx no longer reads the files of its responses into memory, and the responses are the same (#847).

  • HEAD responses with an mruby output body filter: nothing. To close a connection deliberately, configure nginx’s keep-alive policy rather than relying on this filter error.

  • HEAD responses through an mruby header filter alone, or through an mruby body filter without Content-Length: nothing; to close a connection deliberately, configure nginx’s keep-alive policy (#848).

  • 204 and 304 responses through an mruby output header or body filter: nothing; to close a connection deliberately, configure nginx’s keep-alive policy (#849).