{"id":"57fb8aa4f99e06de","repo":"sidorares/node-mysql2","slug":"no-promise-implementation-available-use-promise-en","errorCode":null,"errorMessage":"no Promise implementation available.Use promise-enabled node version or pass userland Promise implementation as parameter, for example: { Promise: require('bluebird') }","messagePattern":"no Promise implementation available\\.Use promise-enabled node version or pass userland Promise implementation as parameter, for example: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"critical","filePath":"promise.js","lineNumber":26,"sourceCode":"const createPool = require('./lib/create_pool.js');\nconst createPoolCluster = require('./lib/create_pool_cluster.js');\nconst PromiseConnection = require('./lib/promise/connection.js');\nconst PromisePool = require('./lib/promise/pool.js');\nconst {\n  captureStackHolder,\n  applyCapturedStack,\n} = require('./lib/promise/capture_local_err.js');\nconst makeDoneCb = require('./lib/promise/make_done_cb.js');\nconst PromisePoolConnection = require('./lib/promise/pool_connection.js');\nconst inheritEvents = require('./lib/promise/inherit_events.js');\nconst PromisePoolNamespace = require('./lib/promise/pool_cluster');\n\nfunction createConnectionPromise(opts) {\n  const coreConnection = createConnection(opts);\n  const stackHolder = captureStackHolder(createConnectionPromise);\n  const thePromise = opts.Promise || Promise;\n  if (!thePromise) {\n    throw new Error(\n      'no Promise implementation available.' +\n        'Use promise-enabled node version or pass userland Promise' +\n        \" implementation as parameter, for example: { Promise: require('bluebird') }\"\n    );\n  }\n  return new thePromise((resolve, reject) => {\n    coreConnection.once('connect', () => {\n      resolve(new PromiseConnection(coreConnection, thePromise));\n    });\n    coreConnection.once('error', (err) => {\n      applyCapturedStack(err, stackHolder);\n      reject(err);\n    });\n  });\n}\n\n// note: the callback of \"changeUser\" is not called on success\n// hence there is no possibility to call \"resolve\"","sourceCodeStart":8,"sourceCodeEnd":44,"githubUrl":"https://github.com/sidorares/node-mysql2/blob/5ebe8903d6aea2d8ea1490e11b52491526e50f19/promise.js#L8-L44","documentation":"createConnectionPromise() in promise.js resolves the Promise implementation from opts.Promise || Promise and throws at promise.js:26 if the result is falsy. On any modern Node (>=0.12) the global Promise exists, so this only fires when the global has been polyfilled away to a falsy value AND no opts.Promise was supplied. The library cannot construct the returned promise without a Promise constructor.","triggerScenarios":"Running on an ancient Node (<0.12) with no global Promise, explicitly deleting or shadowing global Promise in the process, or passing { Promise: null } / { Promise: false } in opts.","commonSituations":"Custom runtimes that strip globals, aggressive sandboxing, legacy embedded JS engines, or a config object that programmatically sets Promise to a falsy value. Extremely rare on supported Node versions.","solutions":["Run on Node >= 14 (the project minimum), where global Promise always exists","Pass a Promise implementation in options: createConnection({ ..., Promise: require('bluebird') })","Ensure no code deletes or overwrites global Promise with a falsy value","If using a bundler/transpiler that mangles globals, alias global.Promise correctly"],"exampleFix":"// before\nconst conn = await mysql.createConnection({ host: 'localhost', user: 'root' }); // throws if global Promise is missing\n\n// after\nconst conn = await mysql.createConnection({\n  host: 'localhost',\n  user: 'root',\n  Promise: require('bluebird'), // explicit userland Promise\n});","handlingStrategy":"validation","validationCode":"function ensurePromise(config) {\n  const P = (config && config.Promise) || (typeof Promise !== 'undefined' ? Promise : null);\n  if (!P) {\n    throw new Error('No Promise implementation: pass { Promise: require(\"bluebird\") } or upgrade Node');\n  }\n  return P;\n}","typeGuard":"function hasPromiseConstructor(config) {\n  const P = (config && config.Promise) || (typeof Promise !== 'undefined' ? Promise : null);\n  return typeof P === 'function';\n}","tryCatchPattern":null,"preventionTips":["Pin Node >= 14 in CI and in package.json engines","Never pass { Promise: null } or { Promise: false } in config","If you need a specific Promise lib, set it once in a shared config module"],"tags":["promise-api","runtime","config","environment"],"analyzedSha":"5ebe8903d6aea2d8ea1490e11b52491526e50f19","analyzedAt":"2026-08-03T18:58:53.602Z","schemaVersion":2}