OrchardCMS/OrchardCore · error · TypeError
RegExp#exec called on incompatible receiver
Error message
RegExp#exec called on incompatible receiver
What it means
core-js's RegExp#exec shim (bundled into vuedraggable.common.js) throws this TypeError when the receiver R has no function-valued exec and its internal classof is not 'RegExp' — i.e. RegExp.prototype.exec was called on an object that is not a RegExp (and not a well-behaved RegExp-like with a proper exec).
Solutions
- Ensure the value passed as a pattern is a real RegExp in the same realm: use `new RegExp(pattern)` on the consuming side before calling match/test/exec.
- Bind/apply correctly: call regex.exec(str) / regex.test(str) on the RegExp instance, not via unbound function references.
- If supporting cross-realm regexes, normalize them: `const re = obj instanceof RegExp ? new RegExp(obj.source, obj.flags) : obj;`
- Audit for polyfills that wrap String.prototype.match/replace with a shimmed RegExpExec and remove duplicate polyfill loads.
- Validate config-supplied 'pattern' values with typeof v === 'string' ? new RegExp(v) : v before use.
Example fix
// before
const test = RegExp.prototype.test;
test.call(somePlainObject, 'input'); // not a RegExp -> TypeError
// after
const re = somePlainObject instanceof RegExp ? somePlainObject : new RegExp(String(somePlainObject));
re.test('input'); Defensive patterns
Strategy: validation
Validate before calling
function assertRegExp(v) { if (!(v instanceof RegExp)) throw new TypeError('Pattern must be a RegExp in the current realm, got: ' + Object.prototype.toString.call(v)); } Type guard
function isRegExp(v) { return Object.prototype.toString.call(v) === '[object RegExp]'; } Try / catch
try { return pattern.exec(input); } catch (e) { if (e instanceof TypeError && /incompatible receiver/.test(e.message)) { const re = new RegExp(pattern.source ?? String(pattern), pattern.flags ?? ''); return re.exec(input); } throw e; } Prevention
- Call test/exec/match as methods on a real RegExp instance, never via unbound references
- Normalize cross-realm (iframe/vm) regexes with new RegExp(re.source, re.flags)
- Validate config-supplied patterns: strings become new RegExp(v); reject plain objects
- Deduplicate polyfill bundles so core-js shims don't run against foreign receivers
- Prefer String.prototype methods with literal patterns over generic exec helpers
When it happens
Trigger: Calling String.prototype.match/replace/split (or .test/.exec) with a this-value or pattern argument that is an object merely resembling a RegExp (e.g. Object.create(RegExp.prototype), a cloned/plain object, a value from another iframe/realm or vm context) so the shim classifies it as non-RegExp.
Common situations: Cross-realm RegExp (object created in another iframe/Node vm) failing classof checks; library config code doing regex.test(str) with test passed unbound or called with a non-regex this; destructuring pattern values from JSON/config that are plain objects; polyfill collisions where the shimmed exec runs on foreign objects.
Understand the failure class
Background: Type mismatch errors: IllegalArgumentException, TypeError and type guards across 150 open-source libraries — this error's family across 150 libraries.
Related errors
- RegExp exec method returned something other than an Object…
- RegExp exec method returned something other than an Object…
- RegExp#exec called on incompatible receiver
- @@toPrimitive must return a primitive value.
- @@toPrimitive must return a primitive value.
AI-assisted analysis of OrchardCMS/OrchardCore@4306c0717f (2026-09-13).
Data as JSON: /api/errors/3a3a0bd07cc889e4.
Report an issue: GitHub.
Appendix: source
Thrown at src/OrchardCore.Modules/OrchardCore.Resources/wwwroot/Vendor/vue-draggable-2.24.3/vuedraggable.common.js:874
"use strict";
var classof = __webpack_require__("23c6");
var builtinExec = RegExp.prototype.exec;
// `RegExpExec` abstract operation
// https://tc39.github.io/ecma262/#sec-regexpexec
module.exports = function (R, S) {
var exec = R.exec;
if (typeof exec === 'function') {
var result = exec.call(R, S);
if (typeof result !== 'object') {
throw new TypeError('RegExp exec method returned something other than an Object or null');
}
return result;
}
if (classof(R) !== 'RegExp') {
throw new TypeError('RegExp#exec called on incompatible receiver');
}
return builtinExec.call(R, S);
};
/***/ }),
/***/ "613b":
/***/ (function(module, exports, __webpack_require__) {
var shared = __webpack_require__("5537")('keys');
var uid = __webpack_require__("ca5a");
module.exports = function (key) {
return shared[key] || (shared[key] = uid(key));
};
/***/ }),View on GitHub (pinned to 4306c0717f)