-
Notifications
You must be signed in to change notification settings - Fork 425
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Question] How to know when batch syncing is busy. #2165
Comments
Why? What would you do differently? If the http service is busy, that means it’s currently uploading records, which is what you set out to do by calling .sync(). “HTTP Service is busy” is not an error. It’s more like “I’m already on it”. It’s completely harmless. |
Just want to confirm. If we call .sync and get “HTTP Service is busy”, we can ignore it and we continue with our logic, which involves calling So we can continue our business logic and the package will ensure all datapoints are sync even if |
No. The HTTP service is independent. Once started, it won’t stop until all records in the database are emptied. There is only ever one instance of the http service operating at any given time, posting records synchronously.
Yes. |
Follow-up Question: Is I wanted to clarify whether we actually need to manually call Here’s the setup when we start a “round”: await BackgroundGeolocation.setConfig({
url: `${beConfig.config?.tracking?.serverUrl}/batch`,
authorization: {
strategy: 'JWT',
accessToken: idToken!,
},
extras: {
roundId: roundQuery.data?.id!,
versionNumber: `${VersionNumber.appVersion}(${VersionNumber.buildVersion})`,
},
}); At the end of the round (typically after 4 hours), we stop recording GPS data. What I’d like to confirm is whether we need to worry about extras.roundId lingering in the database. Specifically, will the records from the previous round persist with the old roundId? When a new round starts, will the new extras.roundId be applied to new records, without requiring a .sync to ensure the previous round’s records are fully synced? Can we rely on the batch sync mechanism to handle everything as we continue recording new data? |
This causes bad behavior: if http request takes a long time, then BackgroundGeolocation.sync() will not stop until you do BackgroundGeolocation.stop(). While http client syncs a single point to server (http request can take more than 1 second), we get new point (iOS sends actual point every ~1 second). It will never stop sync if http request is slower than the period of getting updated location. |
Perhaps you're interested in |
Do you mean autoSyncThreshold? I cannot use autoSyncThreshold because I need to send data every 10 minutes regardless of collected points amount. |
Summary
We are encountering a
HTTPService is busy
error when attempting to call our custom endpoint that utilizesaxios
. This error occurs because background syncing (handled by thebackground-geolocation
library) is still processing while we attempt to make the call. We are looking for a way to detect when the batch syncing process is in progress—ideally by subscribing to anisLoading
state or some other observable mechanism. This would allow us to handle the API call more effectively and avoid conflicts with ongoing sync operations.Your Environment
4.17.1
0.73.6
Plugin Configuration
Here’s our current configuration setup for the background geolocation service:
Expected Behavior
We expect the batch syncing process not to interfere with our API calls. Specifically, we would like to know when the background sync is in progress (via a state like isLoading or a similar mechanism) so we can avoid triggering the HTTPService is busy error. While the onHttp method allows us to receive responses after sync requests, we are looking for a way to be informed when requests are being sent in the first place.
Actual Behavior
During the call to our API, we intermittently receive the HTTPService is busy error. This is likely due to the background syncing process initiated by the background-geolocation library, which may be blocking the axios thread.
Here’s the code that triggers the error:
Steps to Reproduce
Context
We are trying to determine when the background geolocation service is actively syncing data, so that we can manage API calls more intelligently and avoid conflicts. The ideal solution would involve subscribing to a sync state or knowing precisely when the batch sync process is sending requests.
Debug logs
Here’s an excerpt of the logs where the issue arises:
Logs
Error: HTTPService is busyThe text was updated successfully, but these errors were encountered: