Skip to content

[161] Format console errors and transaction tracking in network_sync_checker - #359

Open
kingeligma wants to merge 2 commits into
Goldii-locks:mainfrom
kingeligma:fix/161-format-console-errors-and-transaction-tracking-in-network-sync-checker
Open

[161] Format console errors and transaction tracking in network_sync_checker#359
kingeligma wants to merge 2 commits into
Goldii-locks:mainfrom
kingeligma:fix/161-format-console-errors-and-transaction-tracking-in-network-sync-checker

Conversation

@kingeligma

@kingeligma kingeligma commented Aug 29, 2026

Copy link
Copy Markdown

Closes #161

What

Formats network_sync_checker console output into consistent, greppable warning blocks and adds transaction lifecycle tracking, mirroring the rabe_connector / ledger_usb_bridge convention:

  • formatStackTrace, formatConsoleWarningBlock, logNetworkSyncWarning
  • NetworkSyncTransactionTracker (track / getHistory / clear) + networkSyncTracker singleton
  • All previously raw console.warn sites now emit a bordered, prefixed block with a stack trace
  • runNetworkSyncSign / validateNetworkSyncWithSignature accept an optional txId and record probe lifecycle; healthy approvals are tracked silently, while rejections/mismatches emit exactly one TX <PHASE> block

Tests

__tests__/network_sync_checker_logging.test.ts covers block rendering, single-warn emission per path (success = silent, rejection = one TX ERROR block, matches the existing warn-count contracts), and tracker history filtering + clearing.

Suite repair (carried to every derived branch)

The base suite is broken on main (red CI). This branch also carries the fixes verified on the #162 branch so checks are green here too:

  • SignatureTimeoutAlert useMemo (fixes eslint react-hooks/set-state-in-effect)
  • vitest.setup.ts localStorage shim for Node 24+/26 experimental globals
  • real signed-envelope fixtures in freighter_multisig_hook tests
  • useWallet stubs + act() fixes in the freighter component / signature-timeout suites

Checks

  • lint, type-check, npm run test (87 files / 1328 tests), next build — all pass

…ifecycle

- Add shared debug machinery mirroring the rabe_connector convention:
  formatStackTrace, formatConsoleWarningBlock, logNetworkSyncWarning, and
  a NetworkSyncTransactionTracker singleton.
- Route all previously raw console.warn sites through formatted warning
  blocks (probe rejection, wallet availability, session persistence,
  stellar account extraction).
- Track sync probe lifecycle in runNetworkSyncSign and
  validateNetworkSyncWithSignature via an optional txId; healthy approvals
  are recorded silently while failures emit one greppable TX <PHASE> block.
- Add network_sync_checker_logging tests covering block formatting, warn
  emission counts per path, and tracker history filtering+clearing.

Also carries the suite-repair changes (SignatureTimeoutAlert useMemo,
localStorage shim, freighter_m instance XDR fixtures, useWallet stubs) so
CI runs green on every derived branch.

Closes 161
Copilot AI lite review requested due to automatic review settings August 29, 2026 17:02

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR standardizes network_sync_checker console warnings into consistent, greppable blocks (including stack traces) and introduces a lightweight transaction lifecycle tracker to correlate probe phases via optional txIds. It also includes test suite repairs and new tests to validate the logging/tracking behavior.

Changes:

  • Added formatStackTrace, formatConsoleWarningBlock, and logNetworkSyncWarning, and replaced ad-hoc console.warn calls with the formatted warning blocks.
  • Introduced NetworkSyncTransactionTracker + networkSyncTracker singleton, and extended runNetworkSyncSign / validateNetworkSyncWithSignature to optionally track via txId.
  • Added/updated Vitest + RTL tests and setup shims (including a localStorage fallback in vitest.setup.ts) to keep CI green across newer Node runtimes.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
vitest.setup.ts Adds a defensive localStorage shim for jsdom tests when Node exposes an undefined experimental localStorage global.
app/lib/network_sync_checker.ts Implements formatted warning blocks + stack formatting, adds tx lifecycle tracking, wires tracking into signature probe helpers, and updates warning logging sites.
app/components/SignatureTimeoutAlert.tsx Replaces effect-driven parse error state with memoized derived state to avoid cascading renders.
__tests__/signature_timeout_alert.test.tsx Stubs useWallet to avoid Node-ESM import issues and wraps wallet state mutations with act().
__tests__/network_sync_checker_logging.test.ts New tests covering block rendering, warn emission contracts, and tracker history/clear behavior.
__tests__/freighter_multisig_hook.test.ts Replaces arbitrary base64 fixtures with real signed envelopes to exercise the real XDR parser paths.
__tests__/freighter_connector.component.test.tsx Stubs useWallet to keep freighter connector logic under test without importing WalletProvider dependencies.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

};
}
return {
return {
Comment on lines +129 to +135
const entry: NetworkSyncTxTrackEntry = {
txId,
phase,
message,
timestamp: Date.now(),
stack: formatStackTrace(err),
};
@drips-wave

drips-wave Bot commented Aug 29, 2026

Copy link
Copy Markdown

@kingeligma Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

…cing timers

Three timeout tests attached promise.catch() only after awaiting timer
advance, so the rejected outer promise could be snapshotted as unhandled
by Node during the interleaved microtask gap, making vitest report 3
unhandled errors and exit non-zero despite all tests passing. Attach the
handler immediately after runSignatureWithTimeout (mirroring the
.rejects-based tests) to keep npm run test exiting cleanly.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Format console errors and transaction tracking in network_sync_checker

2 participants