Troubleshooting
Common issues, error codes, and solutions for PocketSync
Common issues and solutions
Connection issues
Nothing happens when I start sync
Nothing happens when I start sync
Symptoms:
- PocketSync initializes without errors
- No sync operations occur
Possible causes:
- Sync not started
- No user ID set
- No tables configured for sync
- No data changes detected
Solutions:
- Verify that
PocketSync.instance.start()
was called - Make sure
setUserId
was called before starting sync
Cannot connect to PocketSync server
Cannot connect to PocketSync server
Symptoms:
- Sync operations fail with network errors
- App shows offline status even when online
Possible causes:
- Invalid server URL
- Network connectivity issues
- Server is down or unreachable
Solutions:
- Verify your server URL in the PocketSyncOptions
- Check your device’s network connection
- Verify that your auth token is valid
- Check the PocketSync status page for any outages
Authentication failures
Authentication failures
Symptoms:
- Sync operations fail with 401 or 403 errors
- Cannot initialize PocketSync
Possible causes:
- Invalid or expired auth token
- Invalid project ID
- User ID not set before starting sync
Solutions:
- Verify your auth token and project ID in the PocketSync console
- Ensure you’ve called
setUserId()
before starting sync - Check if your token has the necessary permissions
Sync starts but no data is transferred
Sync starts but no data is transferred
Symptoms:
- PocketSync initializes without errors
- No data is synchronized between devices
Possible causes:
- Incorrect table configuration
- Data doesn’t meet sync criteria
- Sync process is stopped or paused
Solutions:
- Verify that your tables are properly configured for sync
- Check if
PocketSync.instance.start()
was called - Inspect logs with verbose mode enabled
- Verify that data changes are being detected
Data Synchronization Issues
Data conflicts not resolving correctly
Data conflicts not resolving correctly
Symptoms:
- Unexpected data values after sync
- Different data appears on different devices
Possible causes:
- Conflict resolution strategy not appropriate for your use case
- Custom resolver function has bugs
Solutions:
- Review your conflict resolution strategy
- Test your custom resolver with different conflict scenarios
- Consider using a different built-in strategy
- Enable verbose logging to see conflict details
Data loss during synchronization
Data loss during synchronization
Symptoms:
- Records disappear after sync
- Fields are reset to default values
Possible causes:
- Improper conflict resolution
- Database schema mismatch
- Incorrect data types
Solutions:
- Verify schema consistency across devices
- Check for proper data type handling
- Implement a custom conflict resolver that preserves data
- Restore from backup if available
Sync is slow or consuming excessive resources
Sync is slow or consuming excessive resources
Symptoms:
- Sync operations take a long time
- High battery or network usage
Possible causes:
- Large dataset
- Frequent changes triggering many sync operations
- Inefficient change tracking
Solutions:
- Adjust sync frequency and debounce settings
- Optimize database queries and change detection
- Consider syncing only essential data
- Implement data pagination or chunking for large datasets
Debugging tips
Enable verbose logging
Enable detailed logging to help diagnose issues:
Inspect database
Directly inspect the database to verify data integrity:
Frequently asked questions
How do I reset sync state if things go wrong?
How do I reset sync state if things go wrong?
If you need to reset the sync state, you can use the resetChangeTracking
method:
This will clear all pending changes and reset the sync state. Note that this won’t delete your data, just the sync metadata.
What happens if a device is offline for an extended period?
What happens if a device is offline for an extended period?
PocketSync is designed to handle extended offline periods. When a device comes back online, it will:
- Upload any local changes that occurred while offline
- Download remote changes that occurred during the offline period
- Resolve any conflicts according to your configured strategy
For very long offline periods (weeks/months), you might want to consider a full resync by calling resetChangeTracking()
followed by start()
.
How can I verify that sync is working correctly?
How can I verify that sync is working correctly?
To verify sync is working:
- Enable verbose logging
- Make changes on one device and check that they appear on another
- Monitor the sync status using the
syncStatus
stream - Check the server logs in the PocketSync console
You can also implement a simple UI indicator to show sync status to users.
Can I sync only specific tables or records?
Can I sync only specific tables or records?
Yes, you can configure which tables to sync when initializing PocketSync:
For more granular control, you can implement custom logic to determine which records to sync.
How do I handle schema migrations with PocketSync?
How do I handle schema migrations with PocketSync?
When changing your database schema:
- Update your table definitions
- Increment your database version
- Provide migration scripts
Always test migrations thoroughly before deploying to production.
Still need help?
If you’re still experiencing issues:
- Check our GitHub repository for known issues
- Contact us at hello@pocketsync.dev
Report a bug
Help us improve by reporting bugs and issues you encounter