wolfsilver opened a new pull request, #129: URL: https://github.com/apache/skywalking-nodejs/pull/129
In the event of prolonged network outages, this may lead to severe memory issues. This pull request introduces a resource cleanup mechanism across the agent protocol and its gRPC client implementations to prevent memory leaks and ensure graceful shutdown. The main changes add a standardized optional `destroy()` method to key interfaces and classes, and implement cleanup logic for timers, event listeners, and buffers. Resource cleanup and lifecycle management: * Added an optional `destroy()` method to the `Protocol` and `Client` interfaces (`Protocol.ts`, `Client.ts`), and implemented it in `GrpcProtocol`, `HeartbeatClient`, and `TraceReportClient` to clean up resources such as timers, event listeners, and buffers. Memory leak prevention in gRPC clients: * In `HeartbeatClient`, implemented `destroy()` to clear the heartbeat timer and log cleanup. * In `TraceReportClient`, refactored event listener registration to store a reference for proper removal, and implemented `destroy()` to remove the event listener, clear timeouts and buffers, and log cleanup. Also added logic to limit buffer size and discard oldest segments with a warning to prevent memory leaks during network issues. Agent shutdown support: * Added a `destroy()` method to the `Agent` class to call the protocol's `destroy()` method, reset protocol state, and log the shutdown process. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
