New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
svileng opened this Issue May 6, 2016 · 5 comments

Comments

Projects
None yet
5 participants
@svileng

svileng commented May 6, 2016

I'm trying out knex and migrations for the first time, and I'm getting a few of those after I run migrate:latest:

Warning: a promise was created in a handler but was not returned from it
    at Runner.ensureConnection (/Users/Svilen/Development/testapp/node_modules/knex/lib/runner.js:156:26)
    at Runner.run (/Users/Svilen/Development/testapp/node_modules/knex/lib/runner.js:29:31)
    at QueryBuilder.Target.then (/Users/Svilen/Development/testapp/node_modules/knex/lib/interface.js:26:43)
    at Migrator._isLocked (/Users/Svilen/Development/testapp/node_modules/knex/lib/migrate/index.js:201:76)
    at /Users/Svilen/Development/testapp/node_modules/knex/lib/migrate/index.js:217:23
    at /Users/Svilen/Development/testapp/node_modules/knex/lib/transaction.js:42:18
From previous event:
    at /Users/Svilen/Development/testapp/node_modules/knex/lib/transaction.js:36:8
From previous event:
    at new Transaction (/Users/Svilen/Development/testapp/node_modules/knex/lib/transaction.js:29:27)
    at Client.transaction (/Users/Svilen/Development/testapp/node_modules/knex/lib/client.js:118:12)
    at Function.transaction (/Users/Svilen/Development/testapp/node_modules/knex/lib/util/make-knex.js:60:21)
    at Migrator._getLock (/Users/Svilen/Development/testapp/node_modules/knex/lib/migrate/index.js:216:24)
    at Migrator._runBatch (/Users/Svilen/Development/testapp/node_modules/knex/lib/migrate/index.js:241:19)
    at /Users/Svilen/Development/testapp/node_modules/knex/lib/migrate/index.js:74:25
    at tryOnImmediate (timers.js:534:15)
    at processImmediate [as _immediateCallback] (timers.js:514:5)
From previous event:
    at /Users/Svilen/Development/testapp/node_modules/knex/lib/migrate/index.js:73:12
From previous event:
    at Migrator.rollback (/Users/Svilen/Development/testapp/node_modules/knex/lib/migrate/index.js:69:28)
    at Command.<anonymous> (/Users/Svilen/Development/testapp/node_modules/knex/lib/bin/cli.js:114:37)
    at Command.listener (/Users/Svilen/Development/testapp/node_modules/commander/index.js:301:8)
    at emitTwo (events.js:100:13)
    at Command.emit (events.js:185:7)
    at Command.parseArgs (/Users/Svilen/Development/testapp/node_modules/commander/index.js:615:12)
    at Command.parse (/Users/Svilen/Development/testapp/node_modules/commander/index.js:458:21)
    at Liftoff.invoke (/Users/Svilen/Development/testapp/node_modules/knex/lib/bin/cli.js:145:13)
    at Liftoff.<anonymous> (/Users/Svilen/Development/testapp/node_modules/liftoff/index.js:193:16)
    at module.exports (/Users/Svilen/Development/testapp/node_modules/flagged-respawn/index.js:17:3)
    at Liftoff.<anonymous> (/Users/Svilen/Development/testapp/node_modules/liftoff/index.js:185:9)
    at /Users/Svilen/Development/testapp/node_modules/liftoff/index.js:159:9
    at /Users/Svilen/Development/testapp/node_modules/v8flags/index.js:108:14
    at /Users/Svilen/Development/testapp/node_modules/v8flags/index.js:36:12
    at /Users/Svilen/Development/testapp/node_modules/v8flags/index.js:47:7
    at _combinedTickCallback (internal/process/next_tick.js:67:7)
    at process._tickCallback (internal/process/next_tick.js:98:9)
    at Function.Module.runMain (module.js:449:11)
    at startup (node.js:146:18)
    at node.js:404:3

Here's my package.json:

{
  "name": "testapp",
  "version": "0.0.0",
  "private": true,
  "scripts": {
    "start": "node app.js",
    "dev": "DEBUG=testapp:* nodemon app.js",
    "migrate:make": "knex migrate:make",
    "migrate:latest": "knex migrate:latest",
    "migrate:rollback": "knex migrate:rollback"
  },
  "dependencies": {
    "bcryptjs": "^2.3.0",
    "body-parser": "^1.15.1",
    "connect-flash": "^0.1.1",
    "connect-session-knex": "^1.0.22",
    "conveyor-belt": "^1.0.0",
    "cookie-parser": "^1.4.1",
    "csurf": "^1.8.3",
    "debug": "^2.2.0",
    "express": "^4.13.4",
    "express-handlebars": "^3.0.0",
    "express-session": "^1.13.0",
    "knex": "^0.11.1",
    "morgan": "^1.7.0",
    "pg": "^4.5.5",
    "serve-favicon": "^2.3.0"
  },
  "devDependencies": {
    "debug": "^2.2.0",
    "nodemon": "^1.9.1"
  }
}

And the migration I've created:

exports.up = function(knex, Promise) {
  return Promise.all([
    knex.schema.createTable('users', function (table) {
      table.increments()
      table.string('name')
      table.timestamps()
    })
  ])
};

exports.down = function(knex, Promise) {
  return Promise.all([
    knex.schema.dropTable('users')
  ])
}

I also tried returning a Promise from knex.schema directly after I call createTable but that didn't make a difference. Any ideas what might be the problem? Thanks!

