-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Error: the promise constructor cannot be invoked directly
benjamingr edited this page Feb 6, 2014
·
3 revisions
Error: the promise constructor cannot be invoked directly.
You can get this error for several reasons:
####1. You forgot to use new
when creating a new promise using new Promise(resolver)
syntax.
This can happen when you tried to do something like:
return Promise(function(resolve,reject){
//...
})
You can correct this by doing:
return Promise(function(resolve,reject){
//...
})
Please consider reading more about promisification and also consider checking out automatic promisification as well as Promise.method
####2. You are trying to subclass Promise
Bluebird does not support extending promises this way. Instead, see the Guide for Library Authors.