Skip to content

Commit 5b6eae2

Browse files
remove delay package (RooCodeInc#2414)
1 parent c153077 commit 5b6eae2

File tree

10 files changed

+22
-36
lines changed

10 files changed

+22
-36
lines changed

.clinerules

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ class Cline {
252252
} catch (error) {
253253
// 4. Error handling with retry
254254
if (isOpenRouter && !this.didAutomaticallyRetryFailedApiRequest) {
255-
await delay(1000)
255+
await setTimeoutPromise(1000)
256256
this.didAutomaticallyRetryFailedApiRequest = true
257257
yield* this.attemptApiRequest(previousApiReqIndex)
258258
return

package-lock.json

Lines changed: 0 additions & 12 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,6 @@
332332
"chokidar": "^4.0.1",
333333
"clone-deep": "^4.0.1",
334334
"default-shell": "^2.2.0",
335-
"delay": "^6.0.0",
336335
"diff": "^5.2.0",
337336
"execa": "^9.5.2",
338337
"fast-deep-equal": "^3.1.3",

src/api/providers/openrouter.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { Anthropic } from "@anthropic-ai/sdk"
22
import axios from "axios"
3-
import delay from "delay"
3+
import { setTimeout as setTimeoutPromise } from "node:timers/promises"
44
import OpenAI from "openai"
55
import { ApiHandler } from "../"
66
import { ApiHandlerOptions, ModelInfo, openRouterDefaultModelId, openRouterDefaultModelInfo } from "../../shared/api"
@@ -96,7 +96,7 @@ export class OpenRouterHandler implements ApiHandler {
9696

9797
async getApiStreamUsage(): Promise<ApiStreamUsageChunk | undefined> {
9898
if (this.lastGenerationId) {
99-
await delay(500) // FIXME: necessary delay to ensure generation endpoint is ready
99+
await setTimeoutPromise(500) // FIXME: necessary delay to ensure generation endpoint is ready
100100
try {
101101
const generationIterator = this.fetchGenerationDetails(this.lastGenerationId)
102102
const generation = (await generationIterator.next()).value

src/core/Cline.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { Anthropic } from "@anthropic-ai/sdk"
22
import cloneDeep from "clone-deep"
3-
import delay from "delay"
3+
import { setTimeout as setTimeoutPromise } from "node:timers/promises"
44
import fs from "fs/promises"
55
import getFolderSize from "get-folder-size"
66
import os from "os"
@@ -1215,7 +1215,7 @@ export class Cline {
12151215
// for their associated messages to be sent to the webview, maintaining
12161216
// the correct order of messages (although the webview is smart about
12171217
// grouping command_output messages despite any gaps anyways)
1218-
await delay(50)
1218+
await setTimeoutPromise(50)
12191219

12201220
result = result.trim()
12211221

@@ -1460,7 +1460,7 @@ export class Cline {
14601460
}
14611461

14621462
console.log("first chunk failed, waiting 1 second before retrying")
1463-
await delay(1000)
1463+
await setTimeoutPromise(1000)
14641464
this.didAutomaticallyRetryFailedApiRequest = true
14651465
} else {
14661466
// request failed after retrying automatically once, ask user if they want to retry again
@@ -1902,7 +1902,7 @@ export class Cline {
19021902
await this.diffViewProvider.open(relPath)
19031903
}
19041904
await this.diffViewProvider.update(newContent, true)
1905-
await delay(300) // wait for diff view to update
1905+
await setTimeoutPromise(300) // wait for diff view to update
19061906
this.diffViewProvider.scrollToFirstDiff()
19071907
// showOmissionWarning(this.diffViewProvider.originalContent || "", newContent)
19081908

@@ -1924,7 +1924,7 @@ export class Cline {
19241924
telemetryService.captureToolUsage(this.taskId, block.name, true, true)
19251925

19261926
// we need an artificial delay to let the diagnostics catch up to the changes
1927-
await delay(3_500)
1927+
await setTimeoutPromise(3_500)
19281928
} else {
19291929
// If auto-approval is enabled but this tool wasn't auto-approved, send notification
19301930
showNotificationForApprovalIfAutoApprovalEnabled(
@@ -3666,7 +3666,7 @@ export class Cline {
36663666

36673667
if (busyTerminals.length > 0 && this.didEditFile) {
36683668
// || this.didEditFile
3669-
await delay(300) // delay after saving file to let terminals catch up
3669+
await setTimeoutPromise(300) // delay after saving file to let terminals catch up
36703670
}
36713671

36723672
// let terminalWasBusy = false

src/core/webview/ClineProvider.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ import CheckpointTracker from "../../integrations/checkpoints/CheckpointTracker"
4040
import { getTotalTasksSize } from "../../utils/storage"
4141
import { ConversationTelemetryService } from "../../services/telemetry/ConversationTelemetryService"
4242
import { GlobalFileNames } from "../../global-constants"
43-
import delay from "delay"
43+
import { setTimeout as setTimeoutPromise } from "node:timers/promises"
4444

4545
/*
4646
https://github.com/microsoft/vscode-webview-ui-toolkit-samples/blob/main/default/weather-webview/src/providers/WeatherViewProvider.ts
@@ -1767,7 +1767,7 @@ Here is the project's README to help you get started:\n\n${mcpDetails.readmeCont
17671767
async addSelectedCodeToChat(code: string, filePath: string, languageId: string, diagnostics?: vscode.Diagnostic[]) {
17681768
// Ensure the sidebar view is visible
17691769
await vscode.commands.executeCommand("claude-dev.SidebarProvider.focus")
1770-
await delay(100)
1770+
await setTimeoutPromise(100)
17711771

17721772
// Post message to webview with the selected code
17731773
const fileMention = this.getFileMentionFromPath(filePath)
@@ -1790,7 +1790,7 @@ Here is the project's README to help you get started:\n\n${mcpDetails.readmeCont
17901790
async addSelectedTerminalOutputToChat(output: string, terminalName: string) {
17911791
// Ensure the sidebar view is visible
17921792
await vscode.commands.executeCommand("claude-dev.SidebarProvider.focus")
1793-
await delay(100)
1793+
await setTimeoutPromise(100)
17941794

17951795
// Post message to webview with the selected terminal output
17961796
// await this.postMessageToWebview({
@@ -1811,7 +1811,7 @@ Here is the project's README to help you get started:\n\n${mcpDetails.readmeCont
18111811
async fixWithCline(code: string, filePath: string, languageId: string, diagnostics: vscode.Diagnostic[]) {
18121812
// Ensure the sidebar view is visible
18131813
await vscode.commands.executeCommand("claude-dev.SidebarProvider.focus")
1814-
await delay(100)
1814+
await setTimeoutPromise(100)
18151815

18161816
const fileMention = this.getFileMentionFromPath(filePath)
18171817
const problemsString = this.convertDiagnosticsToProblemsString(diagnostics)

src/extension.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// The module 'vscode' contains the VS Code extensibility API
22
// Import the module and reference it with the alias vscode in your code below
3-
import delay from "delay"
3+
import { setTimeout as setTimeoutPromise } from "node:timers/promises"
44
import * as vscode from "vscode"
55
import { ClineProvider } from "./core/webview/ClineProvider"
66
import { Logger } from "./services/logging/Logger"
@@ -88,7 +88,7 @@ export function activate(context: vscode.ExtensionContext) {
8888
tabProvider.resolveWebviewView(panel)
8989

9090
// Lock the editor group so clicking on files doesn't open them over the panel
91-
await delay(100)
91+
await setTimeoutPromise(100)
9292
await vscode.commands.executeCommand("workbench.action.lockEditorGroup")
9393
}
9494

src/integrations/editor/DiffViewProvider.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,6 @@ export class DiffViewProvider {
158158
await updatedDocument.save()
159159
}
160160

161-
// await delay(100)
162161
// get text after save in case there is any auto-formatting done by the editor
163162
const postSaveContent = updatedDocument.getText()
164163

src/services/browser/BrowserSession.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { Browser, Page, ScreenshotOptions, TimeoutError, launch } from "puppetee
55
// @ts-ignore
66
import PCR from "puppeteer-chromium-resolver"
77
import pWaitFor from "p-wait-for"
8-
import delay from "delay"
8+
import { setTimeout as setTimeoutPromise } from "node:timers/promises"
99
import { fileExistsAtPath } from "../../utils/fs"
1010
import { BrowserActionResult } from "../../shared/ExtensionMessage"
1111
import { BrowserSettings } from "../../shared/BrowserSettings"
@@ -295,7 +295,7 @@ export class BrowserSession {
295295
}
296296

297297
lastHTMLSize = currentHTMLSize
298-
await delay(checkDurationMsecs)
298+
await setTimeoutPromise(checkDurationMsecs)
299299
}
300300
}
301301

@@ -314,7 +314,7 @@ export class BrowserSession {
314314
this.currentMousePosition = coordinate
315315

316316
// Small delay to check if click triggered any network activity
317-
await delay(100)
317+
await setTimeoutPromise(100)
318318

319319
if (hasNetworkActivity) {
320320
// If we detected network activity, wait for navigation/loading
@@ -346,7 +346,7 @@ export class BrowserSession {
346346
behavior: "auto",
347347
})
348348
})
349-
await delay(300)
349+
await setTimeoutPromise(300)
350350
})
351351
}
352352

@@ -358,7 +358,7 @@ export class BrowserSession {
358358
behavior: "auto",
359359
})
360360
})
361-
await delay(300)
361+
await setTimeoutPromise(300)
362362
})
363363
}
364364
}

src/services/mcp/McpHub.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import {
88
ReadResourceResultSchema,
99
} from "@modelcontextprotocol/sdk/types.js"
1010
import chokidar, { FSWatcher } from "chokidar"
11-
import delay from "delay"
11+
import { setTimeout as setTimeoutPromise } from "node:timers/promises"
1212
import deepEqual from "fast-deep-equal"
1313
import * as fs from "fs/promises"
1414
import * as path from "path"
@@ -415,7 +415,7 @@ export class McpHub {
415415
connection.server.status = "connecting"
416416
connection.server.error = ""
417417
await this.notifyWebviewOfServerChanges()
418-
await delay(500) // artificial delay to show user that server is restarting
418+
await setTimeoutPromise(500) // artificial delay to show user that server is restarting
419419
try {
420420
await this.deleteConnection(serverName)
421421
// Try to connect again using existing config

0 commit comments

Comments
 (0)