-
Notifications
You must be signed in to change notification settings - Fork 1
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
Report Errors #102
Comments
@imwalterbot can you take a look? |
Queued for processing... |
Processing this now |
Based on the provided code, I can see that you want to implement a retry mechanism when there's an error processing a request and then report it back to the user. Here's a pseudocode solution to achieve this:
Now, you can replace the call to This pseudocode adds a |
@imwalterbot good approach. Can you do a back off? |
Queued for processing... |
Processing this now |
Based on the provided code, I can add a backoff mechanism to the retry strategy. Here's the updated pseudocode with an exponential backoff: function sleep(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
}
async function retryOnError(attempts, processingFunction, errorCallback, successCallback) {
// Run the processing function
try {
await processingFunction();
successCallback();
} catch (error) {
// If there's an error and we still have retry attempts left
if (attempts > 0) {
// Calculate the backoff time (exponential backoff)
const backoffTime = Math.pow(2, 3 - attempts) * 1000;
// Wait for the backoff time before retrying
await sleep(backoffTime);
// Retry the processing function with one less attempt
await retryOnError(attempts - 1, processingFunction, errorCallback, successCallback);
} else {
// If no more attempts left, call the error callback
errorCallback(error);
}
}
}
async function processEventWithRetry(event) {
await retryOnError(
3, // Number of retry attempts
async () => await processEvent(event), // Processing function
(error) => { // Error callback
// Report the error back to the user
gh.postIssueComment(
event.payload.repository,
event.payload.issue,
[`> ${event.payload.comment.body} `, "Error processing request. Please try again later."].join("\n\n")
);
Log.error(`Error processing event ${event.id}: ${error}`);
},
() => { // Success callback
Log.info(`Successfully processed event ${event.id}`);
}
);
} Now, you can replace the call to The updated pseudocode adds a |
@imwalterbot APPROVED for application to https://github.com/octaviuslabs/walter/blob/main/src/handlers/index.ts |
Queued for processing... |
Processing this now |
When there is an error processing a request we need to retry first then report that back to the user.
This probably would need to happen here: https://github.com/octaviuslabs/walter/blob/main/src/handlers/index.ts
The text was updated successfully, but these errors were encountered: