Skip to content

Conversation

@Toba-bonjour
Copy link

@Toba-bonjour Toba-bonjour commented Dec 22, 2025

🎯 Changes

From Discord https://discord.com/channels/719702312431386674/1451931709296869426/1451931709296869426

Raw changes

  • Added isOnline(): boolean to OnlineDetector interface
  • Added onlineDetector?: OnlineDetector | null to OfflineConfig
  • Modified TransactionExecutor.runExecution() to check online status before processing
  • Added isOnline() check when notifyOnline() is called
  • Added tests
  • Updated README.md

Problem

Currently, TransactionExecutor attempts to execute transactions even when the user is offline, leading to:

  • Unnecessary network calls during offline periods
  • Continuous error throwing until the 10-retry limit is reached
  • Data loss risk: transactions are cleared after ~5 minutes offline (10 retries hard coded with exponential backoff)

Solution

This PR introduces configurable online detection to prevent transaction execution when offline:

  1. Enhanced OnlineDetector interface with isOnline() method
  2. Configurable detector in OfflineConfig:
    • undefined (default): uses DefaultOnlineDetector
    • Custom detector: user-provided implementation
  3. Online check before execution: skips transaction processing when offline
  4. network/connectivity errors no longer count toward retry limit

✅ Checklist

  • I have followed the steps in the Contributing guide.
  • I have tested this code locally with pnpm test:pr.

🚀 Release Impact

  • This change affects published code, and I have generated a changeset.
  • This change is docs/CI/dev-only (no release).

@changeset-bot
Copy link

changeset-bot bot commented Dec 22, 2025

🦋 Changeset detected

Latest commit: 9a5bb56

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@tanstack/offline-transactions Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@Toba-bonjour Toba-bonjour force-pushed the toba/skip-transaction-retry-when-offline branch from 1d51bbf to 0a292f5 Compare December 22, 2025 22:20
Toba-bonjour and others added 6 commits December 22, 2025 23:29
…tion when offline

- Add onlineDetector config option to allow custom online detection
- Change onlineDetector type from DefaultOnlineDetector to OnlineDetector interface
- Add isOnline() and dispose() methods to OnlineDetector interface
- Check online status before executing transactions in TransactionExecutor
- Clear scheduler before reloading filtered transactions to ensure consistency
- Pass onlineDetector to TransactionExecutor for status checks

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
@Toba-bonjour Toba-bonjour force-pushed the toba/skip-transaction-retry-when-offline branch from 0a292f5 to d68bebe Compare December 22, 2025 22:31
@Toba-bonjour Toba-bonjour marked this pull request as ready for review December 24, 2025 11:04
@Toba-bonjour Toba-bonjour changed the title WIP: Expose onlineDetector and add check online status before executing transactions Expose onlineDetector and add check online status before executing transactions Dec 24, 2025
KyleAMathews and others added 3 commits January 23, 2026 14:24
Resolve conflicts:
- OfflineExecutor.ts: Use WebOnlineDetector as default (renamed from DefaultOnlineDetector)
- types.ts: Keep isOnline() method in OnlineDetector interface, add doc comment
- offline-e2e.test.ts: Include both custom OnlineDetector tests and optimistic state restoration tests

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Match production WebOnlineDetector behavior by skipping notification
when offline. This prevents tests from passing with behavior that
would fail in production.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

2 participants