I’m experiencing a race condition issue when using the Google Sheets API with concurrent requests.
My script first reads a spreadsheet to determine the populated range, then sends a batchUpdate request with deleteDimension to remove those rows. Immediately after (within milliseconds, due to multithreading), I send parallel append requests to insert new data into a specified range.
Occasionally, some rows are skipped and the inserted data becomes offset, meaning values are not written to the intended range. It appears that although the DELETE request returns successfully, the row deletions may still be processing on the backend. As a result, subsequent insert operations target a range that isn’t fully updated yet, causing unexpected offsets—even when using insertDataOption=OVERWRITE.
Has anyone encountered this behavior or found a reliable way to ensure the delete operation is fully applied before issuing insert requests?