Skip to content

Conflict when running multiple Remotes simultaneously with Module Federation + Rspack #417

@lnuvy

Description

@lnuvy

Hi,

I'm using a Module Federation (MFE) architecture with Rspack, and I’d like to apply code-inspector to each remote module. However, it intermittently throws errors and stops working.

I’ve attached a screenshot of the console log when the error occurs (the blurred part is the monorepo root path).

Image

Sometimes the screenshot doesn’t appear, and when that happens, this kind of error shows up instead:

{rootDir}/node_modules/.pnpm/@code-inspector+core@1.2.10/node_modules/@code-inspector/core/dist/index.js:6

 */var kAe=50;St.TYPED_ARRAY_SUPPORT=jh.TYPED_ARRAY_SUPPORT!==void 0?jh.TYPED_ARRAY_SUPPORT:!0;vw();function vw(){return St.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function cf(e,t){if(vw()<t)throw new RangeError("Invalid typed array length");return St.TYPED_ARRAY_SUPPORT?(e=new Uint8Array(t),e.__proto__=St.prototype):(e===null&&(e=new St(t)),e.length=t),e}function St(e,t,r){if(!St.TYPED_ARRAY_SUPPORT&&!(this instanceof St))return new St(e,t,r);if(typeof e=="number"){if(typeof t=="string")throw new Error("If encoding is specified then the first argument must be a string");return L$(this,e)}return cce(this,e,t,r)}St.poolSize=8192;St._augment=function(e){return e.__proto__=St.prototype,e};function cce(e,t,r,i){if(typeof t=="number")throw new TypeError('"value" argument must not be a number');return typeof ArrayBuffer!="undefined"&&t instanceof ArrayBuffer?DAe(e,t,r,i):typeof t=="string"?NAe(e,t,r):LAe(e,t)}St.from=function(e,t,r){return cce(null,e,t,r)};St.TYPED_ARRAY_SUPPORT&&(St.prototype.__proto__=Uint8Array.prototype,St.__proto__=Uint8Array,typeof Symbol!="undefined"&&Symbol.species&&St[Symbol.species]);function pce(e){if(typeof e!="number")throw new TypeError('"size" argument must be a number');if(e<0)throw new RangeError('"size" argument must not be negative')}function OAe(e,t,r,i){return pce(t),t<=0?cf(e,t):r!==void 0?typeof i=="string"?cf(e,t).fill(r,i):cf(e,t).fill(r):cf(e,t)}St.alloc=function(e,t,r){return OAe(null,e,t,r)};function L$(e,t){if(pce(t),e=cf(e,t<0?0:M$(t)|0),!St.TYPED_ARRAY_SUPPORT)for(var r=0;r<t;++r)e[r]=0;return e}St.allocUnsafe=function(e){return L$(null,e)};St.allocUnsafeSlow=function(e){return L$(null,e)};function NAe(e,t,r){if((typeof r!="string"||r==="")&&(r="utf8"),!St.isEncoding(r))throw new TypeError('"encoding" must be a valid string encoding');var i=fce(t,r)|0;e=cf(e,i);var n=e.write(t,r);return n!==i&&(e=e.slice(0,n)),e}function bF(e,t){var r=t.length<0?0:M$(t.length)|0;e=cf(e,r);for(var i=0;i<r;i+=1)e[i]=t[i]&255;return e}function DAe(e,t,r,i){if(t.byteLength,r<0||t.byteLength<r)throw new RangeError("'offset' is out of bounds");if(t.byteLength<r+(i||0))throw new RangeError("'length' is out of bounds");return r===void 0&&i===void 0?t=new Uint8Array(t):i===void 0?t=new Uint8Array(t,r):t=new Uint8Array(t,r,i),St.TYPED_ARRAY_SUPPORT?(e=t,e.__proto__=St.prototype):e=bF(e,t),e}function LAe(e,t){if(dp(t)){var r=M$(t.length)|0;return e=cf(e,r),e.length===0||t.copy(e,0,0,r),e}if(t){if(typeof ArrayBuffer!="undefined"&&t.buffer instanceof ArrayBuffer||"length"in t)return typeof t.length!="number"||ZAe(t.length)?cf(e,0):bF(e,t);if(t.type==="Buffer"&&uce(t.data))return bF(e,t.data)}throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.")}function M$(e){if(e>=vw())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+vw().toString(16)+" bytes");return e|0}St.isBuffer=eCe;function dp(e){return!!(e!=null&&e._isBuffer)}St.compare=function(t,r){if(!dp(t)||!dp(r))throw new TypeError("Arguments must be Buffers");if(t===r)return 0;for(var i=t.length,n=r.length,s=0,a=Math.min(i,n);s<a;++s)if(t[s]!==r[s]){i=t[s],n=r[s];break}return i<n?-1:n<i?1:0};St.isEncoding=function(t){switch(String(t).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}};St.concat=function(t,r){if(!uce(t))throw new TypeError('"list" argument must be an Array of Buffers');if(t.length===0)return St.alloc(0);var i;if(r===void 0)for(r=0,i=0;i<t.length;++i)r+=t[i].length;var n=St.allocUnsafe(r),s=0;for(i=0;i<t.length;++i){var a=t[i];if(!dp(a))throw new TypeError('"list" argument must be an Array of Buffers');a.copy(n,s),s+=a.length}return n};function fce(e,t){if(dp(e))return e.length;if(typeof ArrayBuffer!="undefined"&&typeof ArrayBuffer.isView=="function"&&(ArrayBuffer.isView(e)||e instanceof ArrayBuffer))return e.byteLength;typeof e!="string"&&(e=""+e);var r=e.length;if(r===0)return 0;for(var i=!1;;)switch(t){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":case void 0:return Tw(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return r*2;case"hex":return r>>>1;case"base64":return vce(e).length;default:if(i)return Tw(e).length;t=(""+t).toLowerCase(),i=!0}}St.byteLength=fce;function MAe(e,t,r){var i=!1;if((t===void 0||t<0)&&(t=0),t>this.length||((r===void 0||r>this.length)&&(r=this.length),r<=0)||(r>>>=0,t>>>=0,r<=t))return"";for(e||(e="utf8");;)switch(e){case"hex":return HAe(this,t,r);case"utf8":case"utf-8":return mce(this,t,r);case"ascii":return VAe(this,t,r);case"latin1":case"binary":return WAe(this,t,r);case"base64":return UAe(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return KAe(this,t,r);default:if(i)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),i=!0}}St.prototype._isBuffer=!0;function Ad(e,t,r){var i=e[t];e[t]=e[r],e[r]=i}St.prototype.swap16=function(){var t=this.length;if(t%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var r=0;r<t;r+=2)Ad(this,r,r+1);return this};St.prototype.swap32=function(){var t=this.length;if(t%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var r=0;r<t;r+=4)Ad(this,r,r+3),Ad(this,r+1,r+2);return this};St.prototype.swap64=function(){var t=this.length;if(t%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var r=0;r<t;r+=8)Ad(this,r,r+7),Ad(this,r+1,r+6),Ad(this,r+2,r+5),Ad(this,r+3,r+4);return this};St.prototype.toString=function(){var t=this.length|0;return t===0?"":arguments.length===0?mce(this,0,t):MAe.apply(this,arguments)};St.prototype.equals=function(t){if(!dp(t))throw new TypeError("Argument must be a Buffer");return this===t?!0:St.compare(this,t)===0};St.prototype.inspect=function(){var t="",r=kAe;return this.length>0&&(t=this.toString("hex",0,r).match(/.{2}/g).join(" "),this.length>r&&(t+=" ... ")),"<Buffer "+t+">"};St.prototype.compare=function(t,r,i,n,s){if(!dp(t))throw new TypeError("Argument must be a Buffer");if(r===void 0&&(r=0),i===void 0&&(i=t?t.length:0),n===void 0&&(n=0),s===void 0&&(s=this.length),r<0||i>t.length||n<0||s>this.length)throw new RangeError("out of range index");if(n>=s&&r>=i)return 0;if(n>=s)return-1;if(r>=i)return 1;if(r>>>=0,i>>>=0,n>>>=0,s>>>=0,this===t)return 0;for(var a=s-n,o=i-r,l=Math.min(a,o),u=this.slice(n,s),c=t.slice(r,i),f=0;f<l;++f)if(u[f]!==c[f]){a=u[f],o=c[f];break}return a<o?-1:o<a?1:0};function hce(e,t,r,i,n){if(e.length===0)return-1;if(typeof r=="string"?(i=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),r=+r,isNaN(r)&&(r=n?0:e.length-1),r<0&&(r=e.length+r),r>=e.length){if(n)return-1;r=e.length-1}else if(r<0)if(n)r=0;else return-1;if(typeof t=="string"&&(t=St.from(t,i)),dp(t))return t.length===0?-1:tW(e,t,r,i,n);if(typeof t=="number")return t=t&255,St.TYPED_ARRAY_SUPPORT&&typeof Uint8Array.prototype.indexOf=="function"?n?Uint8Array.prototype.indexOf.call(e,t,r):Uint8Array.prototype.lastIndexOf.call(e,t,r):tW(e,[t],r,i,n);throw new TypeError("val must be string, number or Buffer")}function tW(e,t,r,i,n){var s=1,a=e.length,o=t.length;if(i!==void 0&&(i=String(i).toLowerCase(),i==="ucs2"||i==="ucs-2"||i==="utf16le"||i==="utf-16le")){if(e.length<2||t.length<2)return-1;s=2,a/=2,o/=2,r/=2}function l(m,g){return s===1?m[g]:m.readUInt16BE(g*s)}var u;if(n){var c=-1;for(u=r;u<a;u++)if(l(e,u)===l(t,c===-1?0:u-c)){if(c===-1&&(c=u),u-c+1===o)return c*s}else c!==-1&&(u-=u-c),c=-1}else for(r+o>a&&(r=a-o),u=r;u>=0;u--){for(var f=!0,h=0;h<o;h++)if(l(e,u+h)!==l(t,h)){f=!1;break}if(f)return u}return-1}St.prototype.includes=function(t,r,i){return this.indexOf(t,r,i)!==-1};St.prototype.indexOf=function(t,r,i){return hce(this,t,r,i,!0)};St.prototype.lastIndexOf=function(t,r,i){return hce(this,t,r,i,!1)};function RAe(e,t,r,i){r=Number(r)||0;var n=e.length-r;i?(i=Number(i),i>n&&(i=n)):i=n;var s=t.length;if(s%2!==0)throw new TypeError("Invalid hex string");i>s/2&&(i=s/2);for(var a=0;a<i;++a){var o=parseI

Even when I assign different ports to each remote, the error still happens.
The only case where it works without errors is when the plugin is applied only to the host.
However, in that case, due to the MFE structure, I can’t inspect the locations of smaller remote components.

If there’s any recommended way to make it work properly in this setup, I’d really appreciate your guidance.
Thank you! 🙏

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions