Skip to content

Commit

Permalink
feat(NodeChannelSubscribeJob.cs, ProcessNodeChannelAcceptorJob.cs): a…
Browse files Browse the repository at this point in the history
…dd delay after error to prevent excessive requests (#310)

This change is implemented to avoid overloading the server with massive requests in case of an error.
  • Loading branch information
Jossec101 authored Oct 4, 2023
1 parent 3d3523e commit 0c5d866
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/Jobs/NodeChannelSubscribeJob.cs
Original file line number Diff line number Diff line change
Expand Up @@ -87,11 +87,18 @@ public async Task Execute(IJobExecutionContext context)
_logger.LogError(e, "Error reading and update event of node {NodeId}", nodeId);
throw new JobExecutionException(e, true);
}


}


}
catch (Exception e)
{
_logger.LogError(e, "Error while subscribing for the channel updates of node {NodeId}", nodeId);
//Sleep to avoid massive requests
await Task.Delay(1000);

throw new JobExecutionException(e, true);
}

Expand Down
5 changes: 5 additions & 0 deletions src/Jobs/ProcessNodeChannelAcceptorJob.cs
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,12 @@ await AcceptChannelOpeningRequestWithUpfrontShutdown(_nBXplorerService,
catch (Exception e)
{
_logger.LogError(e, "Error on {JobName}", nameof(ProcessNodeChannelAcceptorJob));

//Sleep to avoid massive requests
await Task.Delay(1000);

throw new JobExecutionException(e, true);

}
}
}

0 comments on commit 0c5d866

Please sign in to comment.