[Windows] Electron gRPC Server and Playwright + Electron gRPC Client connection issues
Problem description
I have an Electron app that spins up a gRPC server after app.whenReady() is called. I have some Playwright + Electron tests that spin up a gRPC client as a fixture available for each test. The instantiated gRPC client closes after a test has finished using client.close(). On Mac, this works great and tests pass without issue. On Windows, one test passes but the next test fails due to Error: 14 UNAVAILABLE: Connection dropped. I thought maybe I needed to gracefully shutdown the gRPC server on Windows so I added a server.tryShutdown call to an app.on('will-quit') listener. This made both tests fail with Error: 1 CANCELLED: Call cancelled.
What do I need to do to make this work on Windows?
Reproduction steps
Electron
const server = new grpc.Server()
server.addService(service, implementation)
server.bindAsync('localhost:1234', grpc.ServerCredentials.createInsecure(), (error) => {
if (!error) {
server.start()
}
})
Playwright + Electron
grpcClient: async ({}, run) => {
const packageDefinition = await load(
'path/to/protos',
{
keepCase: true,
longs: String,
enums: String,
defaults: true,
oneofs: true,
}
)
const proto = loadPackageDefinition(packageDefinition).package
const client = new proto.Service(
'localhost:1234',
credentials.createInsecure()
)
await run(client)
client.close()
},
Environment
- OS name, version and architecture: Windows 10 x64
- Node version: 16.16.0
- Node installation method: nvm
- Package name and version: "@grpc/grpc-js": "1.7.3",