question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Warning: a promise was created in a handler but was not returned from it

See original GitHub issue

I’m submitting a…

  • Bug report
  • Feature request

Current behavior

When running any migration (up or down) the following error presents itself:

Warning: a promise was created in a handler but was not returned from it
    at Function.Migration.registerHook (/Users/jessevanderwerf/taskspace/cloud-service/node_modules/db-migrate/lib/migration.js:41:20)
    at module.exports (/Users/jessevanderwerf/taskspace/cloud-service/node_modules/db-migrate/lib/commands/helper/migration-hook.js:4:20)
    at module.exports (/Users/jessevanderwerf/taskspace/cloud-service/node_modules/db-migrate/lib/commands/up.js:7:3)
    at run (/Users/jessevanderwerf/taskspace/cloud-service/node_modules/db-migrate/lib/commands/run.js:64:9)
    at Object.run (/Users/jessevanderwerf/taskspace/cloud-service/node_modules/db-migrate/api.js:439:16)
    at /Users/jessevanderwerf/taskspace/cloud-service/node_modules/db-migrate/bin/db-migrate:36:19
    at runCallback (timers.js:574:20)
    at tryOnImmediate (timers.js:554:5)
    at processImmediate [as _immediateCallback] (timers.js:533:5)
From previous event:
    at /Users/jessevanderwerf/taskspace/cloud-service/node_modules/db-migrate/bin/db-migrate:35:8
    at /Users/jessevanderwerf/taskspace/cloud-service/node_modules/resolve/lib/async.js:45:21
    at ondir (/Users/jessevanderwerf/taskspace/cloud-service/node_modules/resolve/lib/async.js:196:27)
    at onex (/Users/jessevanderwerf/taskspace/cloud-service/node_modules/resolve/lib/async.js:104:32)
    at /Users/jessevanderwerf/taskspace/cloud-service/node_modules/resolve/lib/async.js:24:24
    at FSReqWrap.oncomplete (fs.js:123:15)

Expected behavior

Migrations should return all promises and not warn on extra promises not returning.

Minimal reproduction of the problem with instructions

we have a psql db. we are currently running the following versions: db-migrate: 0.10.0 db-migrate-pg: 0.2.5 I have tried the latest published versions and still get the same error. install the latest version of db-migrate and db-migrate-pg and run a migration. I am attempting to run db-migrate up with no migrations (just to see if the warning goes away without our migrations) As a side note our migrations are all of the callback variety. It is happening for our whole team.

What is the motivation / use case for changing the behavior?

I would think that if db-migrate is leaving promises un-resolved they would like to know about it verify where (if it is in your codebase) and resolve them and if not then perhaps pin bluebird and notify them of the warnings.

Or

If its something in how we are currently using db-migrate we’d like to modify how we are doing things to remove the warning.

Environment


db-migrate version: 0.10.0
plugins with versions: 0.2.5
db-migrate driver with versions: 
db-migrate-pg v0.2.5 
Additional information:
- Node version: 6.5.0  
- Platform: Mac 

Others:

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
wzrdtalescommented, Feb 8, 2018

Also take a look at what the create command creates for you. The global.dbm was long since removed and is not needed anymore at all. There is a setup method now.

1reaction
wzrdtalescommented, Feb 8, 2018

Actually impossible to reproducce, even with your examples, I do not run into any trouble executing either of those.

However this style is really really old though.

The second one would look like this today

exports.up = async function (db) {
  await db.addForeignKey(
    NAME,
    'users',
    USERS_KEY,
    {
      _id: 'id'
    },
    {
      onDelete: 'CASCADE',
      onUpdate: 'RESTRICT'
    }
  );
  return db.addForeignKey(
    NAME,
    'user_agreements',
    AGREEMENTS,
    {
      agreement_id: 'id'
    },
    {
      onDelete: 'CASCADE',
      onUpdate: 'RESTRICT'
    }
  );
};

exports.down = async function (db) {
  await db.removeForeignKey(NAME, USERS_KEY);
  return db.removeForeignKey(NAME, AGREEMENTS);
};

As you’re still on node 6 and don’t have natively async/await you can fall back to:

exports.up = function (db) {
  return db
    .addForeignKey(
      NAME,
      'users',
      USERS_KEY,
      {
        _id: 'id'
      },
      {
        onDelete: 'CASCADE',
        onUpdate: 'RESTRICT'
      }
    )
    .then(() =>
      db.addForeignKey(
        NAME,
        'user_agreements',
        AGREEMENTS,
        {
          agreement_id: 'id'
        },
        {
          onDelete: 'CASCADE',
          onUpdate: 'RESTRICT'
        }
      )
    );
};

exports.down = function (db) {
  return db
    .removeForeignKey(NAME, USERS_KEY)
    .then(() => db.removeForeignKey(NAME, AGREEMENTS));
};
Read more comments on GitHub >

github_iconTop Results From Across the Web

Bluebird warning "A promise was created in a handler but was ...
If it determines that a Promise was created at any point while your handler is running (that includes anywhere down in the callstack),...
Read more >
A promise was created in a handler but was not returned from it.
Warning: a promise was created in a handler but was not returned from it. This usually means that you simply forgot a return...
Read more >
a promise was created in a handler but was not returned from it
If I run a simple Promise or any other Sequelize call (find, update, create) without the transaction it does not show this warning....
Read more >
a promise was created in a handler at but was not returned ...
Coding example for the question Warning: a promise was created in a handler at but was not returned from it [bluebird]-node.js.
Read more >
warning: a promise was created in a handler but was not returned ...
Bluebird is a fully featured JavaScript promises library with unmatched performance. bluebird npm. This is a playground to test code. It runs a...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found