Skip to content

Commit

Permalink
doc: sync Stream FAQ (#1195)
Browse files Browse the repository at this point in the history
  • Loading branch information
alice-yyds authored Jan 13, 2025
1 parent 21e2598 commit 35e588d
Showing 1 changed file with 35 additions and 0 deletions.
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.

0 comments on commit 35e588d

Please sign in to comment.