-
-
Notifications
You must be signed in to change notification settings - Fork 14
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
refactor: IPC message forwarding #27
Conversation
ff67c87
to
96e195e
Compare
The CI failure seems to be an Appveyor issue (issue in their |
@@ -4,6 +4,9 @@ if (process.platform === 'win32') { | |||
spawn = require('cross-spawn') | |||
} | |||
|
|||
function noop() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why empty?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because it's a no-op function. It avoids to redefine an empty function every time I need one. (in this PR it's used only once, but there are other places in the file).
child.send(message, handle) | ||
} | ||
|
||
child.on('message', childListener) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Closure would have been cleaner in IMO:
child.on('message', function (message, handle) {
child.send(message, handle);
}
Same for L122.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can't unproxy it if you do not have a reference to the function. The current code does not completely cleans up the proxies, but the end goal is to have a general proxy function with proper clean up.
4667fc2
to
4fdf3e9
Compare
4fdf3e9
to
7b00697
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 👍
This looks good to me, but fails test coverage. |
7b00697
to
b1cc170
Compare
# Why `foregroundChild` is currently hard-coded to only support forwarding with the root process. To support a general `proxy` function between any two objects behaving like processes, we can begin by refactoring the internals to be more parametrized. # What Move the start of the IPC message forwarding to its own function.
b1cc170
to
47e2fdf
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need to add testing for this. Is this functionality is for non-windows only?
This should be a cross-platform feature. The failure is caused by the lack of tests for the clean-up when cancelling the proxy. I'll add some tests. |
@demurgos 👋 is this is still something you'd like to land feel free to reopen, it just needs some tests added and we could see it over the finish line. |
Why
foregroundChild
is currently hard-coded to only support forwarding with the root process. To support a generalproxy
function between any two objects behaving like processes, we can begin by refactoring the internals to be more parametrized.What
Move the start of the IPC message forwarding to its own function.