cli-tunnel 1.2.0-beta.2 → 1.2.0-beta.3

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.
Files changed (2) hide show
  1. package/dist/index.js +33 -4
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -448,6 +448,16 @@ async function main() {
448
448
  installProc.on('close', (code) => code === 0 ? resolve() : reject(new Error(`Install exited with code ${code}`)));
449
449
  installProc.on('error', reject);
450
450
  });
451
+ // Refresh PATH — winget updates the registry but current process has stale PATH
452
+ if (process.platform === 'win32') {
453
+ try {
454
+ const userPath = execFileSync('reg', ['query', 'HKCU\\Environment', '/v', 'Path'], { encoding: 'utf-8', stdio: ['pipe', 'pipe', 'pipe'] });
455
+ const sysPath = execFileSync('reg', ['query', 'HKLM\\SYSTEM\\CurrentControlSet\\Control\\Session Manager\\Environment', '/v', 'Path'], { encoding: 'utf-8', stdio: ['pipe', 'pipe', 'pipe'] });
456
+ const extractPath = (out) => out.split('\n').find(l => l.includes('REG_'))?.split('REG_EXPAND_SZ')[1]?.trim() || out.split('\n').find(l => l.includes('REG_'))?.split('REG_SZ')[1]?.trim() || '';
457
+ process.env.PATH = `${extractPath(userPath)};${extractPath(sysPath)}`;
458
+ }
459
+ catch { /* keep existing PATH */ }
460
+ }
451
461
  // Verify installation
452
462
  execFileSync('devtunnel', ['--version'], { stdio: 'pipe' });
453
463
  console.log(`\n ${GREEN}✓${RESET} devtunnel installed successfully!\n`);
@@ -601,7 +611,7 @@ async function main() {
601
611
  cols, rows, cwd,
602
612
  env: safeEnv,
603
613
  });
604
- // Detect CSPRNG crash (Node.js + node-pty + ConPTY issue) and retry with useConpty: false
614
+ // Detect CSPRNG crash (Node.js 23 + node-pty issue) and retry via cmd.exe wrapper
605
615
  let ptyExitedEarly = false;
606
616
  const earlyExitCheck = new Promise((resolve) => {
607
617
  ptyProcess.onExit(({ exitCode }) => {
@@ -614,13 +624,32 @@ async function main() {
614
624
  });
615
625
  await earlyExitCheck;
616
626
  if (ptyExitedEarly && process.platform === 'win32') {
617
- console.log(` ${YELLOW}⚠${RESET} ConPTY crash detected, retrying with legacy PTY backend...\n`);
618
- ptyProcess = nodePty.spawn(resolvedCmd, commandArgs, {
627
+ console.log(` ${YELLOW}⚠${RESET} CSPRNG crash detected (Node.js + PTY issue), retrying via cmd.exe wrapper...\n`);
628
+ // Spawn through cmd.exe /c — this adds a shell layer that avoids the crash
629
+ const cmdLine = [resolvedCmd, ...commandArgs].map(a => a.includes(' ') ? `"${a}"` : a).join(' ');
630
+ ptyProcess = nodePty.spawn('cmd.exe', ['/c', cmdLine], {
619
631
  name: 'xterm-256color',
620
632
  cols, rows, cwd,
621
633
  env: safeEnv,
622
- useConpty: false,
623
634
  });
635
+ // Check if cmd.exe wrapper also fails
636
+ let retryFailed = false;
637
+ const retryCheck = new Promise((resolve) => {
638
+ ptyProcess.onExit(({ exitCode }) => {
639
+ if (exitCode === 134 || exitCode === 3221226505) {
640
+ retryFailed = true;
641
+ resolve();
642
+ }
643
+ });
644
+ setTimeout(resolve, 2000);
645
+ });
646
+ await retryCheck;
647
+ if (retryFailed) {
648
+ const nodeVer = process.version;
649
+ console.log(` ${YELLOW}⚠${RESET} The command crashed due to a known Node.js ${nodeVer} + PTY compatibility issue.`);
650
+ console.log(` ${BOLD}Fix:${RESET} Install Node.js 22 LTS: ${GREEN}nvm install 22${RESET} or ${GREEN}winget install OpenJS.NodeJS.LTS${RESET}\n`);
651
+ process.exit(1);
652
+ }
624
653
  }
625
654
  ptyProcess.onData((data) => {
626
655
  process.stdout.write(data);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cli-tunnel",
3
- "version": "1.2.0-beta.2",
3
+ "version": "1.2.0-beta.3",
4
4
  "description": "Tunnel any CLI app to your phone — PTY + devtunnel + xterm.js",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",