From 35e588d3c93539af3168b478d0b6f02b59140eb4 Mon Sep 17 00:00:00 2001 From: alice <90381261+alice-yyds@users.noreply.github.com> Date: Mon, 13 Jan 2025 14:22:38 +0800 Subject: [PATCH] doc: sync Stream FAQ (#1195) --- .../Kitex+StreamX+-+Stream+FAQ.md | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 content/en/docs/kitex/Tutorials/basic-feature/Kitex+StreamX+-+Stream+FAQ.md diff --git a/content/en/docs/kitex/Tutorials/basic-feature/Kitex+StreamX+-+Stream+FAQ.md b/content/en/docs/kitex/Tutorials/basic-feature/Kitex+StreamX+-+Stream+FAQ.md new file mode 100644 index 0000000000..e2c7f7fbc5 --- /dev/null +++ b/content/en/docs/kitex/Tutorials/basic-feature/Kitex+StreamX+-+Stream+FAQ.md @@ -0,0 +1,35 @@ +--- +title: "Stream FAQ" +date: 2025-01-13 +weight: 1 +keywords: ["Stream FAQ"] +description: "" +--- + +## Problems caused by programming errors + +### Client forgot to call CloseSend + +Kitex will proactively call CloseSend once when checking that the user no longer holds the stream object to avoid stream leaks on the local and peer ends. + +Note that since the check depends on the GC timing, the delay monitoring of the stream will significantly increase at this time. + +### Client persistent stream object causes stream leak + +If the user holds the stream object for a long time and does not actively call stream. CloseSend, the framework will naturally assume that the stream still needs to be used, and will not close the stream and related gorotuines. + +### Server call Recv stuck + +If the client keeps a stream active and does not call CloseSend, the stream. Recv () function will not return. + +If the server wants to avoid problems caused by incorrect usage of client users, it can customize its own timeout logic in the ctx of Recv (ctx). For example: + +```go +ctx, cancel := context.WithTimeout(ctx, time.Second) +defer cancel() +stream.Recv(ctx) +``` + +### Server handler does not exit + +Server handler function exits to indicate the end of the flow. If the user never exits from this function, the flow will never end.