{"record":{"id":"60b2e498b5e6cdf4","repo":"pentaho/pentaho-kettle","slug":"polyfill-failed-because-global-object-is-unavailable-in-this","errorCode":null,"errorMessage":"polyfill failed because global object is unavailable in this environment","messagePattern":"polyfill failed because global object is unavailable in this environment","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"plugins/core-ui/src/main/resources/app/pentaho/shim/_es6-promise/es6-promise.js","lineNumber":927,"sourceCode":"      Useful for tooling.\n      @return {Promise}\n    */\n      'catch': function(onRejection) {\n        return this.then(null, onRejection);\n      }\n    };\n    function lib$es6$promise$polyfill$$polyfill() {\n      var local;\n\n      if (typeof global !== 'undefined') {\n          local = global;\n      } else if (typeof self !== 'undefined') {\n          local = self;\n      } else {\n          try {\n              local = Function('return this')();\n          } catch (e) {\n              throw new Error('polyfill failed because global object is unavailable in this environment');\n          }\n      }\n\n      var P = local.Promise;\n\n      if (P && Object.prototype.toString.call(P.resolve()) === '[object Promise]' && !P.cast) {\n        return;\n      }\n\n      local.Promise = lib$es6$promise$promise$$default;\n    }\n    var lib$es6$promise$polyfill$$default = lib$es6$promise$polyfill$$polyfill;\n\n    var lib$es6$promise$umd$$ES6Promise = {\n      'Promise': lib$es6$promise$promise$$default,\n      'polyfill': lib$es6$promise$polyfill$$default\n    };\n","sourceCodeStart":909,"sourceCodeEnd":945,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/plugins/core-ui/src/main/resources/app/pentaho/shim/_es6-promise/es6-promise.js#L909-L945","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Ensure the script runs in a browser context where window/self exist.","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.","Skip the auto-polyfill when a native Promise already exists."],"exampleFix":null,"handlingStrategy":"fallback","validationCode":"var hasGlobal = typeof window !== 'undefined' || typeof self !== 'undefined' || typeof global !== 'undefined';\nif (!hasGlobal) { /* do not load auto-polyfill */ }","typeGuard":"function canPolyfill() { try { return !!Function('return this')(); } catch (e) { return false; } }","tryCatchPattern":"try { require('es6-promise').polyfill(); } catch (e) { /* native Promise or manual shim fallback */ }","preventionTips":["Import the polyfill as a module and call polyfill() explicitly instead of relying on the auto-detect script.","Check CSP settings allow the environments where the shim runs, or avoid eval-based global detection.","Feature-detect native Promise and skip polyfilling when present."],"tags":["polyfill","environment","csp","global-object"],"backgroundTag":"unsupported-platform","analyzedSha":"f3058517a153da500bf4551f46d79b91bf8ec552","analyzedAt":"2026-09-13T14:04:16.340Z","contentChangedAt":"2026-09-13T14:04:16.340Z","schemaVersion":2},"datasetVersion":"2026-09-20T23:17:15.980Z"}