gRPC outbound clients remain cached and active after core.Instance.Close

Aperta
#7,177 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
25/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Ferma
Stack tecnologico
go, grpc

Direzione di ricerca

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.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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
  1. Check out Xray-core v26.3.27.

  2. Download the attached repro_test.go.txt and save it as:
    transport/internet/grpc/lifetime_repro_test.go

  3. 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.
Lingua principale
Go
Stelle
43.3k
Fork
6.2k
Merge medio
2g 11h
PR unite (30g)
55

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di XTLS/Xray-core

Tutte le issue di XTLS/Xray-core

Issue simili

Altre issue su Go

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.