pentaho/pentaho-kettle · error · Error

polyfill failed because global object is unavailable in…

Error message

polyfill failed because global object is unavailable in this environment

What it means

The es6-promise polyfill's auto-polyfill IIFE needs a global object to attach Promise to. It tries window, self, then Function('return this')(). In strict environments (e.g. CSP blocking eval, or exotic sandboxed runtimes) all fail and it throws this Error, aborting the polyfill.

Solutions

  1. Ensure the script runs in a browser context where window/self exist.
  2. Relax CSP to allow 'unsafe-eval' for this script, or import the polyfill as a module (require('es6-promise').polyfill()) instead of relying on the auto-polyfill path.
  3. Skip the auto-polyfill when a native Promise already exists.
Defensive patterns

Strategy: fallback

Validate before calling

var hasGlobal = typeof window !== 'undefined' || typeof self !== 'undefined' || typeof global !== 'undefined';
if (!hasGlobal) { /* do not load auto-polyfill */ }

Type guard

function canPolyfill() { try { return !!Function('return this')(); } catch (e) { return false; } }

Try / catch

try { require('es6-promise').polyfill(); } catch (e) { /* native Promise or manual shim fallback */ }

Prevention

When it happens

Trigger: Loading the polyfill script in an environment with no window/self and a Content-Security-Policy that forbids new Function eval; running in a sandboxed VM/Web Worker variant lacking a global binding.

Common situations: Strict CSP headers on web apps blocking unsafe-eval; module bundlers evaluating the polyfill at build time in a sandbox; embedding the shim in restricted environments like some ad-safe iframes.

Understand the failure class

Background: "unsupported platform" / "not supported on this platform" errors: what they mean and how to fix them — this error's family across 47 libraries.

Related errors


AI-assisted analysis of pentaho/pentaho-kettle@f3058517a1 (2026-09-13). Data as JSON: /api/errors/60b2e498b5e6cdf4. Report an issue: GitHub.

Appendix: source

Thrown at plugins/core-ui/src/main/resources/app/pentaho/shim/_es6-promise/es6-promise.js:927

      Useful for tooling.
      @return {Promise}
    */
      'catch': function(onRejection) {
        return this.then(null, onRejection);
      }
    };
    function lib$es6$promise$polyfill$$polyfill() {
      var local;

      if (typeof global !== 'undefined') {
          local = global;
      } else if (typeof self !== 'undefined') {
          local = self;
      } else {
          try {
              local = Function('return this')();
          } catch (e) {
              throw new Error('polyfill failed because global object is unavailable in this environment');
          }
      }

      var P = local.Promise;

      if (P && Object.prototype.toString.call(P.resolve()) === '[object Promise]' && !P.cast) {
        return;
      }

      local.Promise = lib$es6$promise$promise$$default;
    }
    var lib$es6$promise$polyfill$$default = lib$es6$promise$polyfill$$polyfill;

    var lib$es6$promise$umd$$ES6Promise = {
      'Promise': lib$es6$promise$promise$$default,
      'polyfill': lib$es6$promise$polyfill$$default
    };

View on GitHub (pinned to f3058517a1)