cli-tunnel 1.2.0-beta.2 → 1.2.0-beta.4
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/dist/index.js +43 -8
- 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`);
|
|
@@ -463,16 +473,18 @@ async function main() {
|
|
|
463
473
|
console.log(`\n ${DIM}More info: https://aka.ms/devtunnels/doc${RESET}`);
|
|
464
474
|
console.log(` ${DIM}Continuing without tunnel (local only)...${RESET}\n`);
|
|
465
475
|
}
|
|
466
|
-
|
|
467
|
-
|
|
476
|
+
}
|
|
477
|
+
if (devtunnelInstalled) {
|
|
478
|
+
try {
|
|
479
|
+
// Check if logged in before attempting tunnel creation
|
|
468
480
|
try {
|
|
469
481
|
const userInfo = execFileSync('devtunnel', ['user', 'show'], { encoding: 'utf-8', stdio: ['pipe', 'pipe', 'pipe'] });
|
|
470
|
-
if (userInfo.includes('not logged in') || userInfo.includes('No user')) {
|
|
482
|
+
if (userInfo.includes('not logged in') || userInfo.includes('No user') || userInfo.includes('Anonymous')) {
|
|
471
483
|
throw new Error('not logged in');
|
|
472
484
|
}
|
|
473
485
|
}
|
|
474
486
|
catch {
|
|
475
|
-
console.log(
|
|
487
|
+
console.log(`\n ${YELLOW}⚠ devtunnel not authenticated.${RESET}\n`);
|
|
476
488
|
const loginAnswer = await askUser(` Would you like to log in now? [Y/n] `);
|
|
477
489
|
if (loginAnswer === '' || loginAnswer === 'y' || loginAnswer === 'yes') {
|
|
478
490
|
try {
|
|
@@ -496,6 +508,10 @@ async function main() {
|
|
|
496
508
|
}
|
|
497
509
|
}
|
|
498
510
|
}
|
|
511
|
+
catch (err) {
|
|
512
|
+
console.log(` ${YELLOW}⚠${RESET} Tunnel failed: ${err.message}\n`);
|
|
513
|
+
devtunnelInstalled = false;
|
|
514
|
+
}
|
|
499
515
|
}
|
|
500
516
|
if (devtunnelInstalled) {
|
|
501
517
|
try {
|
|
@@ -601,7 +617,7 @@ async function main() {
|
|
|
601
617
|
cols, rows, cwd,
|
|
602
618
|
env: safeEnv,
|
|
603
619
|
});
|
|
604
|
-
// Detect CSPRNG crash (Node.js + node-pty
|
|
620
|
+
// Detect CSPRNG crash (Node.js 23 + node-pty issue) and retry via cmd.exe wrapper
|
|
605
621
|
let ptyExitedEarly = false;
|
|
606
622
|
const earlyExitCheck = new Promise((resolve) => {
|
|
607
623
|
ptyProcess.onExit(({ exitCode }) => {
|
|
@@ -614,13 +630,32 @@ async function main() {
|
|
|
614
630
|
});
|
|
615
631
|
await earlyExitCheck;
|
|
616
632
|
if (ptyExitedEarly && process.platform === 'win32') {
|
|
617
|
-
console.log(` ${YELLOW}⚠${RESET}
|
|
618
|
-
|
|
633
|
+
console.log(` ${YELLOW}⚠${RESET} CSPRNG crash detected (Node.js + PTY issue), retrying via cmd.exe wrapper...\n`);
|
|
634
|
+
// Spawn through cmd.exe /c — this adds a shell layer that avoids the crash
|
|
635
|
+
const cmdLine = [resolvedCmd, ...commandArgs].map(a => a.includes(' ') ? `"${a}"` : a).join(' ');
|
|
636
|
+
ptyProcess = nodePty.spawn('cmd.exe', ['/c', cmdLine], {
|
|
619
637
|
name: 'xterm-256color',
|
|
620
638
|
cols, rows, cwd,
|
|
621
639
|
env: safeEnv,
|
|
622
|
-
useConpty: false,
|
|
623
640
|
});
|
|
641
|
+
// Check if cmd.exe wrapper also fails
|
|
642
|
+
let retryFailed = false;
|
|
643
|
+
const retryCheck = new Promise((resolve) => {
|
|
644
|
+
ptyProcess.onExit(({ exitCode }) => {
|
|
645
|
+
if (exitCode === 134 || exitCode === 3221226505) {
|
|
646
|
+
retryFailed = true;
|
|
647
|
+
resolve();
|
|
648
|
+
}
|
|
649
|
+
});
|
|
650
|
+
setTimeout(resolve, 2000);
|
|
651
|
+
});
|
|
652
|
+
await retryCheck;
|
|
653
|
+
if (retryFailed) {
|
|
654
|
+
const nodeVer = process.version;
|
|
655
|
+
console.log(` ${YELLOW}⚠${RESET} The command crashed due to a known Node.js ${nodeVer} + PTY compatibility issue.`);
|
|
656
|
+
console.log(` ${BOLD}Fix:${RESET} Install Node.js 22 LTS: ${GREEN}nvm install 22${RESET} or ${GREEN}winget install OpenJS.NodeJS.LTS${RESET}\n`);
|
|
657
|
+
process.exit(1);
|
|
658
|
+
}
|
|
624
659
|
}
|
|
625
660
|
ptyProcess.onData((data) => {
|
|
626
661
|
process.stdout.write(data);
|