{"record":{"id":"81c6b44768e1412c","repo":"pentaho/pentaho-kettle","slug":"failed-to-construct-promise-please-use-the-new-operator-this","errorCode":null,"errorMessage":"Failed to construct 'Promise': Please use the 'new' operator, this object constructor cannot be called as a function.","messagePattern":"Failed to construct 'Promise': Please use the 'new' operator, this object constructor cannot be called as a function\\.","errorType":"exception","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"plugins/core-ui/src/main/resources/app/pentaho/shim/_es6-promise/es6-promise.js","lineNumber":535,"sourceCode":"    }\n    var lib$es6$promise$promise$resolve$$default = lib$es6$promise$promise$resolve$$resolve;\n    function lib$es6$promise$promise$reject$$reject(reason) {\n      /*jshint validthis:true */\n      var Constructor = this;\n      var promise = new Constructor(lib$es6$promise$$internal$$noop);\n      lib$es6$promise$$internal$$reject(promise, reason);\n      return promise;\n    }\n    var lib$es6$promise$promise$reject$$default = lib$es6$promise$promise$reject$$reject;\n\n    var lib$es6$promise$promise$$counter = 0;\n\n    function lib$es6$promise$promise$$needsResolver() {\n      throw new TypeError('You must pass a resolver function as the first argument to the promise constructor');\n    }\n\n    function lib$es6$promise$promise$$needsNew() {\n      throw new TypeError(\"Failed to construct 'Promise': Please use the 'new' operator, this object constructor cannot be called as a function.\");\n    }\n\n    var lib$es6$promise$promise$$default = lib$es6$promise$promise$$Promise;\n    /**\n      Promise objects represent the eventual result of an asynchronous operation. The\n      primary way of interacting with a promise is through its `then` method, which\n      registers callbacks to receive either a promise’s eventual value or the reason\n      why the promise cannot be fulfilled.\n\n      Terminology\n      -----------\n\n      - `promise` is an object or function with a `then` method whose behavior conforms to this specification.\n      - `thenable` is an object or function that defines a `then` method.\n      - `value` is any legal JavaScript value (including undefined, a thenable, or a promise).\n      - `exception` is a value that is thrown using the throw statement.\n      - `reason` is a value that indicates why a promise was rejected.\n      - `settled` the final resting state of a promise, fulfilled or rejected.","sourceCodeStart":517,"sourceCodeEnd":553,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/plugins/core-ui/src/main/resources/app/pentaho/shim/_es6-promise/es6-promise.js#L517-L553","documentation":"The es6-promise constructor must be invoked with the `new` operator. Calling Promise(fn) as a plain function throws this TypeError via needsNew(), because the constructor relies on `this` being a newly created instance.","triggerScenarios":"var p = Promise(function(res, rej){...}) without `new`; higher-order code that does `var P = Promise; P(fn)` losing the constructor call; code ported from older promise libraries (like Q or jQuery Deferred style) where plain calls were allowed.","commonSituations":"Migrating legacy callback/promise code to the es6-promise shim; minified/transpiled output stripping `new`; aliasing the constructor in a helper that forgot the operator.","solutions":["Add the new operator: var p = new Promise(fn).","Use Promise.resolve/Promise.reject/Promise.all factories, which never need `new`.","If wrapping, ensure the wrapper itself is called with new or internally uses new Promise(...)."],"exampleFix":"// before\nvar p = Promise(function(resolve) { resolve(1); });\n// after\nvar p = new Promise(function(resolve) { resolve(1); });","handlingStrategy":"type-guard","validationCode":"// ensure constructor call sites use new\nif (typeof Promise !== 'function') throw new Error('Promise unavailable');","typeGuard":"function isPromise(x) { return x != null && typeof x.then === 'function'; }","tryCatchPattern":"try { p = new Promise(executor); } catch (e) { if (e instanceof TypeError && /new.*operator/.test(e.message)) { p = Promise.resolve(); } else throw e; }","preventionTips":["Always call promise constructors with new.","Prefer factory methods (resolve, reject, all, race) which need no new.","Lint with new-cap / enforce-new rules to catch bare constructor calls."],"tags":["promise","typeerror","missing-new-operator","polyfill"],"backgroundTag":"invalid-constructor-argument","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"}