Note: could be related to petkaantonov/bluebird/issues/482

@svileng

This comment has been minimized.

svileng commented May 6, 2016

Reverting back to knex@0.10.0 removes the warnings, so it's probably related to the Bluebird upgrade done for knex@0.11.0.

@rhys-vdw

This comment has been minimized.

Collaborator

rhys-vdw commented May 7, 2016

@svileng Hm. Sounds like the fix @bendrucker applied is not appropriate for the newer version of Bluebird.

What do you think @wubzz?

@rhys-vdw rhys-vdw added the discussion label May 7, 2016

@gaastonsr

This comment has been minimized.

gaastonsr commented May 17, 2016

Using last version and receiving warnings but still working.

image

@ezmiller

This comment has been minimized.

ezmiller commented May 18, 2016

I'm experiencing the same bug, and fixed it temporarily by switching to v0.10.0 also.

ezmiller added a commit to ezmiller/intro-to-bookshelf that referenced this issue May 19, 2016

Add version test for knex
The newer version has a bug related to Promises
and migrations that's still being worked out. See
tgriesser/knex#1388

ezmiller added a commit to ezmiller/intro-to-bookshelf that referenced this issue May 19, 2016

Add version test for knex
The newer version has a bug related to Promises
and migrations that's still being worked out. See
tgriesser/knex#1388

agdevbridge added a commit to agdevbridge/knex that referenced this issue May 30, 2016

Fixes "a promise was created but was not returned" warning
This would fix Warning: a promise was created in a handler but not returned from it
Issue: tgriesser#1388

pletcher added a commit to learn-co-curriculum/node-js-intro-to-bookshelf that referenced this issue Jun 21, 2016

Adds master (#2)
* Add test suite

* Add blog_server stub

* Remove pg dependency

* Add version test for knex

The newer version has a bug related to Promises
and migrations that's still being worked out. See
tgriesser/knex#1388

* Modify server stub for migrations

* Change commenting

* Reorganize tests

* Add comment starting queue

* Remove unneeded code

* Add beginnings of README

* Add changes to README

* Add new seciton header

* Move text around

* Fix name

* Make minor language fixes

* Add last bit of README

* Fix spec

* Add some revisions

* Add blogging graphic

* Fix markdown for blog graphic

* Add minor revisions

* Add resources

* Fix minor typos

Add convenience links in first paragraph to Knex and Bookshelf (I hope
that's okay -- feel free to change if not)

* Omit done for synchronous tests

* Isolate server tests

pletcher added a commit to learn-co-curriculum/node-js-intro-to-bookshelf that referenced this issue Jun 21, 2016

Adds the solution (#1)
* Add package.json with dependencies

* Add package.json test

* Add beginnings of blog server

* Add beginnings of blog server tests

* Change name to models test

* Add server

* Add script to run server

* Start server using root hooks

* Add basic create user endpt

* Add server test suite with create user test

* Add a comment

* Rename test files to set run order

* Fix test name

* Change method of setting env

* Change tearDown to return promise

* Strengthen test

* Fix destroySchema

* Remove uneeded env setting

* Add posts model and tests

* Change user endpt to return id only

* Add create user endpt and test

* Save user id instead of fetching

* Add get user endpt and test

* Add GET /post/id endpt plus test

* Add comments model and tests

* Add create comment endpt plus tests

This commit also reconfigures the relationships a bit to use
default relationship field names.

* Remove send data on GET tests

* Change test name

* Add some error handling tests

* Add 500 error handling

* Add endpt to get all posts plus test

* Clean up

* Move code sections around

* Add pg to package.json test

* Add migrations implementation

* Remove pg dependency

* Add version test for knex

The newer version has a bug related to Promises
and migrations that's still being worked out. See
tgriesser/knex#1388

* Reorganize tests

* Modify method of exporting

* Change commenting

* Isolate server tests

* Add curly braces on single-line ifs

elhigu added a commit that referenced this issue Oct 19, 2016

Adding return's to address warnings mentioned in #1388 (#1740)
* Adding return's to address warnings mentioned in #1388

* Adding comments for returns
@gordysc

This comment has been minimized.

Contributor

gordysc commented Oct 19, 2016

I believe this can be closed out when the next release occurs (currently 0.12.5)

tgriesser added a commit that referenced this issue Oct 19, 2016

Adding return's to address warnings mentioned in #1388 (#1740)
* Adding return's to address warnings mentioned in #1388

* Adding comments for returns

tgriesser added a commit that referenced this issue Oct 19, 2016

Merge branch '0.12.x'
* 0.12.x:
  release 0.12.6
  Update changelog
  Remove postinstall script for now
  Gitignore yarn.lock
  Adding return's to address warnings mentioned in #1388 (#1740)

tgriesser added a commit that referenced this issue Oct 19, 2016

Merge branch 'master' into refactor
* master:
  release 0.12.6
  Update changelog
  Remove postinstall script for now
  Gitignore yarn.lock
  Adding return's to address warnings mentioned in #1388 (#1740)
  Adding return's to address warnings mentioned in #1388 (#1740)

RubenSlabbert added a commit to RubenSlabbert/knex that referenced this issue Nov 9, 2016

Adding return's to address warnings mentioned in tgriesser#1388 (tgri…
…esser#1740)

* Adding return's to address warnings mentioned in tgriesser#1388

* Adding comments for returns
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment