Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions src/renderer/runtime/useMeshcoreRuntime.reconnect.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -521,9 +521,20 @@ describe('useMeshcoreRuntime manual disconnect must not auto-reconnect', () => {
// and left status=reconnecting with no further attempts (n7eal / #792 MeshCore TCP).
const abortIdx = reconnectBody.indexOf('isMeshcoreSetupAbortError(err)');
expect(abortIdx).toBeGreaterThan(-1);
const abortBlock = reconnectBody.slice(abortIdx, abortIdx + 900);
// Delimit the abort branch at the non-abort retry path rather than a fixed
// char window, so adding late-transport cleanup before the defer cannot push
// `return 'defer'` out of range.
const retryIdx = reconnectBody.indexOf("return 'retry'", abortIdx);
expect(retryIdx).toBeGreaterThan(abortIdx);
const abortBlock = reconnectBody.slice(abortIdx, retryIdx);
expect(abortBlock).toContain('meshcoreDeferredReconnectRef.current = true');
expect(abortBlock).toContain("return 'defer'");
// Setup abort must clean up any transport this doomed attempt opened *before* deferring,
// otherwise a late-opened driver leaks while the deferred restart brings up a fresh one.
const cleanupIdx = abortBlock.indexOf('lateTransport.cleanup(openedDriverIdentityId)');
const deferIdx = abortBlock.indexOf("return 'defer'");
expect(cleanupIdx).toBeGreaterThan(-1);
expect(deferIdx).toBeGreaterThan(-1);
expect(cleanupIdx).toBeLessThan(deferIdx);
expect(abortBlock).not.toMatch(/meshcoreIsReconnectingRef\.current = false/);
});

Expand Down