Skip to content

Conversation

@jdalton
Copy link
Contributor

@jdalton jdalton commented Nov 6, 2025

Summary

Replace direct spawn('node', ...) calls with spawnNode() utility to ensure proper Node.js execution in SEA (Single Executable Application) contexts.

Problem

When running from a SEA binary, spawning 'node' directly may not work correctly. The spawnNode() utility handles this by:

  • Using system Node.js when available in SEA context
  • Falling back to SEA self-spawning with IPC handshake
  • Using process.execPath in non-SEA context

Changes

Files Updated

  • src/utils/dlx/spawn.mts - spawnCoanaDlx and spawnCdxgenDlx
  • src/commands/pip/cmd-pip.mts - Local sfw execution
  • src/utils/python/standalone.mts - Local python-cli execution

Pattern

// Before
spawn('node', [scriptPath, ...args], options)

// After
spawnNode([scriptPath, ...args], options)

Benefits

✅ Proper SEA binary support for local tool execution
✅ Automatic system Node.js detection
✅ Fallback to SEA self-spawning when needed
✅ Works correctly in all contexts (SEA, standard Node.js, local binaries)

Test Plan

  • Type check passes
  • Security checks pass
  • Test with SEA binary + local Coana
  • Test with SEA binary + local cdxgen
  • Test with SEA binary + local sfw
  • Test with standard Node.js installation

Impact

Low risk - Only affects local binary execution paths (when SOCKET_CLI_*_LOCAL_PATH is set). Standard dlx paths are unchanged.

Test User added 2 commits November 6, 2025 09:19
Replace direct spawn('node') calls with spawnNode() utility to properly
handle SEA binary execution. spawnNode() automatically:
- Uses system Node.js when available in SEA context
- Falls back to SEA self-spawning with IPC handshake
- Uses process.execPath in non-SEA context

This ensures local Coana and cdxgen binaries work correctly whether
running from SEA binary or standard Node.js installation.

Changes:
- Import spawnNode from ../spawn/spawn-node.mts
- Replace spawn('node', ...) with spawnNode(...) in spawnCoanaDlx
- Replace spawn('node', ...) with spawnNode(...) in spawnCdxgenDlx
- Remove unused spawn import from @socketsecurity/lib/spawn
Replace spawn('node') with spawnNode() for SEA compatibility when executing
local sfw and python-cli binaries. This ensures proper Node.js resolution
in SEA contexts.

Changes:
- cmd-pip.mts: Use spawnNode for local sfw execution
- python/standalone.mts: Use spawnNode for local python-cli execution
@jdalton jdalton closed this Nov 8, 2025
@jdalton jdalton deleted the jdalton/sea-spawn-node-compatibility branch November 8, 2025 15:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants