Skip to content

DurableClientContext gRPC channels are never closed after function invocation #254

@bachuv

Description

@bachuv

Summary

Each function invocation creates a new DurableClientContext with its own gRPC client/channel. When the invocation ends, close() is never called, leaving the channel orphaned.

Customer Impact

Customers see repeated warnings in logs:

 Previous channel ManagedChannelImpl{logId=X, target=localhost:4001} was not shutdown properly!!!
java.lang.RuntimeException: ManagedChannel allocation site 

at io.grpc.internal.ManagedChannelOrphanWrapper$ManagedChannelReference.<init>(ManagedChannelOrphanWrapper.java:102) 

Repro

Any Java Durable Functions app using DurableClientContext.getClient() will eventually see these warnings.

Root Cause

DurableClientContext does not implement AutoCloseable and never calls client.close().
PR #249 added proper shutdown logic to DurableTaskGrpcClient.close(), but that method is never called because:

  1. DurableClientContext does not implement AutoCloseable
  2. DurableClientContext has no close() method
  3. The Java Functions worker has no mechanism to close the client after invocation

Suggested fixes

  1. Close the client after each invocation — Make DurableClientContext implement AutoCloseable and have the Java worker call close() when the invocation ends

  2. Share one client across all invocations — Use a static singleton so only one gRPC channel is ever created per worker process

Metadata

Metadata

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions