Netflix/pollyjs

"ember-inflector.globals" deprecations in @pollyjs/adapter-xhr

oliverlangan opened this issue · 1 comments

Description

Using the latest @pollyjs/ember package (5.1.0) shows a deprecation on the console of the app, both in dev mode and when the tests are first started. The deprecations are traced back to the eval used by ember-auto-import, and appear to happen before the app is started: and so it does not seem possible to suppress them via a standard deprecation filter.

There are four total deprecations, two for pluralize and two for singularize, all sharing the same id: "ember-inflector.globals". All four appear to exist within the @pollyjs/adapter-xhr package.

It is clear that this package is not directly using pluralize or singularize. The deprecation appears to be triggered instead by some in-lined code in the umd package:

            var run = function () {
              var id = +this;
              // eslint-disable-next-line no-prototype-builtins
              if (queue.hasOwnProperty(id)) {
                var fn = queue[id];
                delete queue[id];
                fn();
              }
            };

Error Message & Stack Trace

ok 1 Chrome 81.0 - [4 ms] - ESLint | addon: addon/index.js
    ---
        browser log: |
            WARN: DEPRECATION: String.prototype.pluralize() is deprecated. Please explicitly: import { pluralize } from 'ember-inflector'; [deprecation id: ember-inflector.globals]
                    at logDeprecationStackTrace (https://localhost:7357/assets/vendor.js:54825:21)
                    at HANDLERS.<computed> (https://localhost:7357/assets/vendor.js:54922:9)
                    at raiseOnDeprecation (https://localhost:7357/assets/vendor.js:54852:9)
                    at HANDLERS.<computed> (https://localhost:7357/assets/vendor.js:54922:9)
                    at invoke (https://localhost:7357/assets/vendor.js:54934:9)
                    at Object.deprecate (https://localhost:7357/assets/vendor.js:54890:28)
                    at String.get (https://localhost:7357/assets/vendor.js:175852:15)
                    at eval (webpack://__ember_auto_import__/./node_modules/@pollyjs/adapter-xhr/dist/umd/pollyjs-adapter-xhr.js?:1434:89)
                    at Array.reduce (<anonymous>)

Config

  return {
    enabled: env !== 'production',
    server: {
      apiNamespace: '/polly',
      recordingsDir: 'recordings'
    },
  };

...

    this.polly.configure({
      // when matching requests, ignore:
      // - headers (changes due to auth keys)
      // - body (also sometimes changes due to auth keys)
      // - base url (changes depending on runtime config API)
      // without this, it would re-record every run
      matchRequestsBy: {
        body: false,
        headers: false,
        url: {
          hostname: false,
          port: false,
          protocol: false,
        },
      },
    });

Dependencies

{
...
    "@pollyjs/ember": "^5.1.0",
...
    "ember-auto-import": "^1.6.0",
...
    "ember-cli": "^3.22.0",
...
    "ember-source": "3.13",
...
}

Environment

Tell us which operating system you are using, as well as which versions of Node.js and npm/yarn. If applicable, include the browser and the corresponding version.

Node.js v10.22.0
darwin 20.3.0
yarn 1.22.10

This issue went away completely (and was replaced with different, mysterious, pre-app-loading deprecations) as a result of upgrading various unrelated dependencies in our app.