File tree 3 files changed +19
-8
lines changed
3 files changed +19
-8
lines changed Original file line number Diff line number Diff line change @@ -146,14 +146,19 @@ class LightPush extends BaseProtocol implements ILightPush {
146
146
return { recipients, error : SendError . DECODE_FAILED } ;
147
147
}
148
148
149
- if ( response ?. isSuccess ) {
150
- recipients . some ( ( recipient ) => recipient . equals ( peer . id ) ) ||
151
- recipients . push ( peer . id ) ;
152
- } else {
149
+ if ( ! response ) {
153
150
log ( "Remote peer fault: No response in PushRPC" ) ;
154
151
return { recipients, error : SendError . REMOTE_PEER_FAULT } ;
155
152
}
156
153
154
+ if ( ! response . isSuccess ) {
155
+ log ( "Remote peer rejected the message: " , response . info ) ;
156
+ return { recipients, error : SendError . REMOTE_PEER_REJECTED } ;
157
+ }
158
+
159
+ recipients . some ( ( recipient ) => recipient . equals ( peer . id ) ) ||
160
+ recipients . push ( peer . id ) ;
161
+
157
162
return { recipients } ;
158
163
} ) ;
159
164
Original file line number Diff line number Diff line change @@ -79,10 +79,16 @@ export enum SendError {
79
79
*/
80
80
NO_PEER_AVAILABLE = "No peer available" ,
81
81
/**
82
- * The remote peer did not behave as expected. Mitigation from `NO_PEER_AVAILABLE`
82
+ * The remote peer did not behave as expected. Mitigation for `NO_PEER_AVAILABLE`
83
83
* or `DECODE_FAILED` can be used.
84
84
*/
85
- REMOTE_PEER_FAULT = "Remote peer fault"
85
+ REMOTE_PEER_FAULT = "Remote peer fault" ,
86
+ /**
87
+ * The remote peer rejected the message. Information provided by the remote peer
88
+ * is logged. Review message validity, or mitigation for `NO_PEER_AVAILABLE`
89
+ * or `DECODE_FAILED` can be used.
90
+ */
91
+ REMOTE_PEER_REJECTED = "Remote peer rejected"
86
92
}
87
93
88
94
export interface SendResult {
Original file line number Diff line number Diff line change @@ -86,7 +86,7 @@ describe("Waku Light Push [node only]", function () {
86
86
} ) ;
87
87
} else {
88
88
expect ( pushResponse . recipients . length ) . to . eq ( 0 ) ;
89
- expect ( pushResponse . errors ) . to . include ( SendError . NO_RPC_RESPONSE ) ;
89
+ expect ( pushResponse . errors ) . to . include ( SendError . REMOTE_PEER_REJECTED ) ;
90
90
expect ( await messageCollector . waitForMessages ( 1 ) ) . to . eq ( false ) ;
91
91
}
92
92
} ) ;
@@ -158,7 +158,7 @@ describe("Waku Light Push [node only]", function () {
158
158
} ) ;
159
159
} else {
160
160
expect ( pushResponse . recipients . length ) . to . eq ( 0 ) ;
161
- expect ( pushResponse . errors ) . to . include ( SendError . NO_RPC_RESPONSE ) ;
161
+ expect ( pushResponse . errors ) . to . include ( SendError . REMOTE_PEER_REJECTED ) ;
162
162
expect ( await messageCollector . waitForMessages ( 1 ) ) . to . eq ( false ) ;
163
163
}
164
164
} ) ;
You can’t perform that action at this time.
0 commit comments