Skip to content

Commit d9e8896

Browse files
committed
feat: updated web auth fail logic
1 parent f3a22c5 commit d9e8896

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

cli/src/npm-client.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,7 @@ async function execNpmInteractive(
188188
let otpPromptSeen = false
189189
let authUrlSeen = false
190190
let authUrlTimeout: ReturnType<typeof setTimeout> | null = null
191+
let authUrlTimedOut = false
191192

192193
const env: Record<string, string> = {
193194
...(process.env as Record<string, string>),
@@ -233,6 +234,7 @@ async function execNpmInteractive(
233234

234235
authUrlTimeout = setTimeout(() => {
235236
if (resolved) return
237+
authUrlTimedOut = true
236238
logDebug('Auth URL timeout (90s) — killing process')
237239
logError('Authentication timed out after 90 seconds')
238240
child.kill()
@@ -266,7 +268,8 @@ async function execNpmInteractive(
266268
const cleanOutput = stripAnsi(output)
267269
logDebug('Interactive command exited:', { exitCode, output: cleanOutput })
268270

269-
const requiresOtp = (otpPromptSeen && !options.otp) || detectOtpRequired(cleanOutput)
271+
const requiresOtp =
272+
authUrlTimedOut || (otpPromptSeen && !options.otp) || detectOtpRequired(cleanOutput)
270273
const authFailure = detectAuthFailure(cleanOutput)
271274
const urls = extractUrls(cleanOutput)
272275

@@ -283,14 +286,17 @@ async function execNpmInteractive(
283286
}
284287
}
285288

289+
// If auth URL timed out, force a non-zero exit code so it's marked as failed
290+
const finalExitCode = authUrlTimedOut ? 1 : exitCode
291+
286292
resolve({
287293
stdout: cleanOutput.trim(),
288294
stderr: requiresOtp
289295
? 'This operation requires a one-time password (OTP).'
290296
: authFailure
291297
? 'Authentication failed. Please run "npm login" and restart the connector.'
292298
: filterNpmWarnings(cleanOutput),
293-
exitCode,
299+
exitCode: finalExitCode,
294300
requiresOtp,
295301
authFailure,
296302
urls: urls.length > 0 ? urls : undefined,

0 commit comments

Comments
 (0)