diff --git a/.clinerules b/.clinerules index 3bfef902..fa5e0589 100644 --- a/.clinerules +++ b/.clinerules @@ -252,7 +252,7 @@ class Cline { } catch (error) { // 4. Error handling with retry if (isOpenRouter && !this.didAutomaticallyRetryFailedApiRequest) { - await delay(1000) + await setTimeoutPromise(1000) this.didAutomaticallyRetryFailedApiRequest = true yield* this.attemptApiRequest(previousApiReqIndex) return diff --git a/package-lock.json b/package-lock.json index b7719e85..8b75f190 100644 --- a/package-lock.json +++ b/package-lock.json @@ -33,7 +33,6 @@ "chokidar": "^4.0.1", "clone-deep": "^4.0.1", "default-shell": "^2.2.0", - "delay": "^6.0.0", "diff": "^5.2.0", "execa": "^9.5.2", "fast-deep-equal": "^3.1.3", @@ -10360,17 +10359,6 @@ "node": ">= 14" } }, - "node_modules/delay": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/delay/-/delay-6.0.0.tgz", - "integrity": "sha512-2NJozoOHQ4NuZuVIr5CWd0iiLVIRSDepakaovIN+9eIDHEhdCAEvSy2cuf1DCrPPQLvHmbqTHODlhHg8UCy4zw==", - "engines": { - "node": ">=16" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, "node_modules/delayed-stream": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", diff --git a/package.json b/package.json index 966f9bb4..5ca76e1d 100644 --- a/package.json +++ b/package.json @@ -332,7 +332,6 @@ "chokidar": "^4.0.1", "clone-deep": "^4.0.1", "default-shell": "^2.2.0", - "delay": "^6.0.0", "diff": "^5.2.0", "execa": "^9.5.2", "fast-deep-equal": "^3.1.3", diff --git a/src/api/providers/openrouter.ts b/src/api/providers/openrouter.ts index 203e6f8a..0100f0c8 100644 --- a/src/api/providers/openrouter.ts +++ b/src/api/providers/openrouter.ts @@ -1,6 +1,6 @@ import { Anthropic } from "@anthropic-ai/sdk" import axios from "axios" -import delay from "delay" +import { setTimeout as setTimeoutPromise } from "node:timers/promises" import OpenAI from "openai" import { ApiHandler } from "../" import { ApiHandlerOptions, ModelInfo, openRouterDefaultModelId, openRouterDefaultModelInfo } from "../../shared/api" @@ -96,7 +96,7 @@ export class OpenRouterHandler implements ApiHandler { async getApiStreamUsage(): Promise { if (this.lastGenerationId) { - await delay(500) // FIXME: necessary delay to ensure generation endpoint is ready + await setTimeoutPromise(500) // FIXME: necessary delay to ensure generation endpoint is ready try { const generationIterator = this.fetchGenerationDetails(this.lastGenerationId) const generation = (await generationIterator.next()).value diff --git a/src/core/Cline.ts b/src/core/Cline.ts index 5daa2c24..9be4da6c 100644 --- a/src/core/Cline.ts +++ b/src/core/Cline.ts @@ -1,6 +1,6 @@ import { Anthropic } from "@anthropic-ai/sdk" import cloneDeep from "clone-deep" -import delay from "delay" +import { setTimeout as setTimeoutPromise } from "node:timers/promises" import fs from "fs/promises" import getFolderSize from "get-folder-size" import os from "os" @@ -1215,7 +1215,7 @@ export class Cline { // for their associated messages to be sent to the webview, maintaining // the correct order of messages (although the webview is smart about // grouping command_output messages despite any gaps anyways) - await delay(50) + await setTimeoutPromise(50) result = result.trim() @@ -1460,7 +1460,7 @@ export class Cline { } console.log("first chunk failed, waiting 1 second before retrying") - await delay(1000) + await setTimeoutPromise(1000) this.didAutomaticallyRetryFailedApiRequest = true } else { // request failed after retrying automatically once, ask user if they want to retry again @@ -1902,7 +1902,7 @@ export class Cline { await this.diffViewProvider.open(relPath) } await this.diffViewProvider.update(newContent, true) - await delay(300) // wait for diff view to update + await setTimeoutPromise(300) // wait for diff view to update this.diffViewProvider.scrollToFirstDiff() // showOmissionWarning(this.diffViewProvider.originalContent || "", newContent) @@ -1924,7 +1924,7 @@ export class Cline { telemetryService.captureToolUsage(this.taskId, block.name, true, true) // we need an artificial delay to let the diagnostics catch up to the changes - await delay(3_500) + await setTimeoutPromise(3_500) } else { // If auto-approval is enabled but this tool wasn't auto-approved, send notification showNotificationForApprovalIfAutoApprovalEnabled( @@ -3666,7 +3666,7 @@ export class Cline { if (busyTerminals.length > 0 && this.didEditFile) { // || this.didEditFile - await delay(300) // delay after saving file to let terminals catch up + await setTimeoutPromise(300) // delay after saving file to let terminals catch up } // let terminalWasBusy = false diff --git a/src/core/webview/ClineProvider.ts b/src/core/webview/ClineProvider.ts index 78fce710..23667974 100644 --- a/src/core/webview/ClineProvider.ts +++ b/src/core/webview/ClineProvider.ts @@ -40,7 +40,7 @@ import CheckpointTracker from "../../integrations/checkpoints/CheckpointTracker" import { getTotalTasksSize } from "../../utils/storage" import { ConversationTelemetryService } from "../../services/telemetry/ConversationTelemetryService" import { GlobalFileNames } from "../../global-constants" -import delay from "delay" +import { setTimeout as setTimeoutPromise } from "node:timers/promises" /* 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 async addSelectedCodeToChat(code: string, filePath: string, languageId: string, diagnostics?: vscode.Diagnostic[]) { // Ensure the sidebar view is visible await vscode.commands.executeCommand("claude-dev.SidebarProvider.focus") - await delay(100) + await setTimeoutPromise(100) // Post message to webview with the selected code const fileMention = this.getFileMentionFromPath(filePath) @@ -1790,7 +1790,7 @@ Here is the project's README to help you get started:\n\n${mcpDetails.readmeCont async addSelectedTerminalOutputToChat(output: string, terminalName: string) { // Ensure the sidebar view is visible await vscode.commands.executeCommand("claude-dev.SidebarProvider.focus") - await delay(100) + await setTimeoutPromise(100) // Post message to webview with the selected terminal output // await this.postMessageToWebview({ @@ -1811,7 +1811,7 @@ Here is the project's README to help you get started:\n\n${mcpDetails.readmeCont async fixWithCline(code: string, filePath: string, languageId: string, diagnostics: vscode.Diagnostic[]) { // Ensure the sidebar view is visible await vscode.commands.executeCommand("claude-dev.SidebarProvider.focus") - await delay(100) + await setTimeoutPromise(100) const fileMention = this.getFileMentionFromPath(filePath) const problemsString = this.convertDiagnosticsToProblemsString(diagnostics) diff --git a/src/extension.ts b/src/extension.ts index 048829cb..9a8daa16 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -1,6 +1,6 @@ // The module 'vscode' contains the VS Code extensibility API // Import the module and reference it with the alias vscode in your code below -import delay from "delay" +import { setTimeout as setTimeoutPromise } from "node:timers/promises" import * as vscode from "vscode" import { ClineProvider } from "./core/webview/ClineProvider" import { Logger } from "./services/logging/Logger" @@ -88,7 +88,7 @@ export function activate(context: vscode.ExtensionContext) { tabProvider.resolveWebviewView(panel) // Lock the editor group so clicking on files doesn't open them over the panel - await delay(100) + await setTimeoutPromise(100) await vscode.commands.executeCommand("workbench.action.lockEditorGroup") } diff --git a/src/integrations/editor/DiffViewProvider.ts b/src/integrations/editor/DiffViewProvider.ts index e416f99d..557d8f9c 100644 --- a/src/integrations/editor/DiffViewProvider.ts +++ b/src/integrations/editor/DiffViewProvider.ts @@ -158,7 +158,6 @@ export class DiffViewProvider { await updatedDocument.save() } - // await delay(100) // get text after save in case there is any auto-formatting done by the editor const postSaveContent = updatedDocument.getText() diff --git a/src/services/browser/BrowserSession.ts b/src/services/browser/BrowserSession.ts index 183979d9..8400e561 100644 --- a/src/services/browser/BrowserSession.ts +++ b/src/services/browser/BrowserSession.ts @@ -5,7 +5,7 @@ import { Browser, Page, ScreenshotOptions, TimeoutError, launch } from "puppetee // @ts-ignore import PCR from "puppeteer-chromium-resolver" import pWaitFor from "p-wait-for" -import delay from "delay" +import { setTimeout as setTimeoutPromise } from "node:timers/promises" import { fileExistsAtPath } from "../../utils/fs" import { BrowserActionResult } from "../../shared/ExtensionMessage" import { BrowserSettings } from "../../shared/BrowserSettings" @@ -295,7 +295,7 @@ export class BrowserSession { } lastHTMLSize = currentHTMLSize - await delay(checkDurationMsecs) + await setTimeoutPromise(checkDurationMsecs) } } @@ -314,7 +314,7 @@ export class BrowserSession { this.currentMousePosition = coordinate // Small delay to check if click triggered any network activity - await delay(100) + await setTimeoutPromise(100) if (hasNetworkActivity) { // If we detected network activity, wait for navigation/loading @@ -346,7 +346,7 @@ export class BrowserSession { behavior: "auto", }) }) - await delay(300) + await setTimeoutPromise(300) }) } @@ -358,7 +358,7 @@ export class BrowserSession { behavior: "auto", }) }) - await delay(300) + await setTimeoutPromise(300) }) } } diff --git a/src/services/mcp/McpHub.ts b/src/services/mcp/McpHub.ts index 40660885..fda129b8 100644 --- a/src/services/mcp/McpHub.ts +++ b/src/services/mcp/McpHub.ts @@ -8,7 +8,7 @@ import { ReadResourceResultSchema, } from "@modelcontextprotocol/sdk/types.js" import chokidar, { FSWatcher } from "chokidar" -import delay from "delay" +import { setTimeout as setTimeoutPromise } from "node:timers/promises" import deepEqual from "fast-deep-equal" import * as fs from "fs/promises" import * as path from "path" @@ -415,7 +415,7 @@ export class McpHub { connection.server.status = "connecting" connection.server.error = "" await this.notifyWebviewOfServerChanges() - await delay(500) // artificial delay to show user that server is restarting + await setTimeoutPromise(500) // artificial delay to show user that server is restarting try { await this.deleteConnection(serverName) // Try to connect again using existing config