Commit 809dfed
committed
fix: singleton SecretManagerServiceClient to prevent gRPC channel leak + OOM
Every call to getSecret() was creating a new SecretManagerServiceClient,
which opens a new gRPC channel. These channels were not being closed or
garbage collected, causing memory to grow ~488 MiB OOM within ~28 minutes
on a 512M Cloud Run instance.
Fix: use a module-level singleton client (created once per container instance)
and cache secret values in memory (secrets don't change at runtime).
This eliminates both the gRPC channel leak and the Secret Manager round-trips
on every webhook request.1 parent c41d1eb commit 809dfed
1 file changed
+19
-2
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
5 | | - | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
6 | 18 | | |
7 | 19 | | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
8 | 25 | | |
9 | | - | |
10 | 26 | | |
11 | 27 | | |
12 | 28 | | |
| |||
20 | 36 | | |
21 | 37 | | |
22 | 38 | | |
| 39 | + | |
23 | 40 | | |
24 | 41 | | |
25 | 42 | | |
| |||
0 commit comments