Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Kraken: Fix WsConnect/WsCancelOrder/TestWsAddOrder race #1762

Open
thrasher- opened this issue Dec 23, 2024 · 0 comments
Open

Kraken: Fix WsConnect/WsCancelOrder/TestWsAddOrder race #1762

thrasher- opened this issue Dec 23, 2024 · 0 comments
Labels

Comments

@thrasher-
Copy link
Collaborator

New Issue

Race spotted here: https://github.com/thrasher-corp/gocryptotrader/actions/runs/12462044377/job/34782406720#step:10:594

Looks to be because we're using an authToken global var without any sync.Mutex protection

Context

WARNING: DATA RACE
Write at 0x00000187cda0 by goroutine 197:
  github.com/thrasher-corp/gocryptotrader/exchanges/kraken.(*Kraken).WsConnect()
      /home/runner/work/gocryptotrader/gocryptotrader/exchanges/kraken/kraken_websocket.go:115 +0x519
  github.com/thrasher-corp/gocryptotrader/exchanges/kraken.(*Kraken).WsConnect-fm()
      <autogenerated>:1 +0x33
  github.com/thrasher-corp/gocryptotrader/exchanges/stream.(*Websocket).connect()
      /home/runner/work/gocryptotrader/gocryptotrader/exchanges/stream/websocket.go:355 +0x87b
  github.com/thrasher-corp/gocryptotrader/exchanges/stream.(*Websocket).Connect()
      /home/runner/work/gocryptotrader/gocryptotrader/exchanges/stream/websocket.go:326 +0x9d
  github.com/thrasher-corp/gocryptotrader/internal/testing/exchange.MockWsInstance[go.shape.struct { github.com/thrasher-corp/gocryptotrader/exchanges.Base },go.shape.*github.com/thrasher-corp/gocryptotrader/exchanges/kraken.Kraken]()
      /home/runner/work/gocryptotrader/gocryptotrader/internal/testing/exchange/exchange.go:115 +0x5fb
  github.com/thrasher-corp/gocryptotrader/exchanges/kraken.TestWsAddOrder()
      /home/runner/work/gocryptotrader/gocryptotrader/exchanges/kraken/kraken_test.go:1172 +0x124
  testing.tRunner()
      /opt/hostedtoolcache/go/1.23.4/x64/src/testing/testing.go:1690 +0x226
  testing.(*T).Run.gowrap1()
      /opt/hostedtoolcache/go/1.23.4/x64/src/testing/testing.go:1743 +0x44

Previous read at 0x00000187cda0 by goroutine 260:
  github.com/thrasher-corp/gocryptotrader/exchanges/kraken.(*Kraken).wsCancelOrder()
      /home/runner/work/gocryptotrader/gocryptotrader/exchanges/kraken/kraken_websocket.go:1322 +0x152
  github.com/thrasher-corp/gocryptotrader/exchanges/kraken.(*Kraken).wsCancelOrders.func1()
      /home/runner/work/gocryptotrader/gocryptotrader/exchanges/kraken/kraken_websocket.go:1310 +0xc4

Goroutine 197 (running) created at:
  testing.(*T).Run()
      /opt/hostedtoolcache/go/1.23.4/x64/src/testing/testing.go:1743 +0x825
  testing.runTests.func1()
      /opt/hostedtoolcache/go/1.23.4/x64/src/testing/testing.go:2168 +0x85
  testing.tRunner()
      /opt/hostedtoolcache/go/1.23.4/x64/src/testing/testing.go:1690 +0x226
  testing.runTests()
      /opt/hostedtoolcache/go/1.23.4/x64/src/testing/testing.go:2166 +0x8be
  testing.(*M).Run()
      /opt/hostedtoolcache/go/1.23.4/x64/src/testing/testing.go:2034 +0xf17
  github.com/thrasher-corp/gocryptotrader/exchanges/kraken.TestMain()
      /home/runner/work/gocryptotrader/gocryptotrader/exchanges/kraken/kraken_test.go:58 +0x104
  main.main()
      _testmain.go:255 +0x171

Goroutine 260 (running) created at:
  github.com/thrasher-corp/gocryptotrader/exchanges/kraken.(*Kraken).wsCancelOrders()
      /home/runner/work/gocryptotrader/gocryptotrader/exchanges/kraken/kraken_websocket.go:1308 +0x147
  github.com/thrasher-corp/gocryptotrader/exchanges/kraken.TestWsCancelOrders()
      /home/runner/work/gocryptotrader/gocryptotrader/exchanges/kraken/kraken_test.go:1191 +0x299
  testing.tRunner()
      /opt/hostedtoolcache/go/1.23.4/x64/src/testing/testing.go:1690 +0x226
  testing.(*T).Run.gowrap1()
      /opt/hostedtoolcache/go/1.23.4/x64/src/testing/testing.go:1743 +0x44
==================
--- FAIL: TestWsAddOrder (0.18s)
    testing.go:1399: race detected during execution of test
@thrasher- thrasher- added the bug label Dec 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant