sandboxbox 2.3.3 → 2.3.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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/utils/podman.js +55 -18
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sandboxbox",
3
- "version": "2.3.3",
3
+ "version": "2.3.4",
4
4
  "description": "Portable container runner with Podman - Claude Code & Playwright support. Works on Windows, macOS, and Linux.",
5
5
  "type": "module",
6
6
  "main": "cli.js",
package/utils/podman.js CHANGED
@@ -42,17 +42,32 @@ export function setupBackendNonBlocking(podmanPath) {
42
42
  console.log(color('yellow', '\nšŸ”§ Initializing Podman backend (one-time setup, takes 2-3 minutes)...'));
43
43
 
44
44
  try {
45
- // Check existing machines with timeout
45
+ // Check existing machines with shorter timeout
46
46
  let machines = [];
47
47
  try {
48
48
  const machineListOutput = execSync(`"${podmanPath}" machine list --format json`, {
49
49
  ...execOptions,
50
- timeout: 10000 // 10 seconds timeout
50
+ timeout: 3000 // 3 seconds timeout
51
51
  });
52
52
  machines = JSON.parse(machineListOutput || '[]');
53
53
  console.log(color('cyan', ` Found ${machines.length} existing machine(s)`));
54
54
  } catch (machineListError) {
55
- console.log(color('yellow', ' Could not list machines, assuming no machines exist'));
55
+ console.log(color('yellow', ' Could not list machines quickly, checking via info command...'));
56
+ // Try to detect if machine exists by checking for specific error messages
57
+ try {
58
+ execSync(`"${podmanPath}" info`, {
59
+ ...execOptions,
60
+ timeout: 3000
61
+ });
62
+ console.log(color('green', ' Backend is already working!'));
63
+ return true;
64
+ } catch (infoError) {
65
+ if (infoError.message.includes('127.0.0.1')) {
66
+ console.log(color('cyan', ' Machine exists but not running, proceeding...'));
67
+ } else {
68
+ console.log(color('yellow', ' Assuming no machines exist'));
69
+ }
70
+ }
56
71
  }
57
72
 
58
73
  if (machines.length === 0) {
@@ -88,40 +103,62 @@ export function setupBackendNonBlocking(podmanPath) {
88
103
  encoding: 'utf-8',
89
104
  stdio: 'pipe',
90
105
  shell: true,
91
- timeout: 10000
106
+ timeout: 3000 // 3 seconds timeout
92
107
  });
93
108
 
94
109
  if (statusOutput.includes('Running')) {
95
110
  console.log(color('green', ' Machine is already running'));
96
111
  } else {
97
112
  console.log(color('cyan', ' Starting Podman machine...'));
98
- execSync(`"${podmanPath}" machine start`, {
99
- stdio: 'inherit',
100
- shell: true,
101
- timeout: 180000 // 3 minutes
102
- });
113
+ startMachineWithRetry();
103
114
  }
104
115
  } catch (statusError) {
105
116
  console.log(color('cyan', ' Could not check status, attempting to start machine...'));
106
- execSync(`"${podmanPath}" machine start`, {
107
- stdio: 'inherit',
108
- shell: true,
109
- timeout: 180000 // 3 minutes
110
- });
117
+ startMachineWithRetry();
111
118
  }
112
119
 
113
- // Verify backend is actually working
120
+ // Give background process time to start, then verify once
121
+ console.log(color('cyan', ' Giving background process time to start...'));
122
+ const start = Date.now();
123
+ while (Date.now() - start < 15000) {
124
+ // Wait 15 seconds for background start
125
+ }
126
+
127
+ // Quick verification attempt
114
128
  console.log(color('cyan', ' Verifying backend connection...'));
115
129
  try {
116
- execSync(`"${podmanPath}" info`, execOptions);
130
+ execSync(`"${podmanPath}" info`, {
131
+ ...execOptions,
132
+ timeout: 5000 // 5 second timeout
133
+ });
134
+ console.log(color('green', ' Backend is ready!'));
117
135
  } catch (verifyError) {
118
- console.log(color('red', ` Backend verification failed: ${verifyError.message}`));
119
- console.log(color('yellow', ' Please ensure Podman machine is running manually'));
136
+ console.log(color('yellow', ' Backend still starting. This is normal for first-time setup.'));
137
+ console.log(color('cyan', ' If this persists, run manually:'));
138
+ const manualCmd = process.platform === 'win32'
139
+ ? `"${podmanPath}" machine init --rootful=false && "${podmanPath}" machine start`
140
+ : `"${podmanPath}" machine init && "${podmanPath}" machine start`;
141
+ console.log(color('cyan', ` ${manualCmd}`));
142
+ console.log(color('yellow', ' Then try sandboxbox again.'));
120
143
  return false;
121
144
  }
122
145
 
123
146
  console.log(color('green', '\nāœ… Podman backend setup completed!\n'));
124
147
  return true;
148
+
149
+ function startMachineWithRetry() {
150
+ // Use completely silent background start
151
+ console.log(color('cyan', ' Starting Podman machine silently in background...'));
152
+
153
+ const startProcess = spawn(`"${podmanPath}" machine start`, {
154
+ stdio: ['pipe', 'pipe', 'pipe'],
155
+ shell: true,
156
+ detached: true
157
+ });
158
+
159
+ startProcess.unref(); // Completely detach from parent
160
+ console.log(color('yellow', ' Machine start initiated in background (may take 1-2 minutes)'));
161
+ }
125
162
  } catch (setupError) {
126
163
  if (setupError.signal === 'SIGTERM') {
127
164
  console.log(color('red', '\nāŒ Setup timed out. Please run manually:'));