Skip to content

Catch possible fatal when sending notification emails and in that case remove from the queue the item that produced it. Also don't try to display basic notifications that would produce fatals.#2253

Merged
ideadude merged 13 commits into
gocodebox:devfrom
eri-trabiccolo:blocking-notifications
Feb 25, 2023

Conversation

@eri-trabiccolo

@eri-trabiccolo eri-trabiccolo commented Sep 1, 2022

Copy link
Copy Markdown
Contributor

Description

Fixes #2302
(Doesn't fix #2249 because that issue it's not related to the notification email errors.)
Although in that issue there's an example of error reporting of a notification email breaking, in this case because the order has been removed.
When this happens, since the notification emails sending is handled via a background process (in a batches queue), any unhandled fatal would just stuck the queue, and every time the queue needs to be processed the same fatal would occur and so on.
The idea of this PR is just to catch the fatal, log the error with the proper log handler, and remove the item from the queue, and move on.
For the user in #2249, the next time the queue will be run, the blocking item will be removed and notification emails will start to be sent. Is this good? They might be pretty old notifications...

I've implemented this because we really have to avoid to block that queue for whatever happened in one notification, because an error while sending a notification to a user blocks notifications to be sent to N other users.
On the other hand basic notifications will still break, so we have to really have more/better checks in the merge codes processing.
I'm extending the idea to the basic notifications too.

I'm setting these notification status to error. The downside of this is that even if you fix the error they wont' be displayed/sent anymore. Not a big deal I think, but maybe we can create a tool (ahah another one? yeah) that tries to load at least the errored basic notifications, and if they don't error anymore at least change their status so that they can show up in the user's dashboard.
But these are edge cases, when an error occurs, except for devs messing with the code, it's because of something important for the notification doesn't exist anymore, e.g. an order has been deleted etc.

Also this adds the "no_found_rows" improvement to the LLMS_Notifications_Query as per #933

How has this been tested?

manually, working on tests

Screenshots

Types of changes

Bug fix (non-breaking change which fixes an issue)

Checklist:

  • My code has been tested.
  • My code passes all existing automated tests.
  • My code follows the LifterLMS Coding & Documentation Standards.

@eri-trabiccolo

Copy link
Copy Markdown
Contributor Author

@thomasplevy your opinion on this?

@thomasplevy

Copy link
Copy Markdown
Contributor

smart strategy, should be good I think

@eri-trabiccolo eri-trabiccolo changed the title Catch possible fatal when sending notification emails and in that case remove from the queue the item that produced it Catch possible fatal when sending notification emails and in that case remove from the queue the item that produced it. Also don't try to display basic notifications tha would produce fatals. Sep 3, 2022
@eri-trabiccolo

eri-trabiccolo commented Sep 6, 2022

Copy link
Copy Markdown
Contributor Author

@gocodebox/engineering
This PR misses the tests for the basic notification erroring in the load method:
https://github.com/gocodebox/lifterlms/pull/2253/files#diff-14080370a8dd721dd0302db0cebe498056f02993c91fc28f0769b6d60509562aR287-R309

But if you want to start reviewing, or completing it, while I'm away I'm ok :D

^ done

@eri-trabiccolo eri-trabiccolo self-assigned this Sep 26, 2022
@eri-trabiccolo eri-trabiccolo changed the title Catch possible fatal when sending notification emails and in that case remove from the queue the item that produced it. Also don't try to display basic notifications tha would produce fatals. Catch possible fatal when sending notification emails and in that case remove from the queue the item that produced it. Also don't try to display basic notifications that would produce fatals. Nov 21, 2022
@eri-trabiccolo eri-trabiccolo marked this pull request as ready for review November 21, 2022 10:31
@eri-trabiccolo eri-trabiccolo requested review from a team and removed request for thomasplevy December 30, 2022 09:32
@eri-trabiccolo eri-trabiccolo force-pushed the blocking-notifications branch from 1a6b396 to 51f8182 Compare January 5, 2023 16:52
@ideadude ideadude added this to the 7.1 milestone Feb 20, 2023
@ideadude ideadude merged commit 195042b into gocodebox:dev Feb 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

3 participants