diff --git a/apps/sim/connectors/google-docs/google-docs.ts b/apps/sim/connectors/google-docs/google-docs.ts index fae56ea5f1a..51114f376e5 100644 --- a/apps/sim/connectors/google-docs/google-docs.ts +++ b/apps/sim/connectors/google-docs/google-docs.ts @@ -304,7 +304,8 @@ export const googleDocsConnector: ConnectorConfig = { const maxDocs = sourceConfig.maxDocs ? Number(sourceConfig.maxDocs) : 0 const previouslyFetched = (syncContext?.totalDocsFetched as number) ?? 0 - const remaining = maxDocs > 0 ? maxDocs - previouslyFetched : 0 + /** Last-page precision: never ask Drive for more files than the cap still allows. */ + const remaining = maxDocs > 0 ? Math.max(0, maxDocs - previouslyFetched) : 0 const pageSize = remaining > 0 ? Math.min(PAGE_SIZE, remaining) : PAGE_SIZE /** diff --git a/apps/sim/lib/logs/execution/logger.ts b/apps/sim/lib/logs/execution/logger.ts index 828cdc27de8..00d04a72b2d 100644 --- a/apps/sim/lib/logs/execution/logger.ts +++ b/apps/sim/lib/logs/execution/logger.ts @@ -1399,7 +1399,16 @@ export class ExecutionLogger implements IExecutionLoggerService { actorUserId, exactBillingContext ) - } catch {} + } catch (recordError) { + /* The safety net is the last thing between a completed run and an unbilled + one. Swallowing it left the only emitted line saying a notification check + had failed and was non-fatal. */ + execLog.error('Failed to record execution usage — this run may be unbilled', { + error: recordError, + executionId, + workflowId: updatedLog.workflowId, + }) + } execLog.warn('Usage threshold notification check failed (non-fatal)', { error: e }) }