Jimp breaks Bluebird - PromisifyAll is not a function
See original GitHub issueExpected Behavior
Jimp should not break other modules
Current Behavior
I use Bluebird and Raven like so:
global.Promise = require('bluebird')
const raven = global.Promise.promisifyAll(require('raven'))
if I require Jimp in my project like so,
var Jimp = require('jimp')
It breaks Bluebird’s pormisifyAll function and I get the following error:
TypeError: global.Promise.promisifyAll is not a function
When I only remove var Jimp = require('jimp')
from my poject, it runs without problem.
Steps to Reproduce
- Include and use Bluebird and Raven like so (app.js):
global.Promise = require('bluebird')
const raven = global.Promise.promisifyAll(require('raven'))
-
Include Jimp in the project (for me it’s in a separate file for a controller):
var Jimp = require('jimp')
-
run
$ node app
Context
- Jimp Version: 0.6.0
- Operating System: Windows 10 Home version 1803 build 17134.407
- Node version: 8.12.0
Failure Logs
> npm run start
> oa-api@0.1.0 start <redacted>
> node app
WARN: `increment` should not be used as a schema path name unless you have disabled versioning.
C:\<redacted>\app.js:12
const raven = global.Promise.promisifyAll(require('raven')) // Sentry.io
^
TypeError: global.Promise.promisifyAll is not a function
at Object.<anonymous> (C:\<redacted>\app.js:12:30)
at Module._compile (module.js:653:30)
at Object.Module._extensions..js (module.js:664:10)
at Module.load (module.js:566:32)
at tryModuleLoad (module.js:506:12)
at Function.Module._load (module.js:498:3)
at Function.Module.runMain (module.js:694:10)
at startup (bootstrap_node.js:204:16)
at bootstrap_node.js:625:3
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! oa-api@0.1.0 start: `node app`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the oa-api@0.1.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\<redacted>\AppData\Roaming\npm-cache\_logs\2018-12-08T13_32_44_404Z-debug.log
Issue Analytics
- State:
- Created 5 years ago
- Comments:7
Top Results From Across the Web
PromisifyAll - Callback is not a function - Stack Overflow
Promisifies the entire object by going through the object's properties and creating an async equivalent of each function on the object and its ......
Read more >Promise.promisifyAll - Bluebird JS
Class property is a property with a function value that has a non-empty .prototype object. Returns the input object. Note that the original...
Read more >Top 10 Most Common Node.js Developer Mistakes - Toptal
I would go as far as to say that with Promise libraries like "bluebird," there is actually no reason to ever use the...
Read more >Promise in for loop node js - Caritas Castellaneta
The API for creating a promise isn't specified in Promise/A+In some use cases in Node. A callback function is called at the completion...
Read more >Changelog - Cypress Documentation
Fixed a regression introduced in the Electron browser in Cypress 10.8.0 where the CYPRESS_EVERY_NTH_FRAME environment variable was not being set appropriately ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Don’t support old versions. If the consumer of the library wants to use it with an older version of Node, have them include a polyfill where it makes sense for them.
When I set a breakpoint on the
require("jimp")
call and step into the module code, I find it very hard to follow. Especially if your goal is to find out where something might register a symbol onglobal
. But that might just be me. I just don’t like debugging transpiled code. And I only got into this issue randomly. I’m not even affected by it. So I guess we can ignore my personal preference here.Awesome findings! What would you suggest doing instead of babel polyfill to support old versions of node?
Also how are they a horror to debug? I’m interested in filing issues for this is you can provide examples.
PRs welcome ❤️
(I agree that using global like this is probably not the best idea @ananaszjoe is this the suggested way of using bluebird? I have never used it)