@deeeed/metamask-harness 0.50.4 → 0.50.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -2,6 +2,13 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ ## 0.50.5 - 2026-09-10
6
+
7
+ ### Fixed
8
+
9
+ - Avoid disabling and re-enabling the Extension after a fresh browser launch, which could cause `No SW` storage errors in reused wallet profiles. Keep build handoff for updates in an already-running browser.
10
+ - Keep the previously focused macOS app in front while Chrome starts, instead of restoring only after CDP is up. Do not let caffeinate declare user activity during that launch.
11
+
5
12
  ## 0.50.4 - 2026-09-10
6
13
 
7
14
  - Distinguish Extension startup/provider absence from attempted RPC failures and preserve diagnosed failed tabs during verification.
@@ -301,7 +301,7 @@ const {
301
301
  runtimeIdentityArgs,
302
302
  writeRuntimeIdentity,
303
303
  } = require(path.join('${SCRIPT_DIR}', 'lib/chrome-args.cjs'));
304
- const { captureMacFrontmostProcess, restoreMacFrontmostProcess } = require(path.join('${SCRIPT_DIR}', 'lib/macos-focus.cjs'));
304
+ const { captureMacFrontmostProcess, preserveMacFrontmostProcess } = require(path.join('${SCRIPT_DIR}', 'lib/macos-focus.cjs'));
305
305
 
306
306
  const SLOT_ID = '${SLOT_ID}';
307
307
  const AGENT_DIR = '${AGENT_DIR}';
