Reproducer (as a test): ```diff diff --git a/tarantool_test.go b/tarantool_test.go index 2be3e79..91d50aa 100644 --- a/tarantool_test.go +++ b/tarantool_test.go @@ -3550,6 +3550,44 @@ func TestConnection_NewWatcher(t *testing.T) { } } +func TestNewWatcherDuringReconnect(t *testing.T) { + const server = "127.0.0.1:3015" + testDialer := dialer + testDialer.Address = server + + inst, err := test_helpers.StartTarantool(test_helpers.StartOpts{ + Dialer: testDialer, + InitScript: "config.lua", + Listen: server, + WaitStart: 100 * time.Millisecond, + ConnectRetry: 10, + RetryTimeout: 500 * time.Millisecond, + }) + defer test_helpers.StopTarantoolWithCleanup(inst) + if err != nil { + t.Fatalf("Unable to start Tarantool: %s", err) + } + + ctx, cancel := test_helpers.GetConnectContext() + defer cancel() + + reconnectOpts := opts + reconnectOpts.Reconnect = 100 * time.Millisecond + reconnectOpts.MaxReconnects = 100 + conn, err := Connect(ctx, testDialer, reconnectOpts) + if err != nil { + t.Fatalf("Connection was not established: %v", err) + } + defer conn.Close() + test_helpers.StopTarantool(inst) + + time.Sleep(time.Second) + _, err = conn.NewWatcher("one", func(event WatchEvent) {}) + if err == nil { + t.Fatal("Expected an error") + } +} + func TestConnection_NewWatcher_noWatchersFeature(t *testing.T) { test_helpers.SkipIfWatchersSupported(t) ``` Result: ```console mergen@megatron:~/work/go-tarantool$ go test -run TestNewWatcherDuringReconnect 2025/03/28 12:54:46 Tarantool "127.0.0.1:3013" was unexpectedly terminated: exit status 1 2025/03/28 12:54:46 tarantool: reconnect (0/100) to 127.0.0.1:3015 failed: failed to dial: dial tcp 127.0.0.1:3015: connect: connection refused 2025/03/28 12:54:46 tarantool: reconnect (1/100) to 127.0.0.1:3015 failed: failed to dial: dial tcp 127.0.0.1:3015: connect: connection refused 2025/03/28 12:54:46 tarantool: reconnect (2/100) to 127.0.0.1:3015 failed: failed to dial: dial tcp 127.0.0.1:3015: connect: connection refused 2025/03/28 12:54:47 tarantool: reconnect (3/100) to 127.0.0.1:3015 failed: failed to dial: dial tcp 127.0.0.1:3015: connect: connection refused 2025/03/28 12:54:47 tarantool: reconnect (4/100) to 127.0.0.1:3015 failed: failed to dial: dial tcp 127.0.0.1:3015: connect: connection refused 2025/03/28 12:54:47 tarantool: reconnect (5/100) to 127.0.0.1:3015 failed: failed to dial: dial tcp 127.0.0.1:3015: connect: connection refused 2025/03/28 12:54:47 tarantool: reconnect (6/100) to 127.0.0.1:3015 failed: failed to dial: dial tcp 127.0.0.1:3015: connect: connection refused 2025/03/28 12:54:47 tarantool: reconnect (7/100) to 127.0.0.1:3015 failed: failed to dial: dial tcp 127.0.0.1:3015: connect: connection refused 2025/03/28 12:54:47 tarantool: reconnect (8/100) to 127.0.0.1:3015 failed: failed to dial: dial tcp 127.0.0.1:3015: connect: connection refused 2025/03/28 12:54:47 tarantool: reconnect (9/100) to 127.0.0.1:3015 failed: failed to dial: dial tcp 127.0.0.1:3015: connect: connection refused --- FAIL: TestNewWatcherDuringReconnect (1.62s) panic: runtime error: invalid memory address or nil pointer dereference [recovered] panic: runtime error: invalid memory address or nil pointer dereference [signal SIGSEGV: segmentation violation code=0x1 addr=0x38 pc=0x5922e2] goroutine 35 [running]: testing.tRunner.func1.2({0x67f920, 0x8f05e0}) /usr/lib/go-1.22/src/testing/testing.go:1631 +0x24a testing.tRunner.func1() /usr/lib/go-1.22/src/testing/testing.go:1634 +0x377 panic({0x67f920?, 0x8f05e0?}) /usr/lib/go-1.22/src/runtime/panic.go:770 +0x132 github.com/tarantool/go-tarantool/v2.(*Connection).NewWatcher(0xc00019e180, {0x6c35f7, 0x3}, 0x6f7350) /home/mergen/work/go-tarantool/connection.go:1422 +0x42 github.com/tarantool/go-tarantool/v2_test.TestNewWatcherDuringReconnect(0xc0003401a0) /home/mergen/work/go-tarantool/tarantool_test.go:3585 +0x365 testing.tRunner(0xc0003401a0, 0x6f6f60) /usr/lib/go-1.22/src/testing/testing.go:1689 +0xfb created by testing.(*T).Run in goroutine 1 /usr/lib/go-1.22/src/testing/testing.go:1742 +0x390 exit status 2 FAIL github.com/tarantool/go-tarantool/v2 1.735s ```