claude-notification-plugin 1.1.34 → 1.1.35

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "claude-notification-plugin",
3
- "version": "1.1.34",
3
+ "version": "1.1.35",
4
4
  "description": "Claude Code task-completion notifications: Telegram, desktop notifications (Windows/macOS/Linux), sound, and voice",
5
5
  "author": {
6
6
  "name": "Viacheslav Makarov",
package/commit-sha CHANGED
@@ -1 +1 @@
1
- f5fe014bea67b636f42de095623452d25a44b329
1
+ 0c61ed57e3d709a6379f00009d55d8f6093f1cbc
@@ -10,6 +10,8 @@ export class TelegramPoller {
10
10
  this.logger = logger;
11
11
  this.baseUrl = `https://api.telegram.org/bot${token}`;
12
12
  this.offset = 0;
13
+ this._errorBackoff = 0; // current backoff in ms (0 = no backoff)
14
+ this._consecutiveErrors = 0;
13
15
  }
14
16
 
15
17
  async flush () {
@@ -26,14 +28,27 @@ export class TelegramPoller {
26
28
  }
27
29
 
28
30
  async getUpdates () {
31
+ // Apply backoff delay if we've had consecutive errors
32
+ if (this._errorBackoff > 0) {
33
+ await new Promise((resolve) => setTimeout(resolve, this._errorBackoff));
34
+ }
35
+
29
36
  try {
30
37
  const url = `${this.baseUrl}/getUpdates?offset=${this.offset}&timeout=${POLL_TIMEOUT}&allowed_updates=["message"]`;
31
38
  const res = await fetch(url, { signal: AbortSignal.timeout((POLL_TIMEOUT + 10) * 1000) });
32
39
  const data = await res.json();
33
40
  if (!data.ok) {
34
41
  this.logger.error(`getUpdates failed: ${JSON.stringify(data)}`);
42
+ this._applyBackoff();
35
43
  return [];
36
44
  }
45
+ // Success — reset backoff
46
+ if (this._consecutiveErrors > 0) {
47
+ this.logger.info('getUpdates recovered after errors');
48
+ }
49
+ this._consecutiveErrors = 0;
50
+ this._errorBackoff = 0;
51
+
37
52
  const messages = [];
38
53
  for (const update of data.result || []) {
39
54
  this.offset = update.update_id + 1;
@@ -55,12 +70,19 @@ export class TelegramPoller {
55
70
  return messages;
56
71
  } catch (err) {
57
72
  if (err.name !== 'TimeoutError' && err.name !== 'AbortError') {
58
- this.logger.error(`getUpdates error: ${err.message}`);
73
+ this._applyBackoff();
74
+ this.logger.error(`getUpdates error: ${err.message} (retry in ${Math.round(this._errorBackoff / 1000)}s)`);
59
75
  }
60
76
  return [];
61
77
  }
62
78
  }
63
79
 
80
+ _applyBackoff () {
81
+ this._consecutiveErrors++;
82
+ // Exponential backoff: 1s, 2s, 4s, 8s, 16s, 30s (max)
83
+ this._errorBackoff = Math.min(1000 * Math.pow(2, this._consecutiveErrors - 1), 30000);
84
+ }
85
+
64
86
  async sendMessage (text, replyToMessageId) {
65
87
  const chunks = splitMessage(text);
66
88
  let firstMessageId = null;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "claude-notification-plugin",
3
3
  "productName": "claude-notification-plugin",
4
- "version": "1.1.34",
4
+ "version": "1.1.35",
5
5
  "description": "Claude Code task-completion notifications: Telegram, desktop notifications (Windows/macOS/Linux), sound, and voice",
6
6
  "type": "module",
7
7
  "engines": {