balderdashy/sails · warning

Bootstrap is taking a while to finish (${timeoutMs} millisec

Error message

Bootstrap is taking a while to finish (${timeoutMs} milliseconds).
If this is unexpected, and *if* the bootstrap function uses a callback,
maybe double-check to be sure that callback is getting called.
 [?] Read more: https://sailsjs.com/config/bootstrap

What it means

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.

Source

Thrown at lib/app/private/bootstrap.js:48

  // > w/ hook loading.)
  // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

  var sails = this;

  // Run bootstrap script if specified
  // Otherwise, do nothing and continue
  if (!sails.config.bootstrap) {
    return done();
  }

  sails.log.verbose('Running the setup logic in `sails.config.bootstrap(done)`...');

  // If bootstrap takes too long, display warning message
  // (just in case user forgot to call THEIR bootstrap's `done` callback, if
  // they're using that approach)
  var timeoutMs = sails.config.bootstrapTimeout || 30000;
  var timer = setTimeout(function bootstrapTookTooLong() {
    sails.log.warn(
    'Bootstrap is taking a while to finish ('+timeoutMs+' milliseconds).\n'+
    'If this is unexpected, and *if* the bootstrap function uses a callback,\n'+
    'maybe double-check to be sure that callback is getting called.\n'+
    ' [?] Read more: https://sailsjs.com/config/bootstrap');
  }, timeoutMs);

  var ranBootstrapFn = false;
  (function(proceed){
    try {
      var seemsToExpectCallback = true;
      if (sails.config.implementationSniffingTactic === 'analogOrClassical') {
        var hasParameters = (function(fn){
          var fnStr = fn.toString().replace(STRIP_COMMENTS_RX, '');
          var parametersAsString = fnStr.slice(fnStr.indexOf('(')+1, fnStr.indexOf(')'));
          // console.log('::',parametersAsString, parametersAsString.replace(/\s*/g,'').length);
          return parametersAsString.replace(/\s*/g,'').length !== 0;
        })(sails.config.bootstrap);//†
        seemsToExpectCallback = hasParameters;

View on GitHub (pinned to 7b76422cc2)

Solutions

  1. Ensure every code path in the bootstrap calls its done callback (including error branches: return done(err)).
  2. If the work is legitimately slow, raise sails.config.bootstrapTimeout in config/bootstrap.js.
  3. Move heavy one-time data seeding out of the bootstrap into a script so lift stays fast.

Example fix

// before
module.exports.bootstrap = async function(done) {
  if (process.env.NODE_ENV === 'production') { /* forgot done() */ }
  await seedData();
  done();
};
// after
module.exports.bootstrap = async function(done) {
  try {
    if (process.env.NODE_ENV === 'production') { return done(); }
    await seedData();
    return done();
  } catch (err) { return done(err); }
};
Defensive patterns

Strategy: try-catch

Validate before calling

if (sails.config.bootstrapTimeout && expectedBootstrapMs > sails.config.bootstrapTimeout) console.warn('bootstrapTimeout too low for expected bootstrap duration');

Try / catch

module.exports.bootstrap = function(done) {
  try {
    doAsyncWork(function(err) { return err ? done(err) : done(); });
  } catch (e) { return done(e); }
};

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Understand the failure class


AI-assisted analysis of balderdashy/sails@7b76422cc2 (2026-09-01). Data as JSON: /api/errors/9a83e69c968957e6. Report an issue: GitHub.