Skip to content

Fix AS init timing error in SystemAgentServiceProvider#1019

Merged
chubes4 merged 1 commit intomainfrom
fix/as-init-timing
Apr 4, 2026
Merged

Fix AS init timing error in SystemAgentServiceProvider#1019
chubes4 merged 1 commit intomainfrom
fix/as-init-timing

Conversation

@chubes4
Copy link
Copy Markdown
Member

@chubes4 chubes4 commented Apr 4, 2026

Summary

  • Defers manageDailyMemorySchedule() to the action_scheduler_init hook instead of calling AS functions directly from the constructor at plugins_loaded priority 20
  • Eliminates the as_next_scheduled_action() was called before the Action Scheduler data store was initialized notices that fire in massive clusters (50-100+ per ~20s) across all 10 subsites

Root Cause

SystemAgentServiceProvider is constructed at plugins_loaded p20 (via datamachine_run_datamachine_plugin()). Its constructor calls manageDailyMemorySchedule(), which calls as_next_scheduled_action() directly. At that point, the AS functions exist (files are loaded), but the data store isn't initialized until action_scheduler_init fires at init p1.

This was the only DM class doing it wrong — all 8 other files that interact with AS scheduling (ActionsCleanup, ClaimsCleanup, CompletedJobsCleanup, JobsCleanup, LogCleanup, ProcessedItemsCleanup, FileCleanup, Chat) already correctly defer to action_scheduler_init.

Fix

Wrap the scheduling logic in add_action('action_scheduler_init', ...) — same pattern used everywhere else.

Defer manageDailyMemorySchedule() to the action_scheduler_init hook
instead of calling AS functions directly from the constructor at
plugins_loaded. The constructor fires at plugins_loaded p20, before
AS initializes its data store at init p1.

This was the sole remaining source of the 'as_next_scheduled_action()
was called before the Action Scheduler data store was initialized'
notices that fire in massive clusters (50-100+ per ~20s) across all
10 subsites during cron/CLI operations.

All 8 other DM files that interact with AS scheduling already use
the action_scheduler_init pattern correctly.
@chubes4 chubes4 merged commit be0c3d3 into main Apr 4, 2026
1 check failed
@chubes4 chubes4 deleted the fix/as-init-timing branch April 4, 2026 15:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant