fix: release tenant sessions after proof events - #441
Conversation
Signed-off-by: Mark <markniu@sign.global>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (1)
Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review. 📝 WalkthroughWalkthrough
ChangesProof event session lifecycle
Priority: ➖ Normal Estimated code review effort: 2 (Simple) | ~10 minutes Change: Bug fix Merge Risk: ⚪ Minimal · up to Tenant proof-event sessions are now released on both successful and failed format-data reads without changing dedicated-agent handling or delivery payloads. 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
ajile-in
left a comment
There was a problem hiding this comment.
Thanks for the fix, Mark — I verified it locally: the 4 tests pass with the exact command in the PR description, yarn check-types is clean, yarn lint is 0 errors (only pre-existing warnings), and format checks pass. The release semantics are confirmed against the installed Credo 0.6.2 withTenantAgent (calls endSession() in a finally, on both success and failure).
A few things to consider (all non-blocking):
-
Flaky lint on a fresh checkout: the first full
yarn lintrun right afteryarn installcrashed ineslint-plugin-import'sno-cyclerule (TypeError: Cannot read properties of null) on the test file's@credo-ts/didcommimport. A re-run passed clean. If CI lints on fresh installs, it may hit this — worth watching. -
Pre-existing repo issue this PR relies on:
jest.config.tsstill has the invalidnameoption, so a barejestrun fails config parse and theTS_NODE_TRANSPILE_ONLY=trueworkaround is required. Since this PR introduces the repo's first test suite, fixing that config (or switching to a.mjs/JS config) would makeyarn testwork without the env-var incantation. -
Test design: the fixture stubs Credo's
withTenantAgentcontract rather than using the real API (documented reason: ESM/native deps). The stub's contract matches reality and you note an isolated runtime check — acceptable for a unit test. -
Optional: in the failing-read test, you assert webhook/WebSocket are not called after rejection. Consider also asserting a subsequent event delivers a webhook, to lock in end-to-end recovery (the second
handleEventcurrently only checksendSession).
Signed-off-by: Mark <markniu@sign.global>
|
Thanks for the thorough verification and feedback. I addressed item 4 in I left items 1–3 unchanged to keep this PR focused: the lint failure did not reproduce on this run, the Jest configuration issue is pre-existing and better handled separately, and the scoped-session stub remains paired with the Credo 0.6.2 runtime verification already documented in the PR. Validation after the update:
|
|
|
Merged |



Proof-state events in shared agents acquire a tenant session to read format data but never release it. Repeated events retain sessions and can exhaust a configured finite session limit; a failed format-data read leaks its session as well.
Use Credo's
withTenantAgentto release the session on both success and failure, before webhook or WebSocket delivery. This follows the existing credential-event handler pattern. Dedicated-agent behavior and event payloads are preserved.Validation:
TS_NODE_TRANSPILE_ONLY=true yarn test --runInBand src/events/__tests__/ProofEvents.test.ts. The environment variable bypasses an existing TypeScript error in the root Jest config's unsupportednameoption. The tests also passed a separate TypeScript check.TenantsApi.withTenantAgentreleased all five acquired sessions, including a failed read. Wallet access and delivery were stubbed; this was not a live wallet integration test.yarn check-types,yarn lint(zero errors; existing warnings),yarn check-format, andgit diff --checkpass.Summary by CodeRabbit