Skip to content

feat(sync): add delayed task submission for throttling#1506

Draft
jpnurmi wants to merge 3 commits intomasterfrom
jpnurmi/feat/delayed-task
Draft

feat(sync): add delayed task submission for throttling#1506
jpnurmi wants to merge 3 commits intomasterfrom
jpnurmi/feat/delayed-task

Conversation

@jpnurmi
Copy link
Collaborator

@jpnurmi jpnurmi commented Feb 6, 2026

WIP: Early draft for AI review & CI feedback...

Add sentry__bgworker_submit_delayed() to allow deferring task execution by a given number of milliseconds. This paves the road for HTTP retries that should be throttled on startup (similar to Cocoa/iOS and Java/Android SDKs that throttle HTTP retries by 100ms).

// delay 100ms
sentry__bgworker_submit_delayed(bgworker, sentry__curl_send_task, sentry_envelope_free, envelope, 100);

#skip-changelog (internal)

@github-actions
Copy link

github-actions bot commented Feb 6, 2026

Messages
📖 Do not forget to update Sentry-docs with your feature once the pull request gets approved.

Generated by 🚫 dangerJS against a4428e0

@jpnurmi
Copy link
Collaborator Author

jpnurmi commented Feb 6, 2026

@sentry review

@jpnurmi
Copy link
Collaborator Author

jpnurmi commented Feb 6, 2026

@cursor review

Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

jpnurmi and others added 3 commits February 6, 2026 16:21
Add sentry__bgworker_submit_delayed() to defer task execution by a
given number of milliseconds. Tasks are sorted by readiness time using
monotonic timestamps, so a ready delayed task is not bypassed by a
later-submitted immediate task. On shutdown, tasks that exceed the
deadline (started + timeout) are pruned while the rest execute normally.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The flush marker now uses the last task's deadline (capped at the flush
timeout) so it sorts after all current tasks including delayed ones.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Extract the core submission logic into submit_at which takes an absolute
execute_after time. submit and submit_delayed become thin wrappers.

Use submit_at in bgworker_delayed_tasks to pin all tasks to a single
base timestamp, making the test ordering deterministic regardless of OS
preemption between submissions.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@jpnurmi jpnurmi force-pushed the jpnurmi/feat/delayed-task branch from 0f6f4b9 to a4428e0 Compare February 6, 2026 15:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant