Remove debug logs and improve query coalescing timeout (#2241)

Removed unnecessary console.log statements from PuterFSProvider.js and WebServerService.js. Increased PENDING_QUERY_TTL to 3 seconds and added a timeout mechanism for coalesced queries in get_app to prevent indefinite waiting.
This commit is contained in:
Nariman Jelveh
2026-01-03 19:28:40 -08:00
committed by GitHub
parent 363b798026
commit 71bee556f6
3 changed files with 17 additions and 9 deletions
-2
View File
@@ -345,7 +345,6 @@ export default class PuterFSProvider {
} : {}),
};
console.log('raw fsentry', raw_fsentry);
const entryOp = await this.fsEntryController.insert(raw_fsentry);
await entryOp.awaitDone();
@@ -668,7 +667,6 @@ export default class PuterFSProvider {
* @returns {Promise<FSNode>}
*/
async write_new ({ context, parent, name, file }) {
console.log('calling write new');
const {
tmp, fsentry_tmp, message, actor: inputActor, app_id,
} = context.values;
+17 -6
View File
@@ -36,7 +36,14 @@ const tmp_provide_services = async ss => {
};
// TTL for pending get_app queries (request coalescing)
const PENDING_QUERY_TTL = 2; // seconds
const PENDING_QUERY_TTL = 3; // seconds
const QUERY_TIMEOUT = 2000; // max ms to wait for a coalesced query
// Wait for a promise, but give up after timeout
const withTimeout = (promise, ms) => Promise.race([
promise,
new Promise((_, reject) => setTimeout(() => reject(new Error('Query timeout')), ms))
]);
async function is_empty (dir_uuid) {
/** @type BaseDatabaseAccessService */
@@ -352,11 +359,15 @@ async function get_app (options) {
const pendingKey = `pending_app:${queryKey}`;
const pending = kv.get(pendingKey);
if ( pending ) {
// Reuse the existing pending query
log.info(`coalescing query for ${queryKey}`);
const result = await pending;
// shallow clone the result
return result ? { ...result } : null;
// Wait for existing query, but don't block forever
try {
log.info(`coalescing query for ${queryKey}`);
const result = await withTimeout(pending, QUERY_TIMEOUT);
return result ? { ...result } : null;
} catch (err) {
// Timeout or error - fall through and execute query directly
log.warn(`coalesced query failed for ${queryKey}, executing direct query`);
}
}
// Create a new pending query
@@ -110,7 +110,6 @@ class WebServerService extends BaseService {
const services = this.services;
await services.emit('start.webserver');
await services.emit('ready.webserver');
console.log('in case you care, ready.webserver hooks are done');
}
/**