grpc / grpc/grpc-node

[Windows] Electron gRPC Server and Playwright + Electron gRPC Client connection issues

Open
#2,258 0 comments 0 reactions 0 assignees View on GitHub
package: @grpc/grpc-js
Dominant language
TypeScript
Stars
4.8k
Forks
716
Avg merge
2d 3h
Merged PRs (30d)
10

Description

### 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
```javascript
const server = new grpc.Server()
server.addService(service, implementation)
server.bindAsync('localhost:1234', grpc.ServerCredentials.createInsecure(), (error) => {
if (!error) {
server.start()
}
})
```

Playwright + Electron
```javascript
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",

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.