Skip to content

Commit 18e9c85

Browse files
evnchnclaude
andcommitted
Fix nodejs-mobile integration: override process.exit to prevent abort
Claude Code calls process.exit(1) during initialization (e.g., when not logged in), which kills the entire Node.js runtime embedded in iSH. Override process.exit in bootstrap to prevent this. Also added exit trace logging to /tmp/exit-trace.txt for debugging. Result: Claude Code CLI loads successfully inside iSH on ARM64 iOS. Status: LOADED (with Intl warning caught as uncaughtException). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent aee0bd4 commit 18e9c85

3 files changed

Lines changed: 15 additions & 1627 deletions

File tree

app/claude-native/bootstrap.mjs

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,17 @@
11
import net from 'net';
2+
import path from 'path';
3+
import { fileURLToPath } from 'url';
4+
var __dirname = path.dirname(fileURLToPath(import.meta.url));
25
Object.defineProperty(process, 'title', { get: function() { return 'c'; }, set: function() {} });
3-
var s = net.createServer(function(c) { c.write('ALIVE\n'); c.end(); });
4-
s.listen(7331, '0.0.0.0');
6+
// Override process.exit at JS level
7+
var _origExit = process.exit;
8+
process.exit = function(code) {
9+
try { require('fs').appendFileSync('/tmp/exit-trace.txt', 'exit('+code+') ' + new Error().stack.split('\n')[1] + '\n'); } catch(x) {}
10+
};
11+
var s = 'start', e = '';
12+
var srv = net.createServer(function(c) { c.write(s+'\n'+e+'\n'); c.end(); });
13+
srv.listen(7331, '0.0.0.0');
14+
process.on('uncaughtException', function(x) { e = x.message; s = 'crash'; });
15+
process.on('unhandledRejection', function(x) { e = (x&&x.message)||String(x); });
16+
s = 'importing';
17+
import(path.join(__dirname, 'claude_cli.js')).then(function() { s = 'LOADED'; }).catch(function(x) { e = x.message; s = 'err'; });

app/claude-native/claude_cli_small.js

Lines changed: 0 additions & 1624 deletions
This file was deleted.

app/claude-native/test_import.js

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)