aaronpk / Overland-iOS

📌 GPS logger for iOS devices
https://overland.p3k.app
Apache License 2.0
602 stars 93 forks source link

Queued points not clearing after successful post #166

Open gloriouslyawkwardlife opened 1 month ago

gloriouslyawkwardlife commented 1 month ago

I have set up a Google Apps Script to receive the output from the Overland app and create a JSON file in my Google Drive. While the execution is successful and returning the expected { "result": "ok"}, the queued locations are not being cleared after the post.

The script:

function doPost(e) {
  DriveApp.createFile(`${new Date().toISOString()}.overland.json`,e.postData.contents,'application/json');
  var reply = ContentService.createTextOutput();
  reply.append(
    `{
  "result": "ok"
}`);
  return reply;
}
aaronpk commented 1 month ago

Do you have any way to tell how long this script takes to return the success response? I haven't set any timeouts on the http client and I don't know what the default is, but my guess is it's timing out before the app gets the response.

gloriouslyawkwardlife commented 1 month ago

In the Apps Script Executions log it's showing 2.246s for 7,444 queued locations, 1.267s when there were about 4,500. Google Apps Script always returns an HTTP 200 even if there is an error in the script (the response would be an HTML page indicating the error), so I have turned on the "Consider HTTP 2XX Successful" setting.

Screenshot 2024-10-18 at 9 12 05 AM (The errors were due to a typo in the script, which I corrected.)

I can confirm that the payloads are getting through (see the attached screenshot); but the app isn't clearing the queue afterward.

Screenshot 2024-10-18 at 9 08 13 AM

If it helps I am on iOS 18.0.1 on an iPhone 16 Pro Max (1 TB).

I have the same issue when sending it to a CouchDB endpoint as well (CouchDB accepts a simple JSON POST and returns a 200 with the ID of the created record).

gloriouslyawkwardlife commented 1 month ago

UPDATE: I changed the URL to my CouchDB endpoint (which takes a raw JSON payload) and it worked; I saw the queue count drop and a record write to the database. It appears to be something with Google Apps Script.

For what it's worth, I believe GAS does an HTTP redirect to present the response; could the app possibly not be following the redirect?

aaronpk commented 1 month ago

Yes, an HTTP redirect means it's first returning a non 200 HTTP code, which the app considers a failure then.