]> git.kaiwu.me - njs.git/commit
Fix the runtime model in the agent developer guide
authorDmitry Volyntsev <xeioex@nginx.com>
Thu, 27 Aug 2026 22:32:56 +0000 (15:32 -0700)
committerDmitry Volyntsev <xeioexception@gmail.com>
Fri, 4 Sep 2026 20:58:39 +0000 (13:58 -0700)
commit186c53d0f8430e4b7e775a857d0fefb185a69023
tree999639c9550d19cab3b0af01aaf862028640be0e
parent3b1d9ad314415fecd615bd04f7f466978e60a529
Fix the runtime model in the agent developer guide

The guide claimed that module scope survives between requests on the same
worker and that module imports load once per worker.  Both are wrong.
js_import only compiles at configuration time; imported module bodies run
when a context is created.

While there, corrected the integration points:

*) js_periodic receives a periodic session rather than nothing, and lives
   in server { } for stream;

*) js_filter is installed in the stream filter chain rather than as a
   phase handler, and cannot call s.done() once filtering started;

*) stream js_access and js_preread may leave pending events, while stream
   js_set may not;

*) "no async support" means no pending nginx events rather than no async
   keyword;

*) HTTP has no js_filter directive, stream js_set receives s, and
   ngx.shared is cross-worker rather than process-wide and holds only
   strings and numbers.
docs/agent/js-dev-njs.md
docs/agent/js-dev.md