{"record":{"id":"12d6960263d20cec","repo":"pulumi/pulumi","slug":"program-exited-with-non-zero-exit-code-d","errorCode":null,"errorMessage":"Program exited with non-zero exit code: %d","messagePattern":"Program exited with non-zero exit code: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"sdk/nodejs/cmd/pulumi-language-nodejs/main.go","lineNumber":1062,"sourceCode":"\t\tcontract.IgnoreError(os.Stdout.Sync())\n\t\tcontract.IgnoreError(os.Stderr.Sync())\n\t\t// Close the write end of the pipe to signal to the sniffer that it should stop scanning.\n\t\tcontract.IgnoreClose(w)\n\t\tif exiterr, ok := err.(*exec.ExitError); ok {\n\t\t\t// If the program ran, but exited with a non-zero error code.  This will happen often,\n\t\t\t// since user errors will trigger this.  So, the error message should look as nice as\n\t\t\t// possible.\n\t\t\tswitch code := exiterr.ExitCode(); code {\n\t\t\tcase 0:\n\t\t\t\t// This really shouldn't happen, but if it does, we don't want to render \"non-zero exit code\"\n\t\t\t\terr = fmt.Errorf(\"Program exited unexpectedly: %w\", exiterr)\n\t\t\tcase nodeJSProcessExitedAfterShowingUserActionableMessage:\n\t\t\t\t// Check if we got special exit code that means \"we already gave the user an\n\t\t\t\t// actionable message\". In that case, we can simply bail out and terminate `pulumi`\n\t\t\t\t// without showing any more messages.\n\t\t\t\treturn &pulumirpc.RunResponse{Error: \"\", Bail: true}\n\t\t\tdefault:\n\t\t\t\terr = fmt.Errorf(\"Program exited with non-zero exit code: %d\", code)\n\t\t\t\tsniffer.Wait()\n\t\t\t\tif sniffer.Detected() {\n\t\t\t\t\terr = fmt.Errorf(\"Program exited with non-zero exit code: %d. %s\", code, sniffer.Message())\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\t// Otherwise, we didn't even get to run the program.  This ought to never happen unless there's\n\t\t\t// a bug or system condition that prevented us from running the language exec.  Issue a scarier error.\n\t\t\terr = fmt.Errorf(\"Problem executing program (could not run language executor): %w\", err)\n\t\t}\n\n\t\terrResult = err.Error()\n\t}\n\n\t// notify our caller of the response we got from the nodejs process.  Note: this is done\n\t// unilaterally. this is how we signal to nodeLanguageHost.Run that we are done and it can\n\t// return to its caller.\n\treturn &pulumirpc.RunResponse{Error: errResult}","sourceCodeStart":1044,"sourceCodeEnd":1080,"githubUrl":"https://github.com/pulumi/pulumi/blob/793f7b2e160db4321fb7fb6b0607461e01cb251e/sdk/nodejs/cmd/pulumi-language-nodejs/main.go#L1044-L1080","documentation":"The user's NodeJS program exited with a non-zero exit code and the stderr sniffer did not detect a known pattern (like an OOM), so the language host reports a plain 'Program exited with non-zero exit code: <code>'. The actual user-facing error was usually already printed by the program itself to stderr/stdout above this message.","triggerScenarios":"cmd.Wait() returns *exec.ExitError with exit code not equal to 0 and not equal to nodeJSProcessExitedAfterShowingUserActionableMessage, and sniffer.Detected() is false (sdk/nodejs/cmd/pulumi-language-nodejs/main.go:1061-1062).","commonSituations":"TypeScript compile errors, unhandled exceptions in the Pulumi program, module-not-found, syntax errors — any crash of user code that prints its own message and exits nonzero.","solutions":["Read the stack trace/output printed by the program above this message and fix the root cause there.","Run the program's entry point directly with node/ts-node to reproduce and debug the exception.","Check that entryPoint in Pulumi.yaml points at a file that exists and compiles.","Install missing dependencies (`npm install` / `yarn install`) in the program directory."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Smoke-test the program before pulumi up\ncd $(pwd) && npx tsc --noEmit && node -e \"require('./bin')\" # or your entrypoint","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Run tsc/type checks and a local smoke run in CI before pulumi up.","Keep entryPoint in Pulumi.yaml correct.","Commit lockfiles and run npm install so deps resolve."],"tags":["nodejs","exit-code","user-program"],"backgroundTag":"non-zero-exit-code","analyzedSha":"793f7b2e160db4321fb7fb6b0607461e01cb251e","analyzedAt":"2026-08-31T09:36:43.099Z","schemaVersion":2},"datasetVersion":"2026-09-01T08:17:40.651Z"}