soberhacker / obsidian-telegram-sync

Transfer messages and files from Telegram to Obsidian
GNU Affero General Public License v3.0
349 stars 30 forks source link

The plugin does not reconnect after sleep mode on macOS #279

Open sbalyakin opened 8 months ago

sbalyakin commented 8 months ago

I have a MacBookPro and I am faced with the following issue of Telegram Sync 3.1.0.

Steps to reproduce:

  1. Open Obsidian
  2. The Telegram Sync plugin is connected to my Telegram bot. My user is not connected.
  3. Put the computer in sleep mode for a while.
  4. Wake up the computer

What's occurred: Telegram Sync is disconnected and does not connect again. To restore the connection it's necessary to disable/enable the plugin or restart Obsidian.

What's expected: Telegram Sync restores the connection.

isermakov87 commented 8 months ago

I have the same issue.

Description:

  1. Launch Obsidian.
  2. Telegram Sync Bot is connected.
  3. Put the laptop to sleep.
  4. While the laptop is in sleep mode, send several messages (e.g. 10 messages) via Telegram.
  5. Wake up the laptop.
  6. After waking up, Telegram Sync will only process the last two messages from Telegram. The rest of the messages are not processed by the plugin. Furthermore, these messages will remain unprocessed even if Obsidian is restarted.

Telegram Sync Log after waking up:

plugin:telegram-sync:92131 Telegram Sync => User connection error: Error: Not connected

plugin:telegram-sync:92711 Telegram Sync => Error: EFATAL: read ECONNRESET
Telegram bot is disconnected!
Check internet (proxy) connection, the functionality of Telegram using the official app. If everything is ok, restart Obsidian.

plugin:telegram-sync:92734 Error: EFATAL: Error: read ECONNRESET
    at new RequestError (plugin:telegram-sync:44934:15)
    at plumbing.callback (plugin:telegram-sync:45196:28)
    at Request.RP$callback [as _callback] (plugin:telegram-sync:45167:29)
    at self2.callback (plugin:telegram-sync:83496:27)
    at Request.emit (node:events:513:28)
    at Request.onRequestError (plugin:telegram-sync:84036:13)
    at ClientRequest.emit (node:events:513:28)
    at TLSSocket.socketErrorListener (node:_http_client:502:9)
    at TLSSocket.emit (node:events:513:28)
    at emitErrorNT (node:internal/streams/destroy:151:8)
    at emitErrorCloseNT (node:internal/streams/destroy:116:3)
    at process.processTicksAndRejections (node:internal/process/task_queues:82:21)
    at Promise2.longStackTracesCaptureStackTrace [as _captureStackTrace] (plugin:telegram-sync:40746:27)
    at Promise2._resolveFromExecutor (plugin:telegram-sync:42738:18)
    at new Promise2 (plugin:telegram-sync:42394:18)
    at plumbing.init (plugin:telegram-sync:45158:29)
    at Request.RP$initInterceptor [as init] (plugin:telegram-sync:45279:25)
    at new Request (plugin:telegram-sync:83454:13)
    at request (plugin:telegram-sync:84626:14)
    at TelegramBot2._request (plugin:telegram-sync:88913:16)
From previous event:
    at Promise2.longStackTracesCaptureStackTrace [as _captureStackTrace] (plugin:telegram-sync:40746:27)
    at Promise2._then (plugin:telegram-sync:42525:23)
    at Promise2.then (plugin:telegram-sync:42439:25)
    at Promise2.caught.Promise2.catch (plugin:telegram-sync:42420:25)
    at TelegramBot2._request (plugin:telegram-sync:88924:17)
    at TelegramBot2.getUpdates (plugin:telegram-sync:89372:21)
    at TelegramBotPolling._getUpdates (plugin:telegram-sync:88640:25)
    at TelegramBotPolling._polling (plugin:telegram-sync:88577:34)
    at eval (plugin:telegram-sync:88620:58)

plugin:telegram-sync:92711 Telegram Sync => Telegram bot is connected!

plugin:telegram-sync:92131 Telegram Sync => User connection error: Error: Not connected

plugin:telegram-sync:92711 Telegram Sync => Error: EFATAL: read ECONNRESET
Telegram bot is disconnected!
Check internet (proxy) connection, the functionality of Telegram using the official app. If everything is ok, restart Obsidian.