@@ -345,7 +345,9 @@ const resumeWebpack = () => {
345
345
 
346
346
  const chromiumApp = path.dirname(path.dirname(path.dirname(chromium.executablePath())));
347
347
  const previousFrontmostPid = captureMacFrontmostProcess();
348
+ const holdOperatorFocus = () => preserveMacFrontmostProcess(previousFrontmostPid);
348
349
  execFileSync('open', ['-g', '-n', '-a', chromiumApp, '--args', ...args], { stdio: 'ignore' });
350
+ holdOperatorFocus();
349
351
  for (let i = 0; i < 60; i++) {
350
352
  try {
351
353
  const version = await new Promise((resolve, reject) => {
@@ -358,6 +360,7 @@ const resumeWebpack = () => {
358
360
  });
359
361
  if (version) break;
360
362
  } catch {}
363
+ holdOperatorFocus();
361
364
  await new Promise(r => setTimeout(r, 1000));
362
365
  }
363
366
  const browser = await chromium.connectOverCDP('http://127.0.0.1:' + CDP_PORT);
@@ -498,7 +501,7 @@ const resumeWebpack = () => {
498
501
  if (process.env.MM_HARNESS_FOCUS_BROWSER === '1') {
499
502
  await page.bringToFront().catch(() => {});
500
503
  } else {
501
- restoreMacFrontmostProcess(previousFrontmostPid);
504
+ holdOperatorFocus();
502
505
  }
503
506
 
504
507
  fs.writeFileSync(path.join(AGENT_DIR, 'extension.id'), extId);
@@ -42,7 +42,7 @@ const {
42
42
  validationLaunchQuarantineError,
43
43
  writeRuntimeIdentity,
44
44
  } = require('./lib/chrome-args.cjs');
45
- const { captureMacFrontmostProcess, restoreMacFrontmostProcess } = require('./lib/macos-focus.cjs');
45
+ const { captureMacFrontmostProcess, preserveMacFrontmostProcess } = require('./lib/macos-focus.cjs');
46
46
 
47
47
  if (process.argv.includes('--help') || process.argv.includes('-h')) {
48
48
  console.log(
@@ -165,6 +165,7 @@ const chromeArgs = [
165
165
  ];
166
166
  const logFd = fs.openSync(args['chrome-log'], 'a');
167
167
  const previousFrontmostPid = captureMacFrontmostProcess();
168
+ const holdOperatorFocus = () => preserveMacFrontmostProcess(previousFrontmostPid);
168
169
  let browserPid;
169
170
  try {
170
171
  const application = process.platform === 'darwin' ? macApplicationForExecutable(args['chrome-bin']) : null;
@@ -174,7 +175,8 @@ try {
174
175
  env: sanitizedChildEnv(),
175
176
  stdio: ['ignore', logFd, logFd],
176
177
  });
177
- browserPid = waitForOwnedCdpPid(cdpPort, args.profile, args['extension-dir']);
178
+ holdOperatorFocus();
179
+ browserPid = waitForOwnedCdpPid(cdpPort, args.profile, args['extension-dir'], holdOperatorFocus);
178
180
  if (browserPid === null) {
179
181
  throw new Error(`Chrome launched but did not expose CDP on 127.0.0.1:${cdpPort}`);
180
182
  }
@@ -186,7 +188,8 @@ try {
186
188
  stdio: ['ignore', logFd, logFd],
187
189
  });
188
190
  child.unref();
189
- browserPid = waitForOwnedCdpPid(cdpPort, args.profile, args['extension-dir']);
191
+ holdOperatorFocus();
192
+ browserPid = waitForOwnedCdpPid(cdpPort, args.profile, args['extension-dir'], holdOperatorFocus);
190
193
  if (browserPid === null) {
191
194
  if (child.pid) terminatePids([child.pid]);
192
195
  throw new Error(
@@ -220,15 +223,13 @@ try {
220
223
  );
221
224
  }
222
225
  if (process.platform === 'darwin') {
223
- const wake = spawn('caffeinate', ['-dimsu', '-w', String(browserPid)], {
226
+ const wake = spawn('caffeinate', ['-dims', '-w', String(browserPid)], {
224
227
  detached: true,
225
228
  stdio: 'ignore',
226
229
  });
227
230
  wake.unref();
228
231
  }
229
- if (process.env.MM_HARNESS_FOCUS_BROWSER !== '1') {
230
- restoreMacFrontmostProcess(previousFrontmostPid);
231
- }
232
+ holdOperatorFocus();
232
233
 
233
234
  function sanitizedChildEnv() {
234
235
  return {
@@ -264,12 +265,13 @@ function macApplicationForExecutable(executable) {
264
265
  return null;
265
266
  }
266
267
 
267
- function waitForOwnedCdpPid(port, profile, extensionDir) {
268
+ function waitForOwnedCdpPid(port, profile, extensionDir, onWait) {
268
269
  for (let i = 0; i < 300; i += 1) {
269
270
  const pid = cdpListenerPids(port).find((candidate) =>
270
271
  processIsOwnedHarnessBrowser(candidate, profile, extensionDir),
271
272
  );
272
273
  if (pid !== undefined) return pid;
274
+ if (typeof onWait === 'function' && i % 10 === 0) onWait();
273
275
  spawnSync('sleep', ['0.1']);
274
276
  }
275
277
  return null;
@@ -29,4 +29,13 @@ function restoreMacFrontmostProcess(pid) {
29
29
  }
30
30
  }
31
31
 
32
- module.exports = { captureMacFrontmostProcess, restoreMacFrontmostProcess };
32
+ function preserveMacFrontmostProcess(pid) {
33
+ if (process.env.MM_HARNESS_FOCUS_BROWSER === '1') return false;
34
+ return restoreMacFrontmostProcess(pid);
35
+ }
36
+
37
+ module.exports = {
38
+ captureMacFrontmostProcess,
39
+ preserveMacFrontmostProcess,
40
+ restoreMacFrontmostProcess,
41
+ };
@@ -228,7 +228,6 @@ NODE
228
228
  quoted_check_infura="$(printf '%q' "$SCRIPT_DIR/check-infura-readiness.cjs")"
229
229
  quoted_stamp_title="$(printf '%q' "$SCRIPT_DIR/stamp-runtime-title.cjs")"
230
230
  quoted_chrome_launcher="$(printf '%q' "$SCRIPT_DIR/launch-browser.cjs")"
231
- quoted_build_handoff="$(printf '%q' "$SCRIPT_DIR/build-handoff.cjs")"
232
231
  quoted_artifact_state="$(printf '%q' "$SCRIPT_DIR/artifact-runtime-state.cjs")"
233
232
  quoted_fixture_state="$(printf '%q' "$FIXTURE_STATE_ABS")"
234
233
  quoted_fixture_validation="$(printf '%q' "$FIXTURE_VALIDATION_ABS")"
@@ -353,7 +352,6 @@ NODE
353
352
  fi
354
353
  prepare_parts+=("$chrome_launch_cmd")
355
354
  prepare_parts+=("for i in {1..60}; do curl -fsS --max-time 1 http://127.0.0.1:${CDP_PORT}/json/version >/dev/null 2>&1 && break; sleep 1; done; curl -fsS --max-time 1 http://127.0.0.1:${CDP_PORT}/json/version >/dev/null")
356
- prepare_parts+=("node ${quoted_build_handoff} --target ${quoted_target} --runtime-dist ${quoted_runtime_dist} --cdp-port ${CDP_PORT}")
357
355
  if [ -n "$WALLET_FIXTURE_ABS" ]; then
358
356
  prepare_parts+=("bash ${quoted_seed_fixture} seed-cdp --target ${quoted_target} --fixture ${quoted_wallet_fixture} --state ${quoted_fixture_state} --cdp-port ${CDP_PORT} --extension-dir ${quoted_runtime_dist} --extension-id-file ${quoted_extension_id_file} --out ${quoted_fixture_validation}")
359
357
  fi
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@deeeed/metamask-harness",
3
- "version": "0.50.4",
3
+ "version": "0.50.5",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "mm-harness": "bin/mm-harness"