fix: stop rule execution when rule group is deleted mid-run#2439
Merged
enoch85 merged 5 commits intoMar 24, 2026
Conversation
Fixes three bugs related to issue Maintainerr#379: 1. onRuleGroupDeleted called removeFromQueue (pending-only) instead of stopProcessingRuleGroup (which also aborts in-flight execution via AbortController). Deleting a rule while it was actively executing never fired the abort signal. 2. handleCollection else branch accessed collection.title when collection is null — always crashes in that code path. 3. handleCollection catch block accessed rulegroup.id and rulegroup.collection without null safety — crashes if rulegroup was null. Closes Maintainerr#379
enoch85
added a commit
that referenced
this pull request
Mar 1, 2026
PR #2438 - feat(rules): add rule Jellyfin favorited by including parents - Added Jellyfin favorited rule that checks parent items (series/seasons) - Includes unit tests for the new favorited-by-parents getter PR #2439 - fix: stop rule execution when rule group is deleted mid-run - Changed onRuleGroupDeleted to call stopProcessingRuleGroup instead of removeFromQueue - Fires abort signal for in-flight execution, preventing null reference crashes - Added unit test for delete-during-execution scenario PR #2442 - fix(server): reject null/undefined in numeric rule comparisons - Fixed null guard using proper nullish check (`firstVal != null`) - Preserves v2.27.0 null→0 coercion for BIGGER/SMALLER to avoid upgrade breakage - Logs warning when non-number values are encountered in numeric comparisons - Updated regression tests for numeric comparisons including null/undefined cases
Contributor
|
🎉 This PR is included in version 3.2.0 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #379 — Deleting a rule while its collection job is running caused continued execution against a deleted Plex collection (404 errors) and null-reference crashes.
Root Cause
Three bugs:
onRuleGroupDeletedcalledremoveFromQueueinstead ofstopProcessingRuleGroup—removeFromQueueonly drops items from the pending queue; it does not abort the currently executing job. The existingAbortControllerinfrastructure was never triggered on deletion.handleCollectionelse branch accessedcollection.titlewhencollectionisnull— this branch is specifically the "collection not found" path, socollectionis always null here.handleCollectioncatch block accessedrulegroup.id/rulegroup.collectionwithout null safety — if the catch fires due to a null rulegroup, it crashes again.Changes
rule-executor-scheduler.service.tsremoveFromQueue→stopProcessingRuleGroup(aborts in-flight execution)rule-executor.service.tsrulegroup?.id,rulegroup?.collection?.title) andundefinedinstead ofcollection.titlein else/catch blocksrule-executor-scheduler.service.spec.tsstopProcessingRuleGroupto mock + test for deletion behaviorTesting
onRuleGroupDeletedcallsstopProcessingRuleGroup(not justremoveFromQueue)