gRPC outbound clients remain cached and active after core.Instance.Close
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 25/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Stale
- Tech stack
- go, grpc
- Domain
- backend, networking
Research direction
Start in transport/internet/grpc, focusing on globalDialerMap and Handler.Close; the attached reproducer is intended to be saved as transport/internet/grpc/lifetime_repro_test.go. Run go test ./transport/internet/grpc -run '^TestCoreCloseIsolatesGRPCClients$' -count=1 -timeout=90s to confirm the failure. Done means closing one core Instance terminates its gRPC clients and streams while a separate Instance remains usable in both normal and MultiMode cases.
Written by the indexing model from the issue text.
Description
Integrity requirements
- I have read all the comments in the issue template and ensured that this issue meet the requirements.
- I confirm that I have read the documentation, understand the meaning of all the configuration items I wrote, and did not pile up seemingly useful options or default values.
- I provided the complete config and logs, rather than just providing the truncated parts based on my own judgment.
- I searched issues and did not find any similar issues.
- The problem can be successfully reproduced in the latest Release
Description
When Xray is embedded in a process that remains alive after core.Instance.Close(), outbound gRPC ClientConns remain in globalDialerMap and are not closed.
The cache key includes *internet.MemoryStreamConfig, so fresh outbound handlers create distinct entries even for the same destination. Handler.Close() does not close or remove these clients. A retained client in reconnect/backoff can continue dialing after its owning core has stopped.
The attached synthetic test reproduces the lifetime problem on release v26.3.27 and main da2248c516c7493919e049c6ae9725f70821b025. Both normal gRPC and MultiMode are affected.
Each Instance is started only once. No restart of a closed Instance is involved.
Environment: Linux amd64, Go 1.27.2. Only synthetic loopback endpoints are used.
This is an embedding/API lifecycle bug. The attached Go test contains the complete programmatic client configurations and synthetic server, rather than separate CLI JSON files.
release-repro.log
repro_test.go.txt
Reproduction Method
-
Check out Xray-core v26.3.27.
-
Download the attached repro_test.go.txt and save it as:
transport/internet/grpc/lifetime_repro_test.go -
Run:
go test ./transport/internet/grpc -run '^TestCoreCloseIsolatesGRPCClients$' -count=1 -timeout=90s
The test creates two fresh core Instances with the same gRPC endpoint and outbound tag. It verifies that ending one RPC preserves a sibling stream, then closes one Instance.
Expected: the closed Instance's gRPC clients and streams terminate, while the other Instance remains usable.
Actual: the closed Instance's stream remains alive. Both normal and MultiMode subtests fail with:
"core Close left its gRPC stream alive".
The embedding process intentionally stays alive: exiting the CLI process would hide the retained global resources.
Client config
Complete programmatic client configurations are included in the attached repro_test.go.txt, in configuredCoreWithProxy()/configuredCore().The test constructs two core.Config objects, each with an outbound manager and a freedom outbound using the grpc transport. The service name is "lifetime"; MultiMode is tested both disabled and enabled.
There is no separate client JSON file: the core instances are constructed directly through the Go API.
Server config
The complete synthetic server is included in the attached repro_test.go.txt, in syntheticServer() and echoService.It is an in-process grpc.Server listening on 127.0.0.1 with an automatically allocated port. It registers the "lifetime" service with Tun and TunMulti echo streams. No TLS, authentication or external server is involved.
There is no separate server JSON file or Xray server process.
Client log
The complete reproduction command output is attached as release-repro.log in Description. It includes Xray debug output and both failing subtests on v26.3.27.
Server log
Not applicable: the server is the in-process synthetic gRPC echo service defined in the attached reproducer. It has no separate logger or server process. The complete test command output is attached as release-repro.log.
- Dominant language
- Go
- Stars
- 43.3k
- Forks
- 6.2k
- Avg merge
- 2d 11h
- Merged PRs (30d)
- 55
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from XTLS/Xray-core
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day
Similar issues
-
clawsweeper:fix-shape-clear clawsweeper:queueable-fix clawsweeper:source-repro impact:other issue-rating: 🦞 diamond lobster no-stale P2
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
openclaw/crabbox#3249 · 1 comment · 1 reaction ·
Maintainers usually reply within 1 day
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
-
ec2-subnet, security-group and internet-gateway skip all resources when one is deleted during the scanPossibly taken @toabctl claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
gruntwork-io/cloud-nuke#1208 ·
Maintainers usually reply within 5 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
snowflakedb/gosnowflake#1872 ·
-
MCP `shadow` says `out` is a folder, but for TS, Python, C, Go and Ruby it is the module's fileOpengood first issue help wanted
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
erkamyaman/rust-anything#1328 ·
Maintainers usually reply within 1 day