title: What is this unknown Google-originating client that triggers JavaScript errors in our PWA?
body: <p>We’re running Progressive Web Applications with push notifications enabled for Chrome and Samsung Internet, and encourage our users to add it to their home screen. We scrupulously log and monitor browser exceptions to preserve a high-quality service.</p>
  
  <p>Since May 22, 2018, we have noticed a sudden rise of puzzling JavaScript exceptions originating from calls to standard, feature-detected Web APIs
  that had previously never failed.</p>
  
  <p>For example, the following code would produce the following error, despite “push” clearly being a valid value per <a href="https://developer.mozilla.org/en-US/docs/Web/API/Permissions/query" rel="noreferrer">Permissions.query() specs</a>:</p>
  
  <pre><code>const permissionStatus = await navigator
    .permissions
    .query({ name: 'push', userVisibleOnly: true });
  </code></pre>
  
  <p> <code>TypeError: Failed to read the 'query' property from 'Permissions': The provided value 'push' is not a valid enum value of type PermissionName.</code></p>
  
  <p>Upon closer inspection, we noticed that all such errors happened during script execution by user agents that are <strong>not</strong> our actual customers. Rather, we see an unknown client query our application right after our user visiting:</p>
  
  <ol>
  <li><strong>User</strong> visits our PWA, no error is reported</li>
  <li><strong>User</strong> uses “Add to Home Screen” (most of the times), no error is reported</li>
  <li><strong>Unknown client</strong> visits our PWA, errors are reported.</li>
  </ol>
  
  <p>This unknown client performs a HTTP Request bearing characteristic patterns:</p>
  
  <ul>
  <li>URL is the exact same as the one visited by the User</li>
  <li>Originating IP Address is assigned to Google, Inc. (66.102.0.0/20 or 66.249.64.0/19 range)</li>
  <li>Referrer is “<a href="https://www.google.com/" rel="noreferrer">https://www.google.com/</a>”</li>
  <li>User Agent String somehow matches the one of the User: same version of Android, same device build, same browser, but a different browser version, always from this list:
  
  <ul>
  <li>Chrome/66.0.3359.126 (May 22 → May 30)</li>
  <li>Chrome/66.0.3359.158 (June 11 → June 25)</li>
  <li>SamsungBrowser/3.0 Chrome/38.0.2125.102 (June 25 → June 27)</li>
  <li>SamsungBrowser/6.4 Chrome/56.0.2924.87 (May 22 → May 30, June 25)</li>
  <li>SamsungBrowser/7.0 Chrome/59.0.3071.125 (May 22 → May 30, June 25)</li>
  </ul></li>
  </ul>
  
  <p>What’s more, these requests only occur intermittently, in a seemingly controlled way, as reflected by the dates above and the graph below:</p>
  
  <p><a href="https://i.stack.imgur.com/R01De.png" rel="noreferrer"><img src="https://i.stack.imgur.com/R01De.png" alt="Frequency of requests by unknown Google-originating client"></a></p>
  
  <p>This, and the fact that we detect usage of “Add to Home Screen” in most cases, make us wonder if this could be an experiment having to do with <a href="https://developers.google.com/web/fundamentals/integration/webapks" rel="noreferrer">WebAPKs</a>. However, this is undocumented, and thus very puzzling.</p>
  
  <p>What is this unknown Google-originating client?</p>
  
  <p>What is its purpose?</p>
  
  <p>How should developers detect them, and what measures should be taken?</p>
  
  <p><strong>August 2018 Update:</strong> Requests such as described above seem to have vanished completely now… But they could have been some sort of prototype of a somehow-similar kind of requests we’re seeing now. These requests of a new kind are still originating from Google servers, and seem to exclusively target the Web Manifest of our PWA, therefore no JavaScript error is triggered anymore. They all bear a Chrome/59+ user agent string clearly postfixed <code>(via Google-Chrome-WebAPK)</code>. Other browsers, such as Samsung Internet, have yet to be spotted.</p>