Commit 702688a
committed
feat: add destroy() to MdkNode to fix 402 zombie node race condition (#30)
* feat: add destroy() method to MdkNode for explicit cleanup
On serverless platforms (Vercel/Lambda), MdkNode's inner Rust Node
and its tokio runtime survive after getInvoice() returns because V8
GC is non-deterministic. When the agent pays a 402 invoice instantly
(<1s), the webhook handler creates a second MdkNode for the same
wallet while the first is still alive. The zombie's reconnection
loop steals the LSP peer connection from the new node, preventing
the JIT channel from being established and causing "retries exhausted"
payment failures.
In normal checkout this doesn't happen because the human delay (5-30s)
gives GC time to collect the old node before the webhook fires.
destroy() wraps the inner Node in Option<Node>, allowing JS callers
to explicitly drop the Rust Node and its tokio runtime immediately
after invoice creation, eliminating the race condition.
* style: fix cargo fmt1 parent c81f35b commit 702688a
2 files changed
Lines changed: 99 additions & 49 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
71 | 71 | | |
72 | 72 | | |
73 | 73 | | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
74 | 80 | | |
75 | 81 | | |
76 | 82 | | |
| |||
0 commit comments