decred / dcrdex

The Decred Decentralized Exchange (DEX), powered by atomic-swaps.
Other
187 stars 96 forks source link

testing: go ci test timeout in `server/swap` #1984

Closed JoeGruffins closed 1 year ago

JoeGruffins commented 1 year ago

https://github.com/decred/dcrdex/actions/runs/3616423483/jobs/6094364116

JoeGruffins commented 1 year ago

Looking into this, probably a race in the test like usual. Unable to hit locally.

JoeGruffins commented 1 year ago

These ctx and locks in swapper.Run are really complicated.

This seems unreachable since mainLoop is not closed until after all the helpers have returned: https://github.com/decred/dcrdex/blob/884100b7652cc27f9ac64d06e4435e2fcaea8530/server/swap/swap.go#L802-L803

JoeGruffins commented 1 year ago

I'm concerned that meterer is also not working as intended: https://github.com/decred/dcrdex/blob/884100b7652cc27f9ac64d06e4435e2fcaea8530/dex/meter/meterer.go#L47-L60

Is <-scheduled.C receiving here? https://go.dev/play/p/ZtdWr_L7OlZ

JoeGruffins commented 1 year ago

Oh, it seems this is used with the '!scheduled.Stop()'? Why do we do this? the docs suggest using with 'Reset' https://pkg.go.dev/time#NewTimer

JoeGruffins commented 1 year ago

Ok, so from this playground it seems if the after function has fired before we do !scheduled.Stop() it does indeed hang https://go.dev/play/p/tZM_m4nWhgj

So if the timer unluckily fires between ctx being done and us checking Stop() we hang?