You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The standard wisdom for ending a node-forked process is to have either the parent or the child detect when the job is done and then explicitly end the child process. Unfortunately, I seem to have a situation where this conventional approach is not available.
I'm using the node-tap module within a fork to run tests. Most people do this by spawning a process, but I'm adding behavior that requires coordinating parent and child. I'd like to use IPC, so I'm forking.
Node-tap defers its work via process.nextTick() and who knows what else. I can't catch the end of work with a setImmediate(), as that happens too soon. It seems that I need to wait for node-tap to tell me that it's done.
But node-tap can't do that. The calling script essentially queues jobs (tests) with each call to node-tap, and node-tap can't know that no more jobs are forthcoming. The best it could possibly do is keep a count of jobs completed and give me that count. Node-tap is popular, and it seems that this feature wasn't needed for anything else, so it would have to be a special request to add support for my forking use-case.
I could solve this problem if node would just tell me when it would normally exit the process were it not forked, without actually exiting the process. "Hey, I'd normally be exiting now, but I'm not gonna, because you forked me." Then node-tap wouldn't need special support for forking.
Is there a way for me to do this? How do I detect the following condition?
The process has reached the end of the script AND there is no pending work to do.
Thanks for any help you can offer! (I'm working with the node-tap folks too.)
The text was updated successfully, but these errors were encountered:
Something you may want to try is looking at what the (undocumented and not officially supported) process._getActiveHandles() and process._getActiveRequests() methods return (or their prettier wrapper, https://github.com/mafintosh/why-is-node-running), that should give you an idea of what keeps your process open.
And fyi, nodejs/node-v0.x-archive#2605 is no longer an issue with current Node versions – the IPC channel alone no longer keeps processes running.
Well, why-is-node-running is proving to be its own fight. I get the Cannot find module 'internal/linkedlist' error for not being compatible with node 5, and the --expose-internals solution cited here isn't working in my fork. I'm calling it a night. Thanks for your help!
The standard wisdom for ending a node-forked process is to have either the parent or the child detect when the job is done and then explicitly end the child process. Unfortunately, I seem to have a situation where this conventional approach is not available.
I'm using the node-tap module within a fork to run tests. Most people do this by spawning a process, but I'm adding behavior that requires coordinating parent and child. I'd like to use IPC, so I'm forking.
Node-tap defers its work via
process.nextTick()
and who knows what else. I can't catch the end of work with asetImmediate()
, as that happens too soon. It seems that I need to wait for node-tap to tell me that it's done.But node-tap can't do that. The calling script essentially queues jobs (tests) with each call to node-tap, and node-tap can't know that no more jobs are forthcoming. The best it could possibly do is keep a count of jobs completed and give me that count. Node-tap is popular, and it seems that this feature wasn't needed for anything else, so it would have to be a special request to add support for my forking use-case.
I could solve this problem if node would just tell me when it would normally exit the process were it not forked, without actually exiting the process. "Hey, I'd normally be exiting now, but I'm not gonna, because you forked me." Then node-tap wouldn't need special support for forking.
Is there a way for me to do this? How do I detect the following condition?
Thanks for any help you can offer! (I'm working with the node-tap folks too.)
The text was updated successfully, but these errors were encountered: