Skip to content

fix(nacos): declare nacos-stream shared dict in the stream subsystem#13541

Open
AlinsRan wants to merge 1 commit into
apache:masterfrom
AlinsRan:fix/nacos-stream-shared-dict
Open

fix(nacos): declare nacos-stream shared dict in the stream subsystem#13541
AlinsRan wants to merge 1 commit into
apache:masterfrom
AlinsRan:fix/nacos-stream-shared-dict

Conversation

@AlinsRan

@AlinsRan AlinsRan commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

TL;DR

Enabling nacos discovery while the stream subsystem is on crashes the stream worker at startup: lua_shared_dict "nacos-stream" not configured.

Cause

nacos selects its shared dict by subsystem (nacos for http, nacos-stream for stream), but nacos-stream is declared nowhere. init_worker() errors out before any network call:

init_worker_by_lua error: .../nacos/init.lua:284: lua_shared_dict "nacos-stream" not configured

Introduced by the refactor in #13201.

Fix

Declare nacos-stream in the stream block of ngx_tpl.lua, mirroring the unconditional nacos dict in the http block.

Test

t/cli/test_discovery_nacos_stream.sh: starts APISIX with proxy_mode: stream + nacos discovery and asserts the stream worker initializes without the error (no nacos server needed — the dict check runs before any network call). Verified locally: passes with the fix, fails (exit 1, with the exact error above) without it.

The bug was missed because it lives in the production ngx_tpl.lua template + the stream init_worker, which the Test::Nginx .t suite bypasses (it uses its own nginx config); only the t/cli tests exercise the real generated config.

Checklist

  • I have explained the need for this PR and the problem it solves
  • I have explained the changes or the new features added to this PR
  • I have added tests corresponding to this change
  • I have updated the documentation to reflect this change (N/A)
  • I have verified that the changes pass the existing tests

@dosubot dosubot Bot added size:XS This PR changes 0-9 lines, ignoring generated files. bug Something isn't working labels Jun 12, 2026
@AlinsRan AlinsRan force-pushed the fix/nacos-stream-shared-dict branch from b5dccbd to 5e9bfe9 Compare June 12, 2026 08:24
The nacos discovery module picks its shared dict by subsystem:

    local dict_name = is_http and "nacos" or "nacos-stream"   -- apisix/discovery/nacos/init.lua:36

and errors out when the dict is missing:

    error('lua_shared_dict "' .. dict_name .. '" not configured')  -- init.lua:284

`nacos` is declared in the http block, but `nacos-stream` is declared
nowhere, so nacos discovery in the stream subsystem fails at init_worker.
Declare `nacos-stream` in the stream block, mirroring the unconditional
`nacos` dict in http.

Signed-off-by: AlinsRan <alinsran@apache.org>
@AlinsRan AlinsRan force-pushed the fix/nacos-stream-shared-dict branch from 5e9bfe9 to 7b275f2 Compare June 12, 2026 08:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working size:XS This PR changes 0-9 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant