Skip to content

refactor: use timers/promises setTimeout for async delays#2377

Merged
ghostdevv merged 1 commit intonpmx-dev:mainfrom
trivikr:timers-promises-settimeout
Apr 4, 2026
Merged

refactor: use timers/promises setTimeout for async delays#2377
ghostdevv merged 1 commit intonpmx-dev:mainfrom
trivikr:timers-promises-settimeout

Conversation

@trivikr
Copy link
Copy Markdown
Contributor

@trivikr trivikr commented Apr 4, 2026

🔗 Linked issue

N/A

🧭 Context

This change replaces ad-hoc promise wrappers around setTimeout with Node’s promise-based timer API from node:timers/promises.

The goal is to remove repetitive delay boilerplate and make retry/wait paths easier to read without changing behavior.

📚 Description

Updated the async delay calls that were written as new Promise(resolve => setTimeout(resolve, ms)) to use setTimeout(ms) from node:timers/promises instead.

This affects the GitHub contributors evolution retry logic, the Upstash OAuth lock retry path, and the related unit tests. The behavior is unchanged; this is a small refactor toward the standard Node API for promise-based timers.

@vercel
Copy link
Copy Markdown

vercel bot commented Apr 4, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
npmx.dev Ready Ready Preview, Comment Apr 4, 2026 5:24pm
2 Skipped Deployments
Project Deployment Actions Updated (UTC)
docs.npmx.dev Ignored Ignored Preview Apr 4, 2026 5:24pm
npmx-lunaria Ignored Ignored Apr 4, 2026 5:24pm

Request Review

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Apr 4, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 59b4d632-acc6-476e-977b-0a0431a9690c

📥 Commits

Reviewing files that changed from the base of the PR and between 06d1eb0 and 238ff68.

📒 Files selected for processing (4)
  • server/api/github/contributors-evolution/[owner]/[repo].get.ts
  • server/utils/atproto/lock.ts
  • test/unit/server/utils/atproto/lock.spec.ts
  • test/unit/shared/utils/async.spec.ts

📝 Walkthrough

Walkthrough

This pull request standardises asynchronous delay handling across the codebase by replacing manually defined sleep() helper functions and custom Promise wrappers around setTimeout with Node.js's built-in setTimeout from the node:timers/promises module. The changes affect one production file, two test files, and maintain existing control flow and timing behaviour whilst reducing code duplication.

Possibly related PRs

Suggested reviewers

  • danielroe
🚥 Pre-merge checks | ✅ 1
✅ Passed checks (1 passed)
Check name Status Explanation
Description check ✅ Passed The pull request description clearly relates to the changeset, explaining the refactoring from manual Promise wrappers around setTimeout to Node's native timers/promises API.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@codecov
Copy link
Copy Markdown

codecov bot commented Apr 4, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ All tests successful. No failed tests found.

📢 Thoughts on this report? Let us know!

Copy link
Copy Markdown
Contributor

@ghostdevv ghostdevv left a comment

Choose a reason for hiding this comment

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

ty!!

@ghostdevv ghostdevv added this pull request to the merge queue Apr 4, 2026
Merged via the queue into npmx-dev:main with commit 2eee0b5 Apr 4, 2026
21 checks passed
@trivikr trivikr deleted the timers-promises-settimeout branch April 4, 2026 18:50
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.

2 participants