plugin:telegram-sync:92734 Error: EFATAL: Error: read ECONNRESET
    at new RequestError (plugin:telegram-sync:44934:15)
    at plumbing.callback (plugin:telegram-sync:45196:28)
    at Request.RP$callback [as _callback] (plugin:telegram-sync:45167:29)
    at self2.callback (plugin:telegram-sync:83496:27)
    at Request.emit (node:events:513:28)
    at Request.onRequestError (plugin:telegram-sync:84036:13)
    at ClientRequest.emit (node:events:513:28)
    at TLSSocket.socketErrorListener (node:_http_client:502:9)
    at TLSSocket.emit (node:events:513:28)
    at emitErrorNT (node:internal/streams/destroy:151:8)
    at emitErrorCloseNT (node:internal/streams/destroy:116:3)
    at process.processTicksAndRejections (node:internal/process/task_queues:82:21)
    at Promise2.longStackTracesCaptureStackTrace [as _captureStackTrace] (plugin:telegram-sync:40746:27)
    at Promise2._resolveFromExecutor (plugin:telegram-sync:42738:18)
    at new Promise2 (plugin:telegram-sync:42394:18)
    at plumbing.init (plugin:telegram-sync:45158:29)
    at Request.RP$initInterceptor [as init] (plugin:telegram-sync:45279:25)
    at new Request (plugin:telegram-sync:83454:13)
    at request (plugin:telegram-sync:84626:14)
    at TelegramBot2._request (plugin:telegram-sync:88913:16)
From previous event:
    at Promise2.longStackTracesCaptureStackTrace [as _captureStackTrace] (plugin:telegram-sync:40746:27)
    at Promise2._then (plugin:telegram-sync:42525:23)
    at Promise2.then (plugin:telegram-sync:42439:25)
    at Promise2.caught.Promise2.catch (plugin:telegram-sync:42420:25)
    at TelegramBot2._request (plugin:telegram-sync:88924:17)
    at TelegramBot2.getUpdates (plugin:telegram-sync:89372:21)
    at TelegramBotPolling._getUpdates (plugin:telegram-sync:88640:25)
    at TelegramBotPolling._polling (plugin:telegram-sync:88577:34)
    at eval (plugin:telegram-sync:88620:58)

plugin:telegram-sync:92131 Telegram Sync => User connection error: Error: Not connected
plugin:telegram-sync:92711 Telegram Sync => Telegram bot is connected!
plugin:telegram-sync:92131 Telegram Sync => User connection error: Error: Not connected
plugin:telegram-sync:92131 Telegram Sync => User connection error: Error: Not connected
plugin:telegram-sync:92131 Telegram Sync => User connection error: Error: Not connected
plugin:telegram-sync:92131 Telegram Sync => User connection error: Error: Not connected
plugin:telegram-sync:92131 Telegram Sync => User connection error: Error: Not connected
plugin:telegram-sync:92131 Telegram Sync => User connection error: Error: Not connected
plugin:telegram-sync:92131 Telegram Sync => User connection error: Error: Not connected

Additional Information: MacBookPro Ventura 13.2.1 Obsidian Version 1.5.3 (Installer 1.4.13) Telegram Sync 3.1.0. (+Insider)

Screenshot 2024-03-20 at 11 15 53

Additional Note: I would also like to take this opportunity to thank you for the plugin. This plugin turned out to be very useful for me. Thank you for your work.

pakadilly commented 4 months ago

Same issue. I wonder if this is only for certain users or a common bug?

siebentod commented 4 months ago

Same issue. I wonder if this is only for certain users or a common bug?

Seems like it also happens on Windows (11) and related to sleep mode.

I've tried to go to sleep mode, then checked out the console, it says "Telegram bot is connected!", gets a post, but doesn't process it and says "Error: EFATAL: getaddrinfo ENOTFOUND api.telegram.org" several times

Update: Actually, the main bug (when it stops getting new posts until plugin or Obsidian restart) behavior & console messages may be different. What I wrote also happens, but then it processes the message. So I'm not even sure it's connected to sleep mode...

soberhacker commented 1 month ago

Hi @sbalyakin @siebentod @isermakov87 @pakadilly Try new 3.2.0 release!

sbalyakin commented 1 month ago

@soberhacker, I've checked the issue on 3.2.0. Still reproducible. I've attached the logs. obsidian.md-1727410890324.log