{"record":{"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":"validation","errorClass":"Error","httpStatus":null,"severity":"error","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/8b1f829d3706404ab372cf97bd77ebcf86578d97/promise.js#L8-L44","documentation":"Thrown by createConnection (from 'mysql2/promise') after computing thePromise = opts.Promise || Promise. It fires only when that resolves to a falsy value, i.e. no native global Promise AND no opts.Promise supplied. Native Promise has shipped since Node 0.12, so on any supported runtime (Node 14+) this is effectively dead code — it triggers only if the global Promise has been deleted/overwritten with a falsy value or a polyfill-less exotic runtime is used. The error message is a legacy artifact from the bluebird era.","triggerScenarios":"Running on a JS runtime without a native Promise global and not passing opts.Promise; or test/sandbox code that deletes globalThis.Promise before requiring mysql2/promise; or explicitly passing { Promise: null } in such an environment.","commonSituations":"Edge embeded JS engines lacking Promise; security sandboxes that strip globals; legacy Node 0.10/0.12 deployments (unsupported by this driver's Node 14 minimum); mistaken polyfill configuration that sets opts.Promise to a non-constructor.","solutions":["Run on Node 14+ (the driver's minimum) — global Promise is always present and this branch is unreachable.","Pass a Promise implementation explicitly: createConnection({ Promise: require('bluebird'), ... }) or { Promise: globalThis.Promise }.","Ensure no code deletes or shadows the global Promise before mysql2 is required."],"exampleFix":"// before (exotic/polyfill-less runtime)\nconst conn = await createConnection({ host: 'localhost' });\n// after\nconst conn = await createConnection({ host: 'localhost', Promise: require('bluebird') });","handlingStrategy":"validation","validationCode":"function ensurePromise(opts) {\n  const P = (opts && opts.Promise) || globalThis.Promise;\n  if (typeof P !== 'function') {\n    throw new Error('No Promise implementation available; pass { Promise: require(\"bluebird\") } or use Node 14+');\n  }\n  return opts;\n}\n\nconst conn = await createConnection(ensurePromise(rawOpts));","typeGuard":"function hasUsablePromise(opts) {\n  const P = (opts && opts.Promise) || globalThis.Promise;\n  return typeof P === 'function' && typeof P.resolve === 'function';\n}","tryCatchPattern":null,"preventionTips":["Target Node 14+ — this guard is unreachable there.","Never delete or reassign globalThis.Promise in startup code.","If you pass opts.Promise, pass a real constructor (bluebird, Q, native), not null."],"tags":["promise-api","runtime","environment","legacy","polyfill"],"backgroundTag":null,"analyzedSha":"8b1f829d3706404ab372cf97bd77ebcf86578d97","analyzedAt":"2026-08-11T02:54:28.964Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}