{"record":{"id":"b6462984907fcb1f","repo":"pentaho/pentaho-kettle","slug":"you-must-pass-a-resolver-function-as-the-first-argument-to","errorCode":null,"errorMessage":"You must pass a resolver function as the first argument to the promise constructor","messagePattern":"You must pass a resolver function as the first argument to the promise constructor","errorType":"exception","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"plugins/core-ui/src/main/resources/app/pentaho/shim/_es6-promise/es6-promise.js","lineNumber":531,"sourceCode":"\n      var promise = new Constructor(lib$es6$promise$$internal$$noop);\n      lib$es6$promise$$internal$$resolve(promise, object);\n      return promise;\n    }\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.","sourceCodeStart":513,"sourceCodeEnd":549,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/plugins/core-ui/src/main/resources/app/pentaho/shim/_es6-promise/es6-promise.js#L513-L549","documentation":"The bundled es6-promise polyfill's Promise constructor requires its first argument to be a function (the resolver). If `new Promise(x)` is called with a non-function or no argument, needsResolver() throws this TypeError. This mirrors the native ES6 Promise specification.","triggerScenarios":"new Promise() with no argument; new Promise('value') or new Promise(someObject) where a non-function was passed (e.g. a thenable instead of an executor).","commonSituations":"Wrapping callback APIs and accidentally passing the callback result rather than a function; copying code where the executor was refactored away; calling a promise factory that forwards arguments to Promise directly.","solutions":["Pass an executor function: new Promise(function(resolve, reject) { ... }).","If you already have a value, use Promise.resolve(value) instead of the constructor.","If you already have a failure, use Promise.reject(reason)."],"exampleFix":"// before\nvar p = new Promise(doWork());\n// after\nvar p = new Promise(function(resolve, reject) { doWork(resolve, reject); });","handlingStrategy":"type-guard","validationCode":"if (typeof executor !== 'function') { return Promise.resolve(value); }","typeGuard":"function isExecutor(x) { return typeof x === 'function' && x.length === 2; }","tryCatchPattern":"try { p = new Promise(executor); } catch (e) { if (e instanceof TypeError && /resolver/.test(e.message)) { p = Promise.resolve(value); } else throw e; }","preventionTips":["Always pass a function taking (resolve, reject) to new Promise.","Use Promise.resolve/reject/all for values you already have.","Never forward arbitrary arguments straight into the Promise constructor."],"tags":["promise","typeerror","polyfill","es6"],"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"}