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

Socket discovery doesn't work across multiple PowerShell versions #44

Open
EverlastingBugstopper opened this issue Oct 2, 2023 · 4 comments
Labels
bug Something isn't working

Comments

@EverlastingBugstopper
Copy link

Describe the bug

Once a socket has been opened on one version of PowerShell, other versions of PowerShell cannot send/read messages to/from the opened socket.

To Reproduce

Using LocalSocketStream::connect("@known-name.sock"):

  1. Run connect in one process in PowerShell 5, it should succeed and does
  2. Run connect in another process in PowerShell 7, it should fail, but succeeds

Expected behavior

Instead of the second connection succeeding, it should fail because there is already a process attached to that socket.

@EverlastingBugstopper EverlastingBugstopper added the bug Something isn't working label Oct 2, 2023
@kotauskas
Copy link
Owner

Can you clarify what you mean by opening the socket on a version of PowerShell: calling into Interprocess from the PowerShell runtime via FFI (P/Invoke..?) or launching a Rust program via PowerShell that makes use of Interprocess?

I can (have both WinPS5 and PS7 installed, and am fairly familiar with both of them) and will look into thismyself after I roll out all of the general fixes that are currently in motion, but one possible cause that comes to mind is that if you installed PowerShell 7 through Windows Store, it might be doing isolation of some sort. Here's the best lead on why this could be that I could think of off the top of my head:

Windows 10, version 1709: Pipes are only supported within an app-container; ie, from one UWP process to another UWP process that's part of the same app. Also, named pipes must use the syntax \\.\pipe\LOCAL\ for the pipe name.

I assume that you're not on 1709, and am very sure that Windows Store PS7 isn't UWP, but I figured that something similar to this kind of isolation might be going on.

@EverlastingBugstopper
Copy link
Author

EverlastingBugstopper commented Oct 2, 2023

The latter: launching a Rust program via PowerShell using interprocess. My local reproduction is launching one instance from the terminal built into Rider (IntelliJ), with $PSVersionTable of 5.1 and the other in VSCode with a PSVersion of 7.2.8. One of them is PS Desktop and the other is PS Core which may be what's causing that isolation though I'm not really sure.

Interestingly, the error my program ends up spitting out is a "port is already in use" error - I'm using the socket connection to determine if one instance is a "leader" and should spin up the server and if one is a "follower" and should send messages that update the existing server.

If you want to try it out with the actual program I'm using you can clone https://github.com/apollographql/rover. ./examples/supergraph-demo has a few npm servers you can start with npm run start in ./examples/supergraph-demo/products and ./examples/supergraph-demo/pandas. Then you can run rover dev --name products --url http://localhost:4002 in one terminal and rover dev --name pandas --url http://localhost:4003 in another. This should work in the same version of PowerShell but fail in two different versions.

@kotauskas
Copy link
Owner

kotauskas commented May 8, 2024

Is this still an issue on 2.1.0?

@EverlastingBugstopper
Copy link
Author

Hey @kotauskas - I no longer work for Apollo so I'm not spending too much time with this project anymore. Thanks for all your help in the past though, hope you're well :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants