@konemono/nostr-login 1.7.31 → 1.7.33

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@konemono/nostr-login",
3
- "version": "1.7.31",
3
+ "version": "1.7.33",
4
4
  "description": "",
5
5
  "main": "./dist/index.esm.js",
6
6
  "types": "./dist/index.d.ts",
@@ -155,6 +155,7 @@ class NostrRpc extends NDKNostrRpc {
155
155
  );
156
156
 
157
157
  const connectedRelays = relays.filter(r => r.status === 1);
158
+ console.log('connected relays', connectedRelays);
158
159
 
159
160
  if (connectedRelays.length === 0) {
160
161
  console.log('No connected relays, forcing reconnection...');
@@ -262,6 +263,7 @@ class NostrRpc extends NDKNostrRpc {
262
263
 
263
264
  const timeoutId = setTimeout(() => {
264
265
  if (this.requests.has(id)) {
266
+ clearTimeout(timeoutId);
265
267
  this.requests.delete(id);
266
268
  this.requestTimeouts.delete(id);
267
269
  console.log('NIP46 request timeout for', id);
@@ -40,7 +40,7 @@ class ProcessManager extends EventEmitter {
40
40
  if (!this.callTimer) {
41
41
  this.callTimer = setTimeout(() => {
42
42
  console.log('ProcessManager: timeout reached, emitting onCallTimeout');
43
- this.callTimer = undefined; // タイムアウト時にタイマーIDをクリア
43
+ this.callTimer = undefined; // タイムアウト時にタイマーIDをクリア
44
44
  this.emit('onCallTimeout');
45
45
  }, CALL_TIMEOUT);
46
46
  console.log(`Setting up timeout timer for ${CALL_TIMEOUT} ms`);
@@ -52,32 +52,41 @@ class ProcessManager extends EventEmitter {
52
52
 
53
53
  this.callCount++;
54
54
 
55
- let error;
56
- let result;
55
+ let error: any; // 型をanyに変更
56
+ let result: any;
57
57
 
58
+ // 非同期処理の実行
58
59
  try {
59
60
  result = await cb();
60
61
  } catch (e) {
61
62
  error = e;
62
63
  }
63
64
 
64
- this.callCount--;
65
+ // ★ 修正後のクリーンアップロジック (finallyブロック相当)
66
+ // ----------------------------------------------------
65
67
 
68
+ // ProcessManagerの呼び出しカウントをデクリメント
69
+ this.callCount--;
66
70
  this.emit('onCallEnd');
67
71
 
72
+ // タイマーがまだ存在していればクリアし、IDもクリア
73
+ // この処理は、cb()が成功/失敗したどちらの場合でも実行される
68
74
  if (this.callTimer) {
69
75
  clearTimeout(this.callTimer);
70
76
  }
77
+ this.callTimer = undefined; // ProcessManager のタイマーIDもここでクリア
71
78
 
72
- this.callTimer = undefined;
79
+ // ----------------------------------------------------
73
80
 
81
+ // エラーがあればスローし、呼び出し元に伝播させる
74
82
  if (error) {
75
83
  throw error;
76
84
  }
77
85
 
78
86
  // @ts-ignore
79
- return result;
87
+ return result as T;
80
88
  }
89
+
81
90
  public pause() {
82
91
  if (this.callTimer) clearTimeout(this.callTimer);
83
92
  this.callTimer = undefined;