-
Notifications
You must be signed in to change notification settings - Fork 6
fix: broadcast timeout #494
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -76,25 +76,22 @@ class RelayJitBroadcastOtherReadStrategy { | |||||||||||||||||||||||||||||||||||||||||||||||||||
| continue; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
| relayManager | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| .connectRelay( | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| final success = await relayManager.connectRelay( | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| dirtyUrl: relayUrl, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| connectionSource: ConnectionSource.broadcastOther, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| .then((success) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (!success.first) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| relayManager.failBroadcast( | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| eventToPublish.id, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| relayUrl, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| "connection failed", | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| return; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| final relay = relayManager.connectedRelays | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| .firstWhere((element) => element.url == relayUrl); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (!success.first) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| relayManager.failBroadcast( | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| eventToPublish.id, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| relayUrl, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| "connection failed", | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| continue; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| final relay = relayManager.connectedRelays | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| .firstWhere((element) => element.url == relayUrl); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
| sendToRelay(relay: relay); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| sendToRelay(relay: relay); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+91
to
+94
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Missing error handling for relay lookup after connection. Same issue as Proposed fix: wrap in try-catch for consistency if (!success.first) {
relayManager.failBroadcast(
eventToPublish.id,
relayUrl,
"connection failed",
);
continue;
}
- final relay = relayManager.connectedRelays
- .firstWhere((element) => element.url == relayUrl);
-
- sendToRelay(relay: relay);
+ try {
+ final relay = relayManager.connectedRelays
+ .firstWhere((element) => element.url == relayUrl);
+ sendToRelay(relay: relay);
+ } catch (e) {
+ relayManager.failBroadcast(
+ eventToPublish.id,
+ relayUrl,
+ "relay not found after connection",
+ );
+ }📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -67,25 +67,22 @@ class RelayJitBroadcastOutboxStrategy { | |
| ); | ||
| continue; | ||
| } | ||
| relayManager | ||
| .connectRelay( | ||
| final success = await relayManager.connectRelay( | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does it need to do await here? AI says:
|
||
| dirtyUrl: relayUrl, | ||
| connectionSource: ConnectionSource.broadcastOwn, | ||
| ) | ||
| .then((success) { | ||
| if (!success.first) { | ||
| relayManager.failBroadcast( | ||
| eventToPublish.id, | ||
| relayUrl, | ||
| "connection failed", | ||
| ); | ||
| return; | ||
| } | ||
| final relay = relayManager.connectedRelays | ||
| .firstWhere((element) => element.url == relayUrl); | ||
| ); | ||
| if (!success.first) { | ||
| relayManager.failBroadcast( | ||
| eventToPublish.id, | ||
| relayUrl, | ||
| "connection failed", | ||
| ); | ||
| continue; | ||
| } | ||
| final relay = relayManager.connectedRelays | ||
| .firstWhere((element) => element.url == relayUrl); | ||
|
|
||
| sendToRelay(relay: relay); | ||
| }); | ||
| sendToRelay(relay: relay); | ||
|
Comment on lines
+82
to
+85
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Missing error handling for relay lookup after connection.
Proposed fix: wrap in try-catch for consistency final success = await relayManager.connectRelay(
dirtyUrl: relayUrl,
connectionSource: ConnectionSource.broadcastOwn,
);
if (!success.first) {
relayManager.failBroadcast(
eventToPublish.id,
relayUrl,
"connection failed",
);
continue;
}
- final relay = relayManager.connectedRelays
- .firstWhere((element) => element.url == relayUrl);
-
- sendToRelay(relay: relay);
+ try {
+ final relay = relayManager.connectedRelays
+ .firstWhere((element) => element.url == relayUrl);
+ sendToRelay(relay: relay);
+ } catch (e) {
+ relayManager.failBroadcast(
+ eventToPublish.id,
+ relayUrl,
+ "relay not found after connection",
+ );
+ }🤖 Prompt for AI Agents |
||
| } | ||
| } | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could be simplified