pentaho/pentaho-kettle · error · TypeError
Failed to construct 'Promise': Please use the 'new'…
Error message
Failed to construct 'Promise': Please use the 'new' operator, this object constructor cannot be called as a function.
What it means
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.
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(...).
Example fix
// before
var p = Promise(function(resolve) { resolve(1); });
// after
var p = new Promise(function(resolve) { resolve(1); }); Defensive patterns
Strategy: type-guard
Validate before calling
// ensure constructor call sites use new
if (typeof Promise !== 'function') throw new Error('Promise unavailable'); Type guard
function isPromise(x) { return x != null && typeof x.then === 'function'; } Try / catch
try { p = new Promise(executor); } catch (e) { if (e instanceof TypeError && /new.*operator/.test(e.message)) { p = Promise.resolve(); } else throw e; } Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- You must pass a resolver function as the first argument to…
- TypeError
- polyfill failed because global object is unavailable in…
AI-assisted analysis of pentaho/pentaho-kettle@f3058517a1 (2026-09-13).
Data as JSON: /api/errors/81c6b44768e1412c.
Report an issue: GitHub.
Appendix: source
Thrown at plugins/core-ui/src/main/resources/app/pentaho/shim/_es6-promise/es6-promise.js:535
}
var lib$es6$promise$promise$resolve$$default = lib$es6$promise$promise$resolve$$resolve;
function lib$es6$promise$promise$reject$$reject(reason) {
/*jshint validthis:true */
var Constructor = this;
var promise = new Constructor(lib$es6$promise$$internal$$noop);
lib$es6$promise$$internal$$reject(promise, reason);
return promise;
}
var lib$es6$promise$promise$reject$$default = lib$es6$promise$promise$reject$$reject;
var lib$es6$promise$promise$$counter = 0;
function lib$es6$promise$promise$$needsResolver() {
throw new TypeError('You must pass a resolver function as the first argument to the promise constructor');
}
function lib$es6$promise$promise$$needsNew() {
throw new TypeError("Failed to construct 'Promise': Please use the 'new' operator, this object constructor cannot be called as a function.");
}
var lib$es6$promise$promise$$default = lib$es6$promise$promise$$Promise;
/**
Promise objects represent the eventual result of an asynchronous operation. The
primary way of interacting with a promise is through its `then` method, which
registers callbacks to receive either a promise’s eventual value or the reason
why the promise cannot be fulfilled.
Terminology
-----------
- `promise` is an object or function with a `then` method whose behavior conforms to this specification.
- `thenable` is an object or function that defines a `then` method.
- `value` is any legal JavaScript value (including undefined, a thenable, or a promise).
- `exception` is a value that is thrown using the throw statement.
- `reason` is a value that indicates why a promise was rejected.
- `settled` the final resting state of a promise, fulfilled or rejected.View on GitHub (pinned to f3058517a1)