refactor: use node's timers/promises API for sleeps - #316
Open
mrafnadeem-apimatic wants to merge 3 commits into
Open
refactor: use node's timers/promises API for sleeps#316mrafnadeem-apimatic wants to merge 3 commits into
mrafnadeem-apimatic wants to merge 3 commits into
Conversation
Make the AbortSignal optional so the three uncancellable polling waits (device-login token poll, delete-directory retry, generation status poll) can share the same helper instead of hand-rolling a Promise wrapper. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
mrafnadeem-apimatic
requested review from
Shield-Jaguar,
aliasghar98 and
saeedjamshaid
as code owners
August 11, 2026 10:27
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



What
Replaces hand-rolled
new Promise((resolve) => setTimeout(resolve, ms))waits with thesleephelper backed bynode:timers/promises.src/infrastructure/timer-extensions.ts—sleep(ms, signal?)returning'ok' | 'cancelled' | 'failed', with theAbortSignaloptional so uncancellable waits can use it too.sdk publishpolling now aborts its wait immediately on cancel instead of up to 10 s later.setTimeoutwaits:LoginAction.pollDeviceToken— device-login token pollFileService.pollDeleteDirectory— delete retry backoffpollUntilCompletedinportal-service— generation status pollWhat is left alone
debounce-service.tsandhooks/utils.tskeep callback-stylesetTimeout: those are cancellable timers racing other work (a debounce window, a readline prompt timeout), not sleeps.Testing
pnpm build— cleanpnpm lint— cleanpnpm test— 71 passing, 11 pendingNote: the
posttesthook (eslint . --ext .ts) reports errors from untracked local.claude/worktrees/**copies. Pre-existing and unrelated to this change;src/andtest/both lint clean.🤖 Generated with Claude Code