Close and return immediately if the context is already canceled (#1158)
Signed-off-by: Clifton Kaznocha <ckaznocha@users.noreply.github.com> Co-authored-by: Clifton Kaznocha <ckaznocha@users.noreply.github.com>
This commit is contained in:
@@ -117,6 +117,15 @@ func testEnsureTerminationOnClose(t *testing.T, r wazero.Runtime) {
|
||||
require.Contains(t, err.Error(), fmt.Sprintf("module \"%s\" closed with context canceled", t.Name()))
|
||||
})
|
||||
|
||||
t.Run("context cancel in advance", func(t *testing.T) {
|
||||
_, infinite := newInfiniteLoopFn(t)
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
cancel()
|
||||
_, err = infinite.Call(ctx)
|
||||
require.Error(t, err)
|
||||
require.Contains(t, err.Error(), fmt.Sprintf("module \"%s\" closed with context canceled", t.Name()))
|
||||
})
|
||||
|
||||
t.Run("context timeout", func(t *testing.T) {
|
||||
_, infinite := newInfiniteLoopFn(t)
|
||||
ctx, cancel := context.WithTimeout(context.Background(), time.Second)
|
||||
|
||||
Reference in New Issue
Block a user