-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Open
Labels
Description
This is an issue for the PR #3020
Describe the bug
When working with waspc/examples/todoApp, Wasp-cli failed to start db on Windows.
To Reproduce
Steps to reproduce the behavior:
- Clone commit 610469f
- Install Docker Desktop
- Install GHCup for building exe
- Change directory to ./waspc/example/todoApp/
- Start db from docker
cabal run wasp-cli -- start db- The console will show this error:
wasp-cli: Network.Socket.connect: <socket: 1200>: failed (Connection refused (WSAECONNREFUSED))Problem
This problem is related to the function to check if port is accepting connections or not.
wasp/waspc/src/Wasp/Util/Network/Socket.hs
Lines 17 to 38 in 610469f
| -- | Tests if port is accepting connections. | |
| -- Does so by trying to connect via socket to it (connection is closed immediately). | |
| -- It returns True if connection succeeds, or False if connection is refused | |
| -- (because port is not opened, nobody is listening on it). | |
| -- Rethrows connection exceptions in all other cases (e.g. when the host | |
| -- is unroutable). | |
| checkIfPortIsAcceptingConnections :: S.SockAddr -> IO Bool | |
| checkIfPortIsAcceptingConnections sockAddr = do | |
| bracket createSocket S.close' $ \sock -> | |
| try | |
| ( do | |
| S.connect sock sockAddr | |
| ) | |
| >>= \case | |
| Right () -> return True | |
| Left e -> | |
| if isConnRefusedException e | |
| then return False | |
| else throwIO e | |
| where | |
| createSocket = createIPv4TCPSocket | |
| isConnRefusedException e = (Errno <$> ioe_errno e) == Just eCONNREFUSED |
This exception on Windows does not have ioe_errno and we can get only the string Connection refused (WSAECONNREFUSED) from ioe_description
Environment:
- OS: Windows 11 (Build 10.0.26100)
- Cabal 3.12.1.0
- Stack 3.3.1
- HLS 2.10.0.0
- GHC 8.10.7 (base-4.14.3.0)
- Docker version 28.3.2, build 578ccf6
PS. I'm working on this issue.