You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
`Context` must not be accessed out of the goroutine handling the request. There are two reasons:
61
+
62
+
1.`Context` has functions that are dangerous to execute from multiple goroutines. Therefore, only one goroutine should access it.
63
+
2. Echo uses a pool to create `Context`'s. When the request handling finishes, Echo returns the `Context` to the pool.
64
+
65
+
See issue [1908](https://github.com/labstack/echo/issues/1908) for a "cautionary tale" caused by this reason. Concurrency is complicated. Beware of this pitfall when working with goroutines.
66
+
67
+
### Solutions
68
+
69
+
#### Use a channel
70
+
71
+
A better design might be to use a channel:
72
+
73
+
```go
74
+
func(cecho.Context) error {
75
+
ca:=make(chanstring, 1) // To prevent this channel from blocking, size is set to 1.
0 commit comments