-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
TypeError: Q.nextTick.runAfter is not a function #764
Comments
I just started seeing this issue as well in a section of code that has not been touched in months. It doesn't happen in my development environment - only in my staging environment. It doesn't look like any of my module dependencies have changed either. If I find a solution I will post back here. |
Might be useful to share versions of Node.js and perhaps any modules that might be monkey-patching nextTick. Maybe do a search for occurrences of runAfter. There are no direct references to nextTick.runAfter in Q. |
Here is the relevant part of my package.json: |
Interestingly, I only have this problem on a single (virtual) machine. Even when I deploy the same setup to a different server (i.e, my qa server), it works fine. Also, not sure what you mean when you say "There are no direct references to nextTick.runAfter in Q." It is defined in q.js line 240, making it all the stranger that it doesn't find it. |
BTW, thanks for such a quick response. |
I have fixed my issue. In copying and pasting my package.json, I realized there were a couple of modules that I wasn't using any longer and removed them (grunt-git, grunt-spritesmith, throttle and signal-master). I also removed a "require" reference to one of the modules which was never being called (throttle). When I redeployed to the server that was reporting this error, the problem went away. Not sure if this helps @Nikolay211 or not, but I thought I would at least report how I resolved it. Thanks again for the response. |
Pardon, I was on the wrong branch. Q does in fact have a nextTick.runAfter now. |
We've just been bitten by this issue as well, after an upgrade to node v4 and latest versions of React, etc. We've not yet found a solution. |
Would anyone be able to Q.nextTick.toString() and manually verify that nextTick.runAfter is missing? Sounds like something is monkey-patching Q. |
looks like it was the |
Thanks @mdressman. Let’s keep this issue open to track how Q can be more resilient against this kind of monkey-patching. nextTick should close over its runAfter dependency instead of exposing it as public API. |
The rationale was to let people change the scheduler kind of like bluebird's setScheduler. I don't think we should explicitly hide it. |
Perhaps we can move it to a top level hook.
|
Any news on this? I would also like to change the scheduler for use with Angular where I would require all handlers to execute within the digest cycle.
Thanks. |
As the person who suggested the scheduler APi for bluebird I'll gladly implement an API for Q for the same thing if Kris asks. |
In the meantime, the following appears to work for Angular: // monkey-patch Q so that it schedules tasks during the digest cycle.
const angularNextTick = task => () => $rootScope.$evalAsync(task);
const {nextTick} = Q;
Q.nextTick = task => nextTick(angularNextTick(task));
const {runAfter} = nextTick;
Q.nextTick.runAfter = task => runAfter(angularNextTick(task)); And here is a simple test to confirm that it's always setInterval(() => {
Q.delay(10).then(() => console.log('$$phase =', $rootScope.$$phase));
}, 100); |
@zamb3zi , Attempting your workaround, runAfter comes back as undefined when destructuring nextTick after reassignment. I'm using [email protected]. |
While running above code I'm getting an error
stack trace: at trackRejection (/Volumes/DATA/projects/cirrent/api-dev/node_modules/q/q.js:1059:20)
at reject (/Volumes/DATA/projects/cirrent/api-dev/node_modules/q/q.js:1133:5)
at deferred.reject (/Volumes/DATA/projects/cirrent/api-dev/node_modules/q/q.js:634:16)
at Object.MaybeAnswer (/Volumes/DATA/projects/cirrent/api-dev/node_modules/API-Common/helpers/rpc.js:98:44)
at Channel.BaseChannel.dispatchMessage (/Volumes/DATA/projects/cirrent/api-dev/node_modules/amqplib/lib/channel.js:466:12)
at Channel.BaseChannel.handleDelivery (/Volumes/DATA/projects/cirrent/api-dev/node_modules/amqplib/lib/channel.js:475:15)
at emitOne (events.js:77:13)
at Channel.emit (events.js:169:7)
at /Volumes/DATA/projects/cirrent/api-dev/node_modules/amqplib/lib/channel.js:263:10
at Channel.content as handleMessage
I really couldn't find out what's gone wrong with my code. I'd appreciate if anyone can help with this.
The text was updated successfully, but these errors were encountered: