octobercms/october · error · Error
The beforeapply callback must return a promise
Error message
The beforeapply callback must return a promise
What it means
Thrown in the Inspector modal's onApplyClick flow: validation passed and a beforeapply event listener stored a callback in the emitted holder object, but invoking it did not return a thenable. The modal waits on this promise to know when pre-apply work (e.g. async confirmation) finishes, so a synchronous or void return breaks the contract.
Solutions
- Make the beforeapply callback return a Promise (async function or Promise.resolve())
- If no asynchronous work is needed, do not set callback on the holder object at all
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at modules/backend/vuecomponents/inspector/assets/js/host-modal.js:99 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of octobercms/october@b608633a7e (2026-08-21).
Data as JSON: /api/errors/3856ec217b07e291.
Report an issue: GitHub.
Appendix: source
Thrown at modules/backend/vuecomponents/inspector/assets/js/host-modal.js:99
onApplyClick: function onApplyClick() {
if (this.readOnly) {
return;
}
var inspector = this.$refs.inspector,
that = this;
that.readOnly = true;
this.$refs.inspector.validate().then(
function validateResolve() {
var beforeApplyCallbackHolder = {};
that.$emit('beforeapply', beforeApplyCallbackHolder);
if (beforeApplyCallbackHolder.callback) {
var beforeApplyPromise = beforeApplyCallbackHolder.callback(inspector.getCleanObject());
if (typeof beforeApplyPromise !== 'object') {
throw new Error('The beforeapply callback must return a promise');
}
if (typeof beforeApplyPromise.then !== 'function') {
throw new Error('The beforeapply callback must return a promise');
}
beforeApplyPromise.then(
function beforeApplyPromiseResolve(result) {
if (result !== false) {
that.applyAndClose();
}
that.readOnly = false;
},
function beforeApplyPromiseReject() {
that.readOnly = false;
}
);
}View on GitHub (pinned to b608633a7e)