{"record":{"id":"9a83e69c968957e6","repo":"balderdashy/sails","slug":"bootstrap-is-taking-a-while-to-finish-timeoutms","errorCode":null,"errorMessage":"Bootstrap is taking a while to finish (${timeoutMs} milliseconds).\nIf this is unexpected, and *if* the bootstrap function uses a callback,\nmaybe double-check to be sure that callback is getting called.\n [?] Read more: https://sailsjs.com/config/bootstrap","messagePattern":"Bootstrap is taking a while to finish \\((.+?) milliseconds\\)\\.\nIf this is unexpected, and \\*if\\* the bootstrap function uses a callback,\nmaybe double-check to be sure that callback is getting called\\.\n \\[\\?\\] Read more: https://sailsjs\\.com/config/bootstrap","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"lib/app/private/bootstrap.js","lineNumber":48,"sourceCode":"  // > w/ hook loading.)\n  // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -\n\n  var sails = this;\n\n  // Run bootstrap script if specified\n  // Otherwise, do nothing and continue\n  if (!sails.config.bootstrap) {\n    return done();\n  }\n\n  sails.log.verbose('Running the setup logic in `sails.config.bootstrap(done)`...');\n\n  // If bootstrap takes too long, display warning message\n  // (just in case user forgot to call THEIR bootstrap's `done` callback, if\n  // they're using that approach)\n  var timeoutMs = sails.config.bootstrapTimeout || 30000;\n  var timer = setTimeout(function bootstrapTookTooLong() {\n    sails.log.warn(\n    'Bootstrap is taking a while to finish ('+timeoutMs+' milliseconds).\\n'+\n    'If this is unexpected, and *if* the bootstrap function uses a callback,\\n'+\n    'maybe double-check to be sure that callback is getting called.\\n'+\n    ' [?] Read more: https://sailsjs.com/config/bootstrap');\n  }, timeoutMs);\n\n  var ranBootstrapFn = false;\n  (function(proceed){\n    try {\n      var seemsToExpectCallback = true;\n      if (sails.config.implementationSniffingTactic === 'analogOrClassical') {\n        var hasParameters = (function(fn){\n          var fnStr = fn.toString().replace(STRIP_COMMENTS_RX, '');\n          var parametersAsString = fnStr.slice(fnStr.indexOf('(')+1, fnStr.indexOf(')'));\n          // console.log('::',parametersAsString, parametersAsString.replace(/\\s*/g,'').length);\n          return parametersAsString.replace(/\\s*/g,'').length !== 0;\n        })(sails.config.bootstrap);//†\n        seemsToExpectCallback = hasParameters;","sourceCodeStart":30,"sourceCodeEnd":66,"githubUrl":"https://github.com/balderdashy/sails/blob/7b76422cc27823df033572bdda5c4910a68b697f/lib/app/private/bootstrap.js#L30-L66","documentation":"Sails runs the bootstrap function (sails.config.bootstrap) with a timeout (config.bootstrapTimeout, default 30000ms). If the bootstrap has not finished when the timer fires, Sails logs this warning hinting that the bootstrap's done callback may never be getting called. It is a diagnostic, not fatal: the app waits for bootstrap completion regardless.","triggerScenarios":"config/bootstrap.js takes longer than bootstrapTimeout (default 30s) to invoke its done callback — e.g. long-running async work, or a code path that forgets to call done() on error or success.","commonSituations":"Bootstrap performs slow external calls (seeding large datasets, waiting on services), a conditional branch never calls done(), or the bootstrap returns a promise that rejects silently.","solutions":["Ensure every code path in the bootstrap calls its done callback (including error branches: return done(err)).","If the work is legitimately slow, raise sails.config.bootstrapTimeout in config/bootstrap.js.","Move heavy one-time data seeding out of the bootstrap into a script so lift stays fast."],"exampleFix":"// before\nmodule.exports.bootstrap = async function(done) {\n  if (process.env.NODE_ENV === 'production') { /* forgot done() */ }\n  await seedData();\n  done();\n};\n// after\nmodule.exports.bootstrap = async function(done) {\n  try {\n    if (process.env.NODE_ENV === 'production') { return done(); }\n    await seedData();\n    return done();\n  } catch (err) { return done(err); }\n};","handlingStrategy":"try-catch","validationCode":"if (sails.config.bootstrapTimeout && expectedBootstrapMs > sails.config.bootstrapTimeout) console.warn('bootstrapTimeout too low for expected bootstrap duration');","typeGuard":null,"tryCatchPattern":"module.exports.bootstrap = function(done) {\n  try {\n    doAsyncWork(function(err) { return err ? done(err) : done(); });\n  } catch (e) { return done(e); }\n};","preventionTips":["Always call done() on every branch of the bootstrap, including errors.","Keep bootstrap work short; move bulk seeding to scripts.","Tune sails.config.bootstrapTimeout if legitimate work is slow."],"tags":["bootstrap","timeout","callback","startup"],"backgroundTag":"bootstrap-callback-not-called","analyzedSha":"7b76422cc27823df033572bdda5c4910a68b697f","analyzedAt":"2026-09-01T04:01:57.104Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}