fix: disable HMR proxy in test mode to prevent WebSocket interference

In test mode (`meteor test --full-app`), `Meteor.isDevelopment` is true
but no rspack dev server is running (test mode uses `runRspackBuild`,
not `startRspackClientServe`). The HMR proxy was still being activated,
registering WebSocket upgrade handlers pointing to a port where nothing
listens. This caused SockJS WebSocket corruption ("Invalid frame header")
and subsequent DDP message failures (`msg.fields` arriving as undefined).

Adding `!Meteor.isTest && !Meteor.isAppTest` to the proxy guard ensures
it is only enabled when the dev server is actually running.
This commit is contained in:
dupontbertrand
2026-04-10 10:40:59 +02:00
parent e85ae994aa
commit 5001a31e40

View File

@@ -31,6 +31,7 @@ const RSPACK_ASSETS_REGEX = new RegExp(
const shouldEnableDevHMRProxy =
global?.Package?.["tools-core"] != null &&
Meteor.isDevelopment &&
!Meteor.isTest && !Meteor.isAppTest &&
!process.env.RSPACK_NATIVE;
if (shouldEnableDevHMRProxy) {
const { shuffleString } = require('meteor/tools-core/lib/string');