-
Notifications
You must be signed in to change notification settings - Fork 261
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
21e2598
commit 35e588d
Showing
1 changed file
with
35 additions
and
0 deletions.
There are no files selected for viewing
35 changes: 35 additions & 0 deletions
35
content/en/docs/kitex/Tutorials/basic-feature/Kitex+StreamX+-+Stream+FAQ.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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. |