-
Notifications
You must be signed in to change notification settings - Fork 189
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
Fixes #462, Integrate inactive blog url and include logic to filter inactive feeds #639
Conversation
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.
This is heading in the right direction. I left some initial comments.
This pull request is being automatically deployed with ZEIT Now (learn more). 🔍 Inspect: https://zeit.co/humphd/telescope/fqsooi59p |
Still need to work on the logic and the failedReason, fail event has been added and can kind of confirm it is working. Edit: There is no way to access the failedReason as noted by this issue here |
To test, the stuff for now:
for example I have a job id #937dda54ec I set a logger.debug message to display something along the lines of |
Further testing is making it weird, its also saving the posts it can't process as part of the |
src/backend/feed/queue.js
Outdated
@@ -26,7 +26,7 @@ queue.addFeed = async function(feed) { | |||
delay: process.env.FEED_QUEUE_DELAY_MS || 60 * 1000, | |||
}, | |||
removeOnComplete: true, | |||
removeOnFail: true, | |||
removeOnFail: false, |
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.
Can you explain this change? Will this still allow the job to be retried?
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.
Sorry, enabled that for now just so I can refer to which jobs failed or not and can manually find them in redis
src/backend/index.js
Outdated
@@ -54,6 +54,10 @@ function processFeeds(feeds) { | |||
const currentFeed = await updateFeed(feed); | |||
// Add a job to the feed queue to process all of this feed's posts. | |||
await feedQueue.addFeed(currentFeed); | |||
// If failed, set the feed to invalid and save to Redis. | |||
feedQueue.on('failed', (job, err) => { | |||
currentFeed.setInvalid(err.message); |
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.
When you have a callback in an event handler that is synchronous, and you need to invoke an async
function, you need to add a .catch()
so a failed Promise doesn't blow things up. Also, you shouldn't hold a reference to the feed
in a closure like this. Use the job.data
to recreate a new Feed
object:
async function invalidateFeed(feedData) {
const feed = Feed.parse(feedData);
await feed.setInvalid(feedData.reason || 'unknown reason');
}
feedQueue.on('failed', (job, err) => invalidateFeed(job.data).catch(error => logger.error({ error }, 'Unable to invalidate feed in database.')));
NOTE: we'll need to attach the reason
to the job.data
before we fail it. I'm not 100% sure where/how to do this without doing it myself.
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.
I tried your above code, it does work... just like you said all of them have a value of 'unknown reason'
Another side effect of it being failed, I'm not sure if its a bug. Bull can't differentiate between feeds failing and posts failing, it adds both to Redis
I think you need to rebase to get the code where I fix the posts not failing. |
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.
Nice. Amazing how compact this code is now. That's fantastic. A few more things.
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.
One last thing, and let's take this. Great work.
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.
Let's try this, and fix bugs as we go.
Testing this on windows dev environment, I didn't get all those errors popping up unlike the demo this morning when shutting down the service with ctrl + c |
81be74c
Going to just merge this once it passes CI, since I'm just rebasing stuff. |
#462
Type of Change
Description
As per discussion, removed the inactive-blog-filter.js files (sorry Rafi). Added new functions in
storage.js
+feed.js
to handle invalid feeds. Modifiedprocessor.js
to use the new functions for the appropriate errors.Checklist