Skip to content

Commit

Permalink
wip: 异常时打印错误详情;throttleTime 默认值修改为 5s
Browse files Browse the repository at this point in the history
  • Loading branch information
renxia committed Jun 10, 2024
1 parent c137d8a commit 2a9e96f
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/lib/getConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ export function getConfig(useCache = true) {
);
}

config.throttleTime = Math.max(1, +config.throttleTime || 10);
config.throttleTime = Math.max(1, +config.throttleTime || 5);

if (!Array.isArray(config.ruleDirs)) config.ruleDirs = [config.ruleDirs as never as string];

Expand Down
3 changes: 2 additions & 1 deletion src/lib/rulesManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,8 @@ function loadRules(filepaths: string[] = [], isInit = false) {
rules.set(rule.ruleId, rule);
}
} catch (e) {
logger.debug('尝试从文件加载规则失败:', filepath, e.message);
console.error(e);
logger.warn('从文件加载规则失败:', color.yellow(filepath), color.red(e.message));
}
}

Expand Down
3 changes: 2 additions & 1 deletion src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ export default (server: Whistle.PluginServer, options: Whistle.PluginOptions) =>
const r = await ruleHandler({ req, rule, res });
if (r.body != null) return res.end(util.toBuffer(r.body) || '');
} catch (e) {
logger.error(`[ruleHandler][${color.red(rule.ruleId)}]err`, e);
console.error(e);
logger.error(`[ruleHandler][${color.red(rule.ruleId)}]err`, (e as Error).message || e);
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions w2.x-scripts.config.sample.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ const config = {
// envConfFile: 'env-config.sh',
/** 写入环境变量信息到本地文件的路径。若设置为空则不写入 */
// cacheFile: 'w2.x-scripts.cache.json',
/** 数据处理防抖时间间隔。单位为秒,默认为 10 (s) */
throttleTime: 10,
/** 数据处理防抖时间间隔。单位为秒,默认为 5 (s) */
throttleTime: 5,
/** 指定规则集文件路径或所在目录,尝试从该列表加载自定义的规则集 */
ruleDirs: [
// require.resolve('@lzwme/x-scripts-rules', { paths: require.main.paths }),
Expand Down

0 comments on commit 2a9e96f

Please sign in to comment.