LearnNewsExamplesServices
Frontmatter
id8484
titleOptimize uploadKnowledgeBase script: Early Exit and Robust Cleanup
stateClosed
labels
enhancementaibuild
assigneestobiu
createdAtJan 9, 2026, 10:18 PM
updatedAtJan 9, 2026, 10:22 PM
githubUrlhttps://github.com/neomjs/neo/issues/8484
authortobiu
commentsCount1
parentIssuenull
subIssues[]
subIssuesCompleted0
subIssuesTotal0
blockedBy[]
blocking[]
closedAtJan 9, 2026, 10:22 PM

Optimize uploadKnowledgeBase script: Early Exit and Robust Cleanup

Closed v11.20.0 enhancementaibuild
tobiu
tobiu commented on Jan 9, 2026, 10:18 PM

buildScripts/uploadKnowledgeBase.mjs needs two improvements:

  1. Cleanup Logic: The current finally block might not execute if the process exits early via process.exit(1) inside the catch block. We should ensure the zip file is always cleaned up, even on failure. The process.exit(1) calls should likely be removed or moved to the end, or we should use a more robust cleanup mechanism (like listening for exit events or just restructuring the flow).
  2. Execution Order: The script currently creates the large zip file before checking if the GitHub release exists. This is inefficient. We should check for the existence of the release tag on GitHub first. If the tag is missing, we should abort immediately without spending time and disk I/O creating the zip.

Proposed Flow:

  1. Check if chroma-neo-knowledge-base exists locally.
  2. Check if the target release tag exists on GitHub.
  3. Zip the knowledge base.
  4. Upload to GitHub.
  5. Cleanup (delete zip).
tobiu added the enhancement label on Jan 9, 2026, 10:18 PM
tobiu added the ai label on Jan 9, 2026, 10:18 PM
tobiu added the build label on Jan 9, 2026, 10:18 PM
tobiu assigned to @tobiu on Jan 9, 2026, 10:19 PM
tobiu referenced in commit 1135f12 - "refactor: Optimize uploadKnowledgeBase flow and cleanup (#8484)" on Jan 9, 2026, 10:20 PM
tobiu referenced in commit 7ac2ba2 - "fix: Ensure zip cleanup runs by deferring process.exit (#8484)" on Jan 9, 2026, 10:22 PM
tobiu
tobiu Jan 9, 2026, 10:22 PM

Input from Gemini 3 Pro:

✦ I have applied a critical fix to the script logic. process.exit(1) inside the catch block would terminate the process immediately, bypassing the finally block and leaving the zip file behind.

I replaced this with an exitCode variable that is checked at the very end of the function, ensuring that the cleanup logic in finally always executes before the process terminates.

Fix applied and pushed to dev.

tobiu closed this issue on Jan 9, 2026, 10:22 PM