Skip to content
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

Closed
wants to merge 1 commit into from

Conversation

demurgos
Copy link
Contributor

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.

@demurgos demurgos force-pushed the refactor-proxy-messages branch 2 times, most recently from ff67c87 to 96e195e Compare September 19, 2018 07:31
@demurgos
Copy link
Contributor Author

The CI failure seems to be an Appveyor issue (issue in their npm package). Fixed in #24.

@@ -4,6 +4,9 @@ if (process.platform === 'win32') {
spawn = require('cross-spawn')
}

function noop() {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why empty?

Copy link
Contributor Author

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)

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.

Copy link
Contributor Author

@demurgos demurgos Sep 19, 2018

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.

@demurgos demurgos force-pushed the refactor-proxy-messages branch 3 times, most recently from 4667fc2 to 4fdf3e9 Compare September 20, 2018 23:36
Copy link

@profnandaa profnandaa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

@isaacs
Copy link
Member

isaacs commented May 23, 2019

This looks good to me, but fails test coverage.

# 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.
Copy link
Member

@coreyfarrell coreyfarrell left a 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?

@demurgos
Copy link
Contributor Author

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.

@bcoe
Copy link
Member

bcoe commented Sep 6, 2019

@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.

@bcoe bcoe closed this Sep 6, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants