Chrome Translation Service Fails When Using Puppeteer with Authenticated Proxy

I’m running into a problem when trying to use Chrome’s built-in translation feature through Puppeteer while connected to a proxy that requires authentication. The browser keeps showing an error message saying the page cannot be translated.

Here’s my current setup:

const puppeteer = require('puppeteer');

const proxyConfig = {}; // proxy configuration object

const browserInstance = await puppeteer.launch({
  headless: false,
  ignoreDefaultArgs: true,
  args: [
    ...puppeteer.defaultArgs({ headless: false }).map(argument => {
      if (argument.startsWith('--disable-features')) {
        return argument.replace('Translate,', '');
      }
      return argument;
    }),
    `--proxy-server=${proxyConfig.host}:${proxyConfig.port}`
  ]
});

browserInstance.on('targetcreated', async (newTarget) => {
    if (newTarget.type() === 'page') {
        const pageInstance = await newTarget.page();
        await pageInstance.authenticate({
            username: proxyConfig.user,
            password: proxyConfig.pass,
        });
    }
});

The translation feature tries to activate but fails every time. Are there specific Chrome flags or Puppeteer settings I should add to make the translation service work correctly with proxy authentication?

i ran into that too! adding --disable-web-security and --disable-features=VizDisplayCompositor to your args helped. also, make sure you’re not blocking translate.googleapis.com in your proxy settings. that was a killer for me.

This happens because Chrome’s translation service tries hitting Google’s servers before your proxy auth finishes. I fixed it by adding --enable-features=UseOzonePlatform and --ozone-platform=headless - forces a more stable connection. Also, call your auth right after launching the browser, not in the targetcreated event. I found page.authenticate() on the default page works way better than waiting for new targets. Check if your proxy handles SSL connections to translate.googleapis.com properly too - some need extra config for Google’s translation endpoints.

Chrome’s translation service and proxy authentication often conflict, which can lead to issues. One effective approach is to start with the --disable-features=TranslateUI flag, and enable it again once the page loads. Additionally, you should consider using --no-first-run and --disable-default-apps within your args. It’s crucial to authenticate as soon as the browser launches and the first page context is established, rather than waiting for the target to be created. This timing can significantly impact the functionality of the translation service.