Uh oh!
There was an error while loading. Please reload this page.
COLDBOX-1419 - Fix scheduled tasks loading module components on Adobe ColdFusion - #685
Open
homestar9 wants to merge 1 commit into
Open
COLDBOX-1419 - Fix scheduled tasks loading module components on Adobe ColdFusion#685homestar9 wants to merge 1 commit into
homestar9 wants to merge 1 commit into
Conversation
COLDBOX-1419 Scheduled tasks run on background threads that have no web request, and on Adobe ColdFusion behind IIS those threads look for components in the wrong web root. ColdBox only registered an engine mapping for a module when it set this.classMapping, so a task that was the first code to build a module component failed with "component not found". ModuleService now stores an engine mapping for every module search folder and every explicitly registered module path, and ColdBoxScheduledTask registers those mappings on its own thread before each run. Adds four specs; verified on BoxLang, Lucee 5, and Adobe 2023+.
Contributor
There was a problem hiding this comment.
Pull request overview
This PR addresses COLDBOX-1419 by ensuring Adobe ColdFusion scheduled tasks can reliably resolve module components when running on background threads (e.g., behind IIS) where CFML mappings may be missing or lost between requests. It does this by persisting module-related mappings in ModuleService and replaying them at task execution time in ColdBoxScheduledTask.run().
Changes:
- Persist module search-folder mappings and explicitly-registered module path mappings into
ModuleService.mappingRegistry. - Replay module mappings on the scheduled task background thread before executing the task body.
- Add regression tests covering mapping registry population, mapping replay behavior, and “mapping replay failure does not block task execution”.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| tests/specs/web/services/ModuleServiceTest.cfc | Adds assertions that module search folders and explicitly registered module paths are stored in the mapping registry. |
| tests/specs/async/tasks/ColdBoxScheduledTaskSpec.cfc | Adds tests verifying mappings are replayed before task execution and that replay errors don’t prevent task success. |
| system/web/tasks/ColdBoxScheduledTask.cfc | Replays module mappings (via ModuleService.loadMappings()) prior to running the scheduled task. |
| system/web/services/ModuleService.cfc | Stores mappings for module scan locations and explicit module registration paths; leverages existing loadMappings() replay mechanism. |
| changelog.md | Documents the fix under Unreleased. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
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 freeto 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 COLDBOX-1419.
On Adobe ColdFusion with IIS, scheduled tasks could fail when loading a handler, model, or scheduler from a module.
Scheduled tasks run in the background without a normal web request. Because of this, Adobe ColdFusion sometimes looks for module components in the wrong folder and shows an error like:
The problem seemed random because the task worked if a web request had already loaded the component. It also did not happen in CommandBox, where component paths are handled differently.
This issue caused two module tasks to fail every night on an ACF 2023 and IIS site.
These failures also triggered COLDBOX-1420, which caused additional “Instance not found” errors until ColdBox was reinitialized. That is a separate bug and is not fixed in this PR.
What changed
This PR ensures the CF engine knows where every module is located.
ModuleServicenow saves a mapping for each module folder it finds.ColdBoxScheduledTask.run()applies those mappings on the scheduled task’s background thread before running the task.Scheduled task threads do not go through the normal web request setup, so they need to apply these mappings themselves.
If applying the mappings fails, ColdBox logs the error and still tries to run the task. This keeps the existing behavior where scheduled task errors are not rethrown.
Tests
Added tests to confirm that:
classMappingsupport still works.The full test suites pass with no failures on:
Notes
ModuleService.unload()does not remove old entries frommappingRegistry. This was already happening and is not changed in this PR.Jira Issues
Type of change
Checklist
InjectorLiveTest.cfc: mapping kept after a failed lookup with a retry that re-throws the original error instead of InstanceNotFound; recovery once the missing file is restored;processMappings()keeps the failed mapping; multi-name mappings keep all names)