isamert / scli

a simple terminal user interface for signal messenger (using signal-cli)
GNU General Public License v3.0
432 stars 40 forks source link

Messages are sometimes incorrectly discarded with "Message from unknown contact" #208

Closed taimon closed 1 year ago

taimon commented 1 year ago

Ever since the change from #202, messages are sometimes discarded when scli starts and signal-cli fetches the newest messages. scli logs the message, the 'source' matches one of the contacts, so it should not have been dropped with the "Message from unknown contact" error.

I assume this is a race condition, because due to recent changes, scli now needs to fetch contacts via dbus, which can take a while. In the meantime, signal-cli could have already received the messages and put them in the pipe. scli does not have a valid contacts map yet, so it will error out.

I haven't debugged this fully yet and I'm not sure if all my assumptions of how things work are correct.

Not sure yet how to properly fix this. signal-cli has a parameter --receive-mode for the daemon command that could be used to defer reception of messages until after contacts are initialized. (Manual mode)

exquo commented 1 year ago

Thanks for reporting this!

I think your diagnosis is spot on! Looks like a race condition indeed.

I'll look into postponing the processing of incoming messages until the contacts map is filled. (signal-cli's --receive-mode option should have been useful here, but it seems it's only relevant to the JSON-RPC mode..)

taimon commented 1 year ago

Thanks for the fix and maintaining scli in general!