You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
tg daemon stop waits out a FLOOD_WAIT in the dialog pass or a sync job, past its 10 s timeout #64
Found while fixing #56. A stop now ends the daemon's dialog pass at the next dialog and waits for at most one running sync job, but neither can be cut short while a request is waiting out a FLOOD_WAIT.
The daemon's clients wait out FLOOD_WAITs of up to five minutes inside the request (floodWaiter.maxWait in createDaemonClient). When SIGTERM arrives during such a wait:
in the startup or reconnect dialog pass, iterDialogs stays inside its messages.getDialogs call until the wait ends, so the pass only sees the stop flag afterwards;
in a sync job, the main loop awaits the job's messages.getHistory, so it only checks the flag after the wait.
tg daemon stop gives up after its 10 s timeout ("Daemon did not stop within 10 seconds. Use --force to forcefully kill."), while the daemon keeps running until the wait ends and then stops cleanly. --force kills it, which loses session writes made since the last save.
The daemon passes no per-call abortSignal to these requests, so today the only way to cut the wait short is to tear the client down, which rejects every request in flight and would need its own handling of interrupted jobs.
Possible fix: give the dialog pass and the sync jobs an AbortSignal that the stop aborts, so a request waiting out a FLOOD_WAIT ends at once, the job keeps its row as it was (pending, not failed) and the pass is treated as stopped.
Done when tg daemon stop during a FLOOD_WAIT in the dialog pass or in a sync job stops the daemon within its timeout, the job stays pending for the next start, and no error is logged for the cut-short request.
Activity
docs: say which timeout still saves session writes on a stop
fix(daemon): keep session files open until the daemon closes its clients
docs: say which timeout still saves session writes on a stop
fix(daemon): keep session files open until the daemon closes its clients
docs: say which timeout still saves session writes on a stop
docs(daemon): say which FLOOD_WAITs still hold a stop and what --time…
docs(daemon): say which FLOOD_WAITs still hold a stop and what --time…
docs: add the changelog entries for the 0.4.1 bug fixes