{"record":{"id":"1507e0a8a44d81c1","repo":"jackwener/OpenCLI","slug":"coupang-add-to-cart-navigation-failed-error-me","errorCode":null,"errorMessage":"coupang add-to-cart navigation failed: ${error?.message || error}","messagePattern":"coupang add-to-cart navigation failed: (.+?)","errorType":"exception","errorClass":"CommandExecutionError","httpStatus":null,"severity":"error","filePath":"clis/coupang/add-to-cart.js","lineNumber":119,"sourceCode":"    strategy: Strategy.COOKIE,\n    browser: true,\n    args: [\n        { name: 'product-id', positional: true, required: false, help: 'Coupang product ID' },\n        { name: 'url', required: false, help: 'Canonical product URL' },\n    ],\n    columns: ['ok', 'product_id', 'url', 'message'],\n    func: async (page, kwargs) => {\n        const rawProductId = kwargs['product-id'];\n        if (!rawProductId && !kwargs.url) {\n            throw new ArgumentError('Either --product-id or --url is required');\n        }\n        const productId = rawProductId\n            ? requireProductIdArg(rawProductId, 'product-id')\n            : requireProductIdArg(kwargs.url, '--url');\n        const targetUrl = canonicalizeProductUrl(kwargs.url, productId);\n        const finalUrl = targetUrl || canonicalizeProductUrl('', productId);\n        await page.goto(finalUrl).catch((error) => {\n            throw new CommandExecutionError(`coupang add-to-cart navigation failed: ${error?.message || error}`);\n        });\n        const result = await page.evaluate(buildAddToCartEvaluate(productId)).catch((error) => {\n            throw new CommandExecutionError(`coupang add-to-cart evaluation failed: ${error?.message || error}`);\n        });\n        const loginHints = result?.loginHints ?? {};\n        if (loginHints.hasLoginLink && !loginHints.hasMyCoupang) {\n            throw new AuthRequiredError('coupang.com', 'Please log into Coupang in Chrome and retry.');\n        }\n        const actualProductId = normalizeProductId(result?.currentProductId || productId);\n        if (result?.reason === 'PRODUCT_MISMATCH') {\n            const observed = actualProductId ? `got ${actualProductId}` : 'no product id observed';\n            throw new CommandExecutionError(`Product mismatch: expected ${productId}, ${observed}`);\n        }\n        if (result?.reason === 'OPTION_REQUIRED') {\n            throw new CommandExecutionError('This product requires option selection and is not supported in v1.');\n        }\n        if (result?.reason === 'ADD_TO_CART_BUTTON_NOT_FOUND') {\n            throw new CommandExecutionError('Could not find an add-to-cart button on the product page.');","sourceCodeStart":101,"sourceCodeEnd":137,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/coupang/add-to-cart.js#L101-L137","documentation":"This CommandExecutionError wraps a failure of page.goto(finalUrl) during the coupang add-to-cart flow. The Playwright navigation itself rejected (timeout, net::ERR_*, navigation interrupted) and the library catches it and rethrows with the underlying message. It means the browser never successfully loaded the product page, so the add-to-cart script could not run.","triggerScenarios":"`page.goto(finalUrl)` rejects: network timeout (default 30s), DNS failure, connection reset, net::ERR_ABORTED from a redirect/download, invalid finalUrl produced by canonicalizeProductUrl from a malformed --url, or the browser/page being closed mid-navigation.","commonSituations":"Slow or blocked network, Coupang bot protection aborting the navigation, a malformed product URL string passed as --url that canonicalization couldn't fix, page closed by prior code, or flaky corporate proxy causing timeouts.","solutions":["Read the wrapped error message for the root cause (net::ERR_NAME_NOT_RESOLVED, Timeout 30000ms exceeded, etc.) and address that specifically","Increase the navigation timeout: page.goto(finalUrl, { timeout: 60000, waitUntil: 'domcontentloaded' }) in your wrapper or pass a larger timeout to the command if supported","Verify the product id/URL is valid — navigate manually in Chrome to confirm the product page loads","Check network/proxy/VPN issues and ensure the Chrome instance the command drives has internet access"],"exampleFix":"// before\nawait page.goto(finalUrl); // flaky timeout on slow network\n// after\nawait page.goto(finalUrl, { timeout: 60000, waitUntil: 'domcontentloaded' });","handlingStrategy":"retry","validationCode":"const productId = '1234567890';\nif (!/^\\d+$/.test(productId)) throw new Error('product-id must be numeric digits');\nconst probe = await fetch(`https://www.coupang.com/vp/products/${productId}`, { method: 'HEAD' });\nif (!probe.ok) throw new Error(`product page not reachable: HTTP ${probe.status}`);","typeGuard":"function isNavFailure(e) {\n  return /add-to-cart navigation failed|net::ERR|Timeout \\d+ms exceeded/i.test(e?.message || '');\n}","tryCatchPattern":"try {\n  await runCli('coupang add-to-cart', '--product-id', productId);\n} catch (e) {\n  if (isNavFailure(e)) {\n    await new Promise(r => setTimeout(r, 5000));\n    return runCli('coupang add-to-cart', '--product-id', productId);\n  }\n  throw e;\n}","preventionTips":["Pre-check the product URL loads in a normal browser before automating","Use longer timeouts / waitUntil:'domcontentloaded' in custom wrappers","Retry once on transient net::ERR or timeout errors","Ensure the driven Chrome instance has network access (proxy/VPN)"],"tags":["navigation","playwright","coupang","timeout","browser-automation"],"backgroundTag":"page-navigation-failed","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T17:17:51.833Z"}