Skip to content

[bug] posix_spawnp failed after calling spawn multiple times #670

Closed

Description

Environment details

  • OS: macOs
  • OS version: 12.0
  • node-pty version: 1.0.0

Issue description

I randomly get this error when calling spawn function multiple consecutive times:

/node_modules/node-pty/src/unixTerminal.ts:114
    const term = pty.fork(file, args, parsedEnv, cwd, this._cols, this._rows, uid, gid, (encoding === 'utf8'), helperPath, onexit);
                     ^
Error: posix_spawnp failed.

Here's a script to reproduce the problem.

import { spawn } from "node-pty"

const reproduce = async () => {
    for(let i = 0; i <= 1000; i++) {
        console.log(`the error is in ${i} iteration`)
        await spawn(`echo hello ${i}`, [], {
            name: 'xterm-color',
            cols: 80,
            rows: 30,
            cwd: process.env.HOME,
            env: process.env as any,
        })
    }
}

try {
    reproduce()
} catch (error) {
    console.error(error)
}

Activity

  1. changed the title [-]posix_spawnp failed after calling spawn multiple times[/-] [+][bug] posix_spawnp failed after calling spawn multiple times[/+] on Mar 6, 2024
  2. Tyriar commented on Dec 17, 2024

    @Tyriar
    Contributor

    My guess is you're hitting some OS limit. Also spawn does not return a promise, so you could be hitting async issues.

    As the example stands, I expect this to fail if you're trying to create 1000, so I'm closing this as out of scope. Please feel free to create a new issue if this happens with relatively few terminals.

  3. added
    *out-of-scope
    on Dec 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    *out-of-scope

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions