{"record":{"id":"dc72842e6f097b51","repo":"denoland/deno","slug":"err-invalid-repl-eval-config","errorCode":"ERR_INVALID_REPL_EVAL_CONFIG","errorMessage":"Cannot specify both \"breakEvalOnSigint\" and \"eval\" for REPL","messagePattern":"Cannot specify both \"breakEvalOnSigint\" and \"eval\" for REPL","errorType":"validation","errorClass":"ERR_INVALID_REPL_EVAL_CONFIG","httpStatus":null,"severity":"error","filePath":"ext/node/polyfills/repl.ts","lineNumber":705,"sourceCode":"    this._isStandalone =\n      !!(options as Record<symbol, unknown>)[kStandaloneREPL];\n    this.useGlobal = !!useGlobal;\n    this.ignoreUndefined = !!ignoreUndefined;\n    this.replMode = replMode || REPL_MODE_SLOPPY;\n    this.underscoreAssigned = false;\n    this.last = undefined;\n    this.underscoreErrAssigned = false;\n    this.lastError = undefined;\n    this.breakEvalOnSigint = !!options.breakEvalOnSigint;\n    this.editorMode = false;\n    this[kContextId] = undefined;\n    this._initialPrompt = prompt as string;\n    // Stable resource name like Node's \"REPL1\"/\"REPL2\"/... - used as the\n    // filename for compiled scripts so stack traces match Node's output.\n    this._resourceName = getREPLResourceName();\n\n    if (this.breakEvalOnSigint && eval_) {\n      throw new ERR_INVALID_REPL_EVAL_CONFIG();\n    }\n\n    if ((options as Record<symbol, unknown>)[kStandaloneREPL]) {\n      _module.exports.repl = this;\n    } else {\n      // Non-standalone REPLs install the user-listener guard and route\n      // async errors via `process._fatalException`. The fatal-exception\n      // hook is global; the guard is refcounted so multiple concurrent\n      // REPLs co-exist and the process is left clean once the last exits.\n      // We use `_fatalException` (rather than process.on) so user code\n      // inspecting `process.listenerCount('uncaughtException')` sees 0,\n      // matching Node's domain-based REPL.\n      _installCaptureHook();\n      _addNewListenerGuard();\n      ArrayPrototypePush(_activeREPLs, this);\n      this._processListenersAttached = true;\n      this.once(\"exit\", () => {\n        const idx = ArrayPrototypeIndexOf(_activeREPLs, this);","sourceCodeStart":687,"sourceCodeEnd":723,"githubUrl":"https://github.com/denoland/deno/blob/9ad36f7a2cce60488e6ec52283efb32efddaf93a/ext/node/polyfills/repl.ts#L687-L723","documentation":"`repl.start()` accepts `breakEvalOnSigint` (abort the current evaluation on Ctrl+C) and `eval` (a custom function used to evaluate each line). They are mutually exclusive: the sigint-breaking mechanism only wraps the default eval path, so both Node and this polyfill throw ERR_INVALID_REPL_EVAL_CONFIG from the REPLServer constructor when both options are truthy.","triggerScenarios":"Calling `repl.start({ breakEvalOnSigint: true, eval: myEvalFn })`, or constructing `new REPLServer(...)` with both options set.","commonSituations":"Custom REPLs built on a vm/global-eval function where Ctrl+C interruption is also wanted; merging options objects copied from two different examples; adding `breakEvalOnSigint` to existing config without removing a previously-set `eval`.","solutions":["Remove `breakEvalOnSigint: true` if you supply a custom `eval` function","Drop the custom `eval` and use the default evaluator to keep Ctrl+C breaking","Implement interruption yourself: set a flag from a SIGINT listener and check it inside the custom eval function"],"exampleFix":"// before\nrepl.start({ breakEvalOnSigint: true, eval: myEval });\n// ERR_INVALID_REPL_EVAL_CONFIG\n\n// after\nrepl.start({ eval: myEval }); // handle Ctrl+C inside myEval if needed","handlingStrategy":"validation","validationCode":"function startReplSafely(opts = {}) {\n  if (opts.breakEvalOnSigint && typeof opts.eval === 'function') {\n    throw new TypeError(\n      'breakEvalOnSigint and eval are mutually exclusive for repl.start()',\n    );\n  }\n  return repl.start(opts);\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Treat breakEvalOnSigint and eval as mutually exclusive in project docs and lint rules","Centralize repl.start() options in one config object so conflicts are visible at review"],"tags":["repl","options","mutually-exclusive","node-compat"],"backgroundTag":"conflicting-options","analyzedSha":"9ad36f7a2cce60488e6ec52283efb32efddaf93a","analyzedAt":"2026-08-20T13:07:44.778Z","contentChangedAt":"2026-08-20T13:07:44.778Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}