Node: 6.9.4
dockerode: 2.3.3
/Users/hyperlink/dev/temp/node_modules/dockerode/lib/docker.js:24
this.modem.Promise = opts.Promise || global.Promise;
^
TypeError: Cannot read property 'Promise' of undefined
at new Docker (/Users/hyperlink/dev/temp/node_modules/dockerode/lib/docker.js:24:28)
at Object.<anonymous> (/Users/hyperlink/dev/temp/dockerode.js:2:10)
at Module._compile (module.js:570:32)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)
at Module.runMain (module.js:604:10)
at run (bootstrap_node.js:394:7)
at startup (bootstrap_node.js:149:9)
Uh... at present you have to pass an object to Docker(), i.e:
docker = new Docker({})
@apocas Perhaps we should handle the case that if opts is undefined:
opts = opts || {}
this.modem = new Modem(opts);
this.modem.Promise = opts.Promise || global.Promise;
This has also broken the instantiation of docker-modem.
By doing:
docker = new Docker({}) or docker = new Docker({Promise: require("bluebird")})
When reaching this line this.modem = new Modem(opts); on line 23 of lib/docker.js, opts is a non null object which prevents defaultOpts() in the docker-modem constructor ever being called. This is now broken for anyone relying on docker-modem to read the DOCKER_* env variables for the connection to the docker host.
On another note, this is a breaking change for anyone who previously promisifed the prototypes with bluebird.promisifyAll. Bluebird throws when it encounters methods with Async already in the name.
Definitely not a patch release in it's current state!
Cheers
So would this be a better fix?
this.modem = new Modem(opts);
this.modem.Promise = opts && opts.Promise || global.Promise;
Doesn't fix the problem with runAsync making bluebird.promisifyAll blow up, but that's a another issue.
By the way, what's the reason behind doing this.modem.Promise rather than just this.Promise?
https://github.com/apocas/dockerode/commit/014f5be40437fc2576f910e4dc438ef05180c464
v2.3.4 just published fixes this.
@ThomWright modem is the object that's everywhere. Example: https://github.com/apocas/dockerode/blob/master/lib/container.js#L65
@ThomWright run now also features a promise interface, you need to manually promisify it.
Example in the readme: https://github.com/apocas/dockerode/blob/master/README.md#equivalent-of-docker-run-in-dockerode
@apocas this doesn't solve the first problem I mentioned above. Should I open another issue?
Cheers
@tanuck I already have a fix for it, but yes please so we can follow up there.
Most helpful comment
Uh... at present you have to pass an object to
Docker(), i.e:@apocas Perhaps we should handle the case that if
optsis undefined: