Skip to content

Commit d7d5949

Browse files
authored
Avoid global dyn rpc descriptor (#178)
Mutating is fine, but ensure its scoped to the base server - someone might have multiple servers created somewhere inside their application with the same names - this currently would cause a conflict
1 parent 7e505d9 commit d7d5949

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/server/base_restate_server.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ export abstract class BaseRestateServer {
6262
HostedGrpcServiceMethod<unknown, unknown>
6363
> = {};
6464
protected readonly discovery: ServiceDiscoveryResponse;
65+
protected readonly dynrpcDescriptor: RpcServiceProtoMetadata;
6566

6667
protected constructor(protocolMode: ProtocolMode) {
6768
this.discovery = {
@@ -71,6 +72,7 @@ export abstract class BaseRestateServer {
7172
maxProtocolVersion: 0,
7273
protocolMode: protocolMode,
7374
};
75+
this.dynrpcDescriptor = copyProtoMetadata(rpcServiceProtoMetadata);
7476
}
7577

7678
protected addDescriptor(descriptor: ProtoMetadata) {
@@ -232,7 +234,7 @@ export abstract class BaseRestateServer {
232234
name.length - serviceName.length - 1
233235
);
234236

235-
const desc = dynrpcDescriptor;
237+
const desc = this.dynrpcDescriptor;
236238
const serviceGrpcSpec = keyed
237239
? pushKeyedService(desc, name)
238240
: pushUnKeyedService(desc, name);
@@ -555,5 +557,3 @@ function createStringKeyedMethodDescriptor(
555557
desc.name = methodName;
556558
return desc;
557559
}
558-
559-
const dynrpcDescriptor = copyProtoMetadata(rpcServiceProtoMetadata);

0 commit comments

Comments
 (0)