From 174dd08ffffc27bad5053a63afe49a9e69db4b51 Mon Sep 17 00:00:00 2001 From: undefined Date: Mon, 24 Oct 2022 02:57:28 +0800 Subject: [PATCH] core: fix concurrent load of locale --- packages/hydrooj/src/entry/common.ts | 4 ++-- packages/hydrooj/src/service/watcher.ts | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/hydrooj/src/entry/common.ts b/packages/hydrooj/src/entry/common.ts index 20fb1c4d2..73467f115 100644 --- a/packages/hydrooj/src/entry/common.ts +++ b/packages/hydrooj/src/entry/common.ts @@ -68,7 +68,7 @@ export async function builtinModel(ctx: Context) { } export async function locale(pending: string[], fail: string[]) { - await Promise.all(pending.map(async (i) => { + for (const i of pending) { const p = locateFile(i, ['locale', 'locales']); if (p && (await fs.stat(p)).isDirectory() && !fail.includes(i)) { try { @@ -86,7 +86,7 @@ export async function locale(pending: string[], fail: string[]) { logger.error(e); } } - })); + } await bus.parallel('app/load/locale'); } diff --git a/packages/hydrooj/src/service/watcher.ts b/packages/hydrooj/src/service/watcher.ts index f5073e6e5..2c268e150 100644 --- a/packages/hydrooj/src/service/watcher.ts +++ b/packages/hydrooj/src/service/watcher.ts @@ -152,7 +152,7 @@ export default class Watcher extends Service { for (const filename in require.cache) { const module = require.cache[filename]; const plugin = unwrapExports(module.exports); - if (!(typeof plugin === 'object' && 'apply' in plugin)) continue; + if (!(typeof plugin === 'object' && plugin && 'apply' in plugin)) continue; const runtime = this.ctx.registry.get(plugin); if (!runtime || this.declined.has(filename)) continue; pending.set(filename, runtime);