Skip to content
This repository was archived by the owner on Dec 15, 2025. It is now read-only.

Conversation

Copy link
Contributor

Copilot AI commented Dec 13, 2025

Post-refactor review of main.ts focusing on logging conventions, code cleanup, method ordering, and removing all error handling without structural changes.

Changes

  • Logging conventions

    • RPC initiators now use "-ing" form: "Joining node", "Leaving node"
    • RPC receivers use "-ed" form: "Node joined", "Node left" (unchanged)
    • Removed error logging for all data push operations per requirement
    • Retained logs for local operations: "Input processed", "Data received", "Found result"
  • Method ordering

    • ClusterManager.getAllNodes() now precedes getAllOtherNodes() (dependency order)
  • Unused code removal

    • Removed EagerNode.getNodeInfo() method
    • Removed ClusterManager.localAddr property
    • Removed NetworkHandler.id property
    • Prefixed unused constructor parameters with underscore
  • Error handling removal (requirement Cluster 的 Join 分成 Join 和 List 吧 #5)

    • Removed all 6 try-catch blocks from the codebase
    • Errors now cause immediate program termination (fail-fast behavior)
    • Removed try-catch from: joinCluster, leaveCluster, handleSearchResults, syncDataWithNode, setupIoHandling, and main function
// Before: error handling with try-catch
for (const node of otherNodes) {
    try {
        await this.networkHandler.callPushData(results, node.client);
    } catch (error) {
        console.error(`Failed to push data to node ${node.id}:`, error);
    }
}

// After: no error handling, let it crash
for (const node of otherNodes) {
    await this.networkHandler.callPushData(results, node.client);
}

The implementation adopts a fail-fast approach where any error will immediately crash the program rather than being caught and handled.

Original prompt

This section details on the original issue you should resolve

<issue_title>main.ts需要进行review</issue_title>
<issue_description>先前对main ts进行了重构,需要对其进行review,包括:

  1. 日志惯例的一致性(节点和数据相关,rpc发起方用ing,接收方用ed,但是发送data到其他节点的情况不要日志,无论是主动push还是被pull)
  2. 变量名的一致性
  3. 属性的顺序,函数的顺序的合理性与一致性
  4. 删除没有使用到的函数

注意,不要进行结构上的重构调整,也不要加上try catch。只做我上面说的四项检查与更新。</issue_description>

Comments on the Issue (you are @copilot in this section)

  • Fixes USTC-KnowledgeComputingLab/ddss#26

💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

@hzhangxyz
Copy link
Member

@copilot 忘了,加上第五条:删除代码中所有的try catch,有问题直接让他崩。

Copilot AI changed the title [WIP] Review main.ts for consistency and clean-up Review main.ts: fix logging conventions, remove unused code, reorder methods Dec 13, 2025
Copilot AI requested a review from hzhangxyz December 13, 2025 17:58
Copy link
Member

@hzhangxyz hzhangxyz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. 通篇检查一下,所有的地方不要try catch,直接跑,崩了就让它崩。
  2. 通篇检查一下,如果一个构造函数有一个参数没有使用,直接把它删掉。

Copy link
Contributor Author

Copilot AI commented Dec 13, 2025

@copilot 忘了,加上第五条:删除代码中所有的try catch,有问题直接让他崩。

已完成。所有 try-catch 块已删除,错误将直接导致程序崩溃。(Done. All try-catch blocks removed, errors will crash the program directly.) - fd272e9

Copilot AI changed the title Review main.ts: fix logging conventions, remove unused code, reorder methods Review main.ts: fix logging conventions, remove unused code, reorder methods, and remove all error handling Dec 13, 2025
Copilot AI requested a review from hzhangxyz December 13, 2025 18:04
@hzhangxyz hzhangxyz marked this pull request as ready for review December 13, 2025 18:05
Copilot AI review requested due to automatic review settings December 13, 2025 18:05
@hzhangxyz hzhangxyz merged commit 637fbf1 into main Dec 13, 2025
2 of 3 checks passed
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR refactors main.ts to standardize logging conventions, improve code organization, remove unused code, and adopt a fail-fast error handling approach. The changes focus on cleanup and consistency without structural modifications.

  • Standardized RPC logging with "-ing" form for initiators and "-ed" form for receivers
  • Removed all try-catch blocks to adopt fail-fast behavior where errors cause immediate program termination
  • Cleaned up unused code including properties, methods, and constructor parameters

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

main.ts需要进行review

2 participants