{"record":{"id":"159dd1fe83760e1c","repo":"nodejs/node","slug":"canceled","errorCode":null,"errorMessage":"canceled","messagePattern":"canceled","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"info","filePath":"deps/npm/lib/utils/open-url.js","lineNumber":76,"sourceCode":"\n  assertValidUrl(url)\n  outputMsg(json, title, url)\n\n  if (browser === false || !process.stdin.isTTY || !process.stdout.isTTY) {\n    return\n  }\n\n  const rl = readline.createInterface({\n    input: process.stdin,\n    output: process.stdout,\n  })\n\n  try {\n    await input.read(() => Promise.race([\n      rl.question(prompt, { signal }),\n      once(rl, 'error'),\n      once(rl, 'SIGINT').then(() => {\n        throw new Error('canceled')\n      }),\n    ]))\n    rl.close()\n    await openUrl(npm, url, 'Browser unavailable. Please open the URL manually')\n  } catch (err) {\n    rl.close()\n    if (err.name !== 'AbortError') {\n      throw err\n    }\n  }\n}\n\n// Rearrange arguments and return a function that takes the two arguments returned from the npm-profile methods that take an opener\nconst createOpener = (npm, title, prompt = 'Press ENTER to open in the browser...') =>\n  (url, opts) => openUrlPrompt(npm, url, title, prompt, opts)\n\nmodule.exports = {\n  openUrl,","sourceCodeStart":58,"sourceCodeEnd":94,"githubUrl":"https://github.com/nodejs/node/blob/1b2de5e052fc0fb95fd7fb6846dcec4ade598e9e/deps/npm/lib/utils/open-url.js#L58-L94","documentation":"Thrown by npm's openUrlPrompt when a SIGINT (Ctrl+C) is received on the readline interface while waiting for the user to press ENTER to open a URL in the browser. It represents an intentional user cancellation of a browser-based auth/OTP flow (e.g. npm login / adduser / publish with web auth), not a malfunction. The error is created as a plain Error (not AbortError), so the surrounding catch (which only suppresses AbortError) re-throws it.","triggerScenarios":"Running a command that calls createOpener/openUrlPrompt (npm login, npm adduser, npm publish with provenance/OTP web flow, npm token create), seeing the 'Press ENTER to open in the browser...' prompt, and pressing Ctrl+C (or a parent process forwarding SIGINT) before pressing ENTER.","commonSituations":"User changes their mind mid-login; a wrapper/CI process forwards Ctrl+C; an interactive prompt is mistakenly reached in a pseudo-TTY where Ctrl+C is sent automatically; the browser failed to open and the user aborts.","solutions":["Treat it as expected: this is the user cancelling, so simply re-run the command when ready or use a non-interactive auth method (e.g. npm config set //registry/:_authToken).","If running in CI, ensure stdin is not a TTY (process.stdin.isTTY === false) so the prompt is skipped entirely, or pre-set credentials via NPM_TOKEN.","If forwarding SIGINT unintentionally, run the npm command in a process group that does not relay Ctrl+C to the child.","To suppress in tooling, wrap the npm invocation and treat exit code / stderr containing 'canceled' as a benign cancellation."],"exampleFix":"// before: interactive prompt blocks CI, Ctrl+C surfaces as fatal 'canceled'\n// after: skip the prompt by providing a token non-interactively\nnpm config set //registry.npmjs.org/:_authToken \"$NPM_TOKEN\"\nnpm publish --access public","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"// openUrlPrompt is internal to npm; guard at the process level when invoking npm.\nconst { spawnSync } = require('node:child_process')\nconst res = spawnSync('npm', ['login'], { stdio: 'inherit' })\nif (res.status !== 0 && /canceled/.test(String(res.stderr))) {\n  console.log('user cancelled the browser login flow')\n}","preventionTips":["Provide credentials non-interactively (NPM_TOKEN / _authToken) so the browser prompt is never reached.","Ensure CI runners have a non-TTY stdin so openUrlPrompt returns early without prompting.","Do not forward SIGINT to the npm child process if cancellation is not intended."],"tags":["npm","cli","interactive","cancellation","auth"],"backgroundTag":null,"analyzedSha":"1b2de5e052fc0fb95fd7fb6846dcec4ade598e9e","analyzedAt":"2026-08-13T00:53:24.642Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}