Compare commits
7 Commits
@continued
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
807d95dd3f | ||
|
|
895632c0a5 | ||
|
|
939b44b39f | ||
|
|
056622faa0 | ||
|
|
676e31d28e | ||
|
|
df83e66d5c | ||
|
|
a99288f25a |
@@ -563,10 +563,15 @@ Org-level secrets can only be used for MCP by Background Agents (https://docs.co
|
|||||||
// Set the initial PATH from process.env
|
// Set the initial PATH from process.env
|
||||||
env.PATH = process.env.PATH;
|
env.PATH = process.env.PATH;
|
||||||
|
|
||||||
// For non-Windows platforms, try to get the PATH from user shell
|
// For non-Windows platforms or WSL remotes, try to get the PATH from user shell
|
||||||
if (process.platform !== "win32") {
|
const ideInfo = await this.extras?.ide?.getIdeInfo();
|
||||||
|
const isWindowsHostWithWslRemote =
|
||||||
|
process.platform === "win32" && ideInfo?.remoteName === "wsl";
|
||||||
|
if (process.platform !== "win32" || isWindowsHostWithWslRemote) {
|
||||||
try {
|
try {
|
||||||
const shellEnvPath = await getEnvPathFromUserShell();
|
const shellEnvPath = await getEnvPathFromUserShell(
|
||||||
|
ideInfo?.remoteName,
|
||||||
|
);
|
||||||
if (shellEnvPath && shellEnvPath !== process.env.PATH) {
|
if (shellEnvPath && shellEnvPath !== process.env.PATH) {
|
||||||
env.PATH = shellEnvPath;
|
env.PATH = shellEnvPath;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,9 +2,12 @@ import { exec } from "child_process";
|
|||||||
import { promisify } from "util";
|
import { promisify } from "util";
|
||||||
|
|
||||||
const execAsync = promisify(exec);
|
const execAsync = promisify(exec);
|
||||||
export async function getEnvPathFromUserShell(): Promise<string | undefined> {
|
export async function getEnvPathFromUserShell(
|
||||||
if (process.platform === "win32") {
|
remoteName?: string,
|
||||||
console.warn(`${getEnvPathFromUserShell.name} not implemented for Windows`);
|
): Promise<string | undefined> {
|
||||||
|
const isWindowsHostWithWslRemote =
|
||||||
|
process.platform === "win32" && remoteName === "wsl";
|
||||||
|
if (process.platform === "win32" && !isWindowsHostWithWslRemote) {
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -45,6 +45,9 @@ class ResourceMonitoringService {
|
|||||||
private maxHistorySize = 300; // Keep 5 minutes at 1s intervals
|
private maxHistorySize = 300; // Keep 5 minutes at 1s intervals
|
||||||
private lastCpuUsage = process.cpuUsage();
|
private lastCpuUsage = process.cpuUsage();
|
||||||
private lastTimestamp = Date.now();
|
private lastTimestamp = Date.now();
|
||||||
|
private lastFdCheckTime = Date.now();
|
||||||
|
private fdCheckIntervalMs = 5000; // Check file descriptors every 5 seconds
|
||||||
|
private cacheFileCount: number | null = null;
|
||||||
|
|
||||||
async initialize(): Promise<void> {
|
async initialize(): Promise<void> {
|
||||||
// Start monitoring if verbose mode is enabled
|
// Start monitoring if verbose mode is enabled
|
||||||
@@ -70,6 +73,12 @@ class ResourceMonitoringService {
|
|||||||
this.lastCpuUsage = process.cpuUsage();
|
this.lastCpuUsage = process.cpuUsage();
|
||||||
this.lastTimestamp = Date.now();
|
this.lastTimestamp = Date.now();
|
||||||
|
|
||||||
|
// Initialize file descriptor count on start
|
||||||
|
this.updateFileDescriptorCount().catch(() => {
|
||||||
|
// Ignore errors during initialization
|
||||||
|
});
|
||||||
|
this.lastFdCheckTime = Date.now();
|
||||||
|
|
||||||
this.monitoringInterval = setInterval(() => {
|
this.monitoringInterval = setInterval(() => {
|
||||||
this.collectResourceUsage();
|
this.collectResourceUsage();
|
||||||
}, this.intervalMs);
|
}, this.intervalMs);
|
||||||
@@ -127,16 +136,10 @@ class ResourceMonitoringService {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
// Try to get file descriptor count (Unix only)
|
// Use cached file descriptor count to avoid lsof command leak
|
||||||
this.getFileDescriptorCount()
|
if (this.cacheFileCount !== null) {
|
||||||
.then((count) => {
|
usage.fileDescriptors = this.cacheFileCount;
|
||||||
if (count !== null) {
|
}
|
||||||
usage.fileDescriptors = count;
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.catch(() => {
|
|
||||||
// Ignore errors for file descriptor counting
|
|
||||||
});
|
|
||||||
|
|
||||||
return usage;
|
return usage;
|
||||||
}
|
}
|
||||||
@@ -215,6 +218,14 @@ class ResourceMonitoringService {
|
|||||||
this.resourceHistory = this.resourceHistory.slice(-this.maxHistorySize);
|
this.resourceHistory = this.resourceHistory.slice(-this.maxHistorySize);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Periodically update file descriptor count to prevent lsof command leak
|
||||||
|
// Issue: https://github.com/continuedev/continue/issues/9422
|
||||||
|
const now = Date.now();
|
||||||
|
if (now - this.lastFdCheckTime >= this.fdCheckIntervalMs) {
|
||||||
|
this.updateFileDescriptorCount();
|
||||||
|
this.lastFdCheckTime = now;
|
||||||
|
}
|
||||||
|
|
||||||
// Check for potential issues and log warnings
|
// Check for potential issues and log warnings
|
||||||
this.checkResourceThresholds(usage);
|
this.checkResourceThresholds(usage);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@@ -251,6 +262,13 @@ class ResourceMonitoringService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private async updateFileDescriptorCount(): Promise<void> {
|
||||||
|
const count = await this.getFileDescriptorCount();
|
||||||
|
if (count !== null) {
|
||||||
|
this.cacheFileCount = count;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private async getFileDescriptorCount(): Promise<number | null> {
|
private async getFileDescriptorCount(): Promise<number | null> {
|
||||||
if (process.platform === "win32") {
|
if (process.platform === "win32") {
|
||||||
return null; // Not supported on Windows
|
return null; // Not supported on Windows
|
||||||
|
|||||||
Reference in New Issue
Block a user