Skip to content

Commit

Permalink
Modifying error passing to invalidation code
Browse files Browse the repository at this point in the history
  • Loading branch information
joshuali7536 authored and humphd committed Oct 27, 2021
1 parent 9a14e8c commit dfb080e
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/backend/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,10 @@ async function updateFeed(feedData) {
* Invalidates a feed
* @param feedData - Object containing feed data
*/
async function invalidateFeed(id) {
async function invalidateFeed(id, error) {
const feed = await Feed.byId(id);
// TODO: we need to bubble up the reason for the failure
await feed.setInvalid('unknown reason');
logger.info(`Invalidating feed ${feed.url} for the following reason: ${'unknown reason'}`);
await feed.setInvalid(error.message);
logger.info(`Invalidating feed ${feed.url} for the following reason: ${error.message}`);
}

/**
Expand Down Expand Up @@ -101,8 +100,10 @@ feedQueue.on('drained', loadFeedsIntoQueue);
* If there is a failure in the queue for a job, set the feed to invalid
* and save to Redis
*/
feedQueue.on('failed', (job) =>
invalidateFeed(job.data.id).catch((error) => logger.error({ error }, 'Unable to invalidate feed'))
feedQueue.on('failed', (job, err) =>
invalidateFeed(job.data.id, err).catch((error) =>
logger.error({ error }, 'Unable to invalidate feed')
)
);

/**
Expand Down

0 comments on commit dfb080e

Please sign in to comment.