Compare commits

..

5 Commits

Author SHA1 Message Date
copilot-swe-agent[bot] 8d5e485cd6 Revert changes - linkCommandToDir already handles symlink creation
Co-authored-by: whyour <22700758+whyour@users.noreply.github.com>
2025-12-30 17:00:10 +00:00
copilot-swe-agent[bot] b87fe2ebf0 Add quotes to variable expansions in ql.sh
Co-authored-by: whyour <22700758+whyour@users.noreply.github.com>
2025-12-30 16:43:04 +00:00
copilot-swe-agent[bot] 7ea2d362f0 Add QL_DIR validation to ql.sh
Co-authored-by: whyour <22700758+whyour@users.noreply.github.com>
2025-12-30 16:41:26 +00:00
copilot-swe-agent[bot] 9bd8318371 Add ql.sh script and create symlinks in docker-entrypoint.sh
Co-authored-by: whyour <22700758+whyour@users.noreply.github.com>
2025-12-30 16:40:18 +00:00
copilot-swe-agent[bot] 4c2a8e2b24 Initial plan 2025-12-30 16:33:45 +00:00
3 changed files with 16 additions and 67 deletions
-2
View File
@@ -206,7 +206,6 @@ export default (app: Router) => {
}),
}),
async (req: Request, res: Response, next: NextFunction) => {
const logger: Logger = Container.get('logger');
try {
let { filename, content, path } = req.body as {
filename: string;
@@ -224,7 +223,6 @@ export default (app: Router) => {
await writeFileWithLock(filePath, content);
return res.send({ code: 200 });
} catch (e) {
logger.error('🔥 error saving script: %o', e);
return next(e);
}
},
-11
View File
@@ -16,17 +16,6 @@ export class HttpServerService {
metricsService.record('http_service_start', 1, {
port: port.toString(),
});
// Set server timeouts to prevent premature connection drops
if (this.server) {
// Timeout for receiving the entire request (including body) - 5 minutes
this.server.requestTimeout = 300000;
// Timeout for headers - 2 minutes
this.server.headersTimeout = 120000;
// Keep-alive timeout - 65 seconds (slightly more than typical load balancer timeout)
this.server.keepAliveTimeout = 65000;
}
resolve(this.server);
});
+16 -54
View File
@@ -1,9 +1,8 @@
import { lock } from 'proper-lockfile';
import os from 'os';
import path from 'path';
import { writeFile, open, chmod, FileHandle } from 'fs/promises';
import { writeFile, open, chmod } from 'fs/promises';
import { fileExist } from '../config/util';
import Logger from '../loaders/logger';
function getUniqueLockPath(filePath: string) {
const sanitizedPath = filePath
@@ -20,61 +19,24 @@ export async function writeFileWithLock(
if (typeof options === 'string') {
options = { encoding: options };
}
// Ensure file exists before locking
if (!(await fileExist(filePath))) {
let fileHandle: FileHandle | undefined;
try {
fileHandle = await open(filePath, 'w');
} catch (error) {
const errorMessage = error instanceof Error ? error.message : String(error);
throw new Error(`Failed to create file ${filePath}: ${errorMessage}`);
} finally {
if (fileHandle !== undefined) {
try {
await fileHandle.close();
} catch (closeError) {
// Log close error but don't throw to avoid masking the original error
Logger.error(`Failed to close file handle for ${filePath}:`, closeError);
}
}
}
const fileHandle = await open(filePath, 'w');
fileHandle.close();
}
const lockfilePath = getUniqueLockPath(filePath);
let release: (() => Promise<void>) | undefined;
try {
release = await lock(filePath, {
retries: {
retries: 10,
factor: 2,
minTimeout: 100,
maxTimeout: 3000,
},
lockfilePath,
});
} catch (error) {
const errorMessage = error instanceof Error ? error.message : String(error);
throw new Error(`Failed to acquire lock for ${filePath}: ${errorMessage}`);
}
try {
await writeFile(filePath, content, { encoding: 'utf8', ...options });
if (options?.mode) {
await chmod(filePath, options.mode);
}
} catch (error) {
const errorMessage = error instanceof Error ? error.message : String(error);
throw new Error(`Failed to write to file ${filePath}: ${errorMessage}`);
} finally {
if (release) {
try {
await release();
} catch (error) {
// Log but don't throw on release failure
Logger.error(`Failed to release lock for ${filePath}:`, error);
}
}
const release = await lock(filePath, {
retries: {
retries: 10,
factor: 2,
minTimeout: 100,
maxTimeout: 3000,
},
lockfilePath,
});
await writeFile(filePath, content, { encoding: 'utf8', ...options });
if (options?.mode) {
await chmod(filePath, options.mode);
}
await release();
}