Cancelling a `notify_later()` future sometimes fails, eventually delivering the cancelled message.
Author: vincentdephilyCreated Sep 17, 2019Updated Mar 24, 2021
This is happening pretty reliably in my code, once enough messages are scheduled :
- create a timeout handler using
self.timeouts.insert(msgid, ctx.notify_later(MsgTimeout{msgid}, now + delay)) - then
ctx.cancel_future(self.timeouts.get(msgid).unwrap())a few ms later when the reply arrives - but I still receive the MsgTimeout message a few secs later
There shouldn't be a race condition, as the timeout arrives many seconds after it was supposedly cancelled. I've triple-checked that I do indeed cancel the right spawnhandle. I've tried to create a reduced testcase that I can share, but didn't succeed. I don't think it's the same as issue #206 as there's no UDP socket involved (there is TCP though).
This is a problem both because of the unexpected timeout that leads to spurious handling, and because the Actor remains alive while waiting for the message.
Source: actix/actix