From 91e12f68866e731e19db83bd6ecd359ab9779906 Mon Sep 17 00:00:00 2001 From: Daniel Salazar Date: Mon, 22 Dec 2025 15:52:24 -0800 Subject: [PATCH] fix: don't load bench.js files (#2207) * fix: autoloader grabbing bench.js files * fix: errors failing * fix: extension cache typ * cache: app icons --- extensions/api.d.ts | 3 ++- package-lock.json | 16 ++++++++++++---- src/backend/src/Kernel.js | 5 +++-- src/backend/src/modules/apps/AppIconService.js | 1 + tests/ci/common.py | 4 ++-- 5 files changed, 20 insertions(+), 9 deletions(-) diff --git a/extensions/api.d.ts b/extensions/api.d.ts index 70be94d8c..af35588c4 100644 --- a/extensions/api.d.ts +++ b/extensions/api.d.ts @@ -14,6 +14,7 @@ import type { RequestHandler } from 'express'; import type FSNodeContext from '../src/backend/src/filesystem/FSNodeContext.js'; import type helpers from '../src/backend/src/helpers.js'; import type * as ExtensionControllerExports from './ExtensionController/src/ExtensionController.ts'; +import kvjs from '@heyputer/kv.js'; declare global { namespace Express { interface Request { @@ -96,7 +97,7 @@ interface Extension extends RouterMethods { on(event: 'create.drivers', listener: (event: { createDriver: (interface: string, service: string, executors: any) => any }) => void), on(event: 'create.permissions', listener: (event: { grant_to_everyone: (permission: string) => void, grant_to_users: (permission: string) => void }) => void) on(event: 'create.interfaces', listener: (event: { createInterface: (interface: string, interfaces: DriverInterface) => void }) => void) - import(module: 'data'): { db: BaseDatabaseAccessService, kv: DynamoKVStore, cache: unknown } // TODO DS: type cache better + import(module: 'data'): { db: BaseDatabaseAccessService, kv: DynamoKVStore, cache: kvjs } import(module: 'core'): CoreRuntimeModule, import(module: 'fs'): FilesystemModule, import(module: 'query'): typeof query, diff --git a/package-lock.json b/package-lock.json index 0bf6a45fc..06f056e66 100644 --- a/package-lock.json +++ b/package-lock.json @@ -68,7 +68,7 @@ "yaml": "^2.8.1" }, "engines": { - "node": ">=20.19.5" + "node": ">=24.0.0" }, "optionalDependencies": { "sharp": "^0.34.4", @@ -5857,10 +5857,12 @@ } }, "node_modules/@types/node": { - "version": "20.19.25", + "version": "24.10.4", + "resolved": "https://registry.npmjs.org/@types/node/-/node-24.10.4.tgz", + "integrity": "sha512-vnDVpYPMzs4wunl27jHrfmwojOGKya0xyM3sH+UE5iv5uPS6vX7UIoh6m+vQc5LGBq52HBKPIn/zcSZVzeDEZg==", "license": "MIT", "dependencies": { - "undici-types": "~6.21.0" + "undici-types": "~7.16.0" } }, "node_modules/@types/node-fetch": { @@ -5871,6 +5873,12 @@ "form-data": "^4.0.4" } }, + "node_modules/@types/node/node_modules/undici-types": { + "version": "7.16.0", + "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-7.16.0.tgz", + "integrity": "sha512-Zz+aZWSj8LE6zoxD+xrjh4VfkIG8Ya6LvYkZqtUQGJPZjYl53ypCaUwWqo7eI0x66KBGeRo+mlBEkMSeSZ38Nw==", + "license": "MIT" + }, "node_modules/@types/pg": { "version": "8.6.1", "license": "MIT", @@ -16866,7 +16874,7 @@ "yargs": "^17.7.2" }, "devDependencies": { - "@types/node": "^20.5.3", + "@types/node": "^24.0.0", "chai": "^4.3.7", "jsdom": "^27.2.0", "mocha": "^10.2.0", diff --git a/src/backend/src/Kernel.js b/src/backend/src/Kernel.js index eaafae326..5c2b5516a 100644 --- a/src/backend/src/Kernel.js +++ b/src/backend/src/Kernel.js @@ -516,12 +516,13 @@ class Kernel extends AdvancedBase { const fullpath = path_.join(mod_path, directory); const fsitems = fs.readdirSync(fullpath); for ( const item of fsitems ) { - if ( ! item.endsWith('.js') ) { + if ( !item.endsWith('.js') && !item.endsWith('.cjs') && !item.endsWith('.mjs') ) { continue; } - if ( item.endsWith('.test.js') ) { + if ( item.endsWith('.test.js') || item.endsWith('.bench.js') ) { continue; } + const stat = fs.statSync(path_.join(fullpath, item)); if ( ! stat.isFile() ) { continue; diff --git a/src/backend/src/modules/apps/AppIconService.js b/src/backend/src/modules/apps/AppIconService.js index 1988c8a73..4e681d91e 100644 --- a/src/backend/src/modules/apps/AppIconService.js +++ b/src/backend/src/modules/apps/AppIconService.js @@ -79,6 +79,7 @@ class AppIconService extends BaseService { } = await this.get_icon_stream({ app_uid, size }); res.set('Content-Type', mime); + res.set('Cache-Control', 'public, max-age=3600'); stream.pipe(res); }, }).attach(app); diff --git a/tests/ci/common.py b/tests/ci/common.py index fa4d78a6c..fd1726288 100644 --- a/tests/ci/common.py +++ b/tests/ci/common.py @@ -30,7 +30,7 @@ def get_admin_password() -> str: """ Get the admin password from the backend server, throw an error if not found. """ - for attempt in range(90): # wait up to 60 seconds (1 minute) + for attempt in range(120): # wait up to 60 seconds (1 minute) time.sleep(1) # read the log file @@ -43,7 +43,7 @@ def get_admin_password() -> str: print(f"Extracted admin password: {admin_password}") return admin_password - raise RuntimeError(f"no admin password found after 60 seconds, check {LOG_PATH} for details") + raise RuntimeError(f"no admin password found after 120 seconds") def get_token(admin_password: str) -> str: