OrchardCMS/OrchardCore · error · TypeError

RegExp#exec called on incompatible receiver

Error message

RegExp#exec called on incompatible receiver

What it means

This TypeError is the second check in the same core-js RegExp#exec polyfill: if the receiver R isn't a real RegExp (classof(R) !== 'RegExp') and has no callable exec, calling exec on it throws 'RegExp#exec called on incompatible receiver'. It means string.match/replace/split/RegExp#exec received something RegExp-like but not an actual RegExp (e.g. undefined or a string pattern where a RegExp was expected).

Solutions

  1. Convert string patterns to RegExp before use: new RegExp(pattern, flags)
  2. Don't pass regexes across iframe/window boundaries; recreate them in the target realm
  3. Check for code that reassigns RegExp or String.prototype methods and remove it
  4. Bypass the problematic polyfilled UMD path by importing the ESM vuedraggable build

Example fix

// before
str.match(pattern); // pattern is a plain string with special chars, not a RegExp

// after
str.match(new RegExp(pattern, 'i'));
Defensive patterns

Strategy: type-guard

Validate before calling

if (!(pattern instanceof RegExp)) { pattern = new RegExp(String(pattern)); }

Type guard

function isRegExp(v) { return Object.prototype.toString.call(v) === '[object RegExp]'; }

Try / catch

try { return regex.exec(str); } catch (e) { if (e instanceof TypeError && /incompatible receiver/.test(e.message)) { return new RegExp(regex.source, regex.flags).exec(str); } throw e; }

Prevention

When it happens

Trigger: Passing undefined/null/a string as a regex argument to String.prototype.match/replace used inside vendored code; a regex created in a different realm/iframe (cross-realm RegExp fails classof check); libraries swapping RegExp for a lookalike object.

Common situations: Dynamic patterns built from config where the value is a plain string passed where new RegExp(pattern) is required; cross-frame code (widget inside iframe) sharing regexes; minified bundle collisions overwriting RegExp globals.

Understand the failure class

Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.

Related errors


AI-assisted analysis of OrchardCMS/OrchardCore@4306c0717f (2026-09-13). Data as JSON: /api/errors/6d75d6839338d969. Report an issue: GitHub.

Appendix: source

Thrown at src/OrchardCore.Modules/OrchardCore.Resources/wwwroot/Vendor/vue-draggable-2.24.3/vuedraggable.umd.js:883

"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)