LearnNewsExamplesServices
Frontmatter
id7162
titleAdd Error Resilience to AST Processor
stateClosed
labels
enhancement
assigneestobiu
createdAtAug 2, 2025, 2:07 PM
updatedAtAug 2, 2025, 2:10 PM
githubUrlhttps://github.com/neomjs/neo/issues/7162
authortobiu
commentsCount0
parentIssue7130
subIssues[]
subIssuesCompleted0
subIssuesTotal0
blockedBy[]
blocking[]
closedAtAug 2, 2025, 2:10 PM

Add Error Resilience to AST Processor

Closed v10.3.0 enhancement
tobiu
tobiu commented on Aug 2, 2025, 2:07 PM

1. Summary

Wrap the core AST processing logic within astTemplateProcessor.mjs in a try...catch block to prevent a single file's parsing error from crashing the entire build process.

2. Rationale

The AST transformation is complex. If an edge case or a bug in the processor causes an error while parsing a specific file, the current implementation would throw an exception and halt the entire build. By adding error handling, we can isolate the failure. The processor will log the error for later inspection but return the original, untransformed content for the problematic file, allowing the build to complete successfully for all other files.

3. Scope & Implementation Plan

  1. Modify processFileContent: In buildScripts/util/astTemplateProcessor.mjs, wrap the entire block of code following the initial regex check in a try...catch (e) block.
  2. Implement Error Handling:
    • Inside the catch block, log a detailed error message to the console, including the error e and ideally the path of the file being processed (though we might need to pass the file path into the function for that).
    • Crucially, the catch block should return the original, unmodified fileContent, ensuring the build can continue.
  3. Update Return Value: Ensure the function signature and return value ({ content: fileContent, hasChanges: false }) are consistent in the catch path.

4. Definition of Done

  • The try...catch block is implemented in processFileContent.
  • A parsing error in one file logs a console error but does not stop the build.
  • The file that caused the error is passed through the build untransformed.
tobiu assigned to @tobiu on Aug 2, 2025, 2:07 PM
tobiu added parent issue #7130 on Aug 2, 2025, 2:07 PM
tobiu added the enhancement label on Aug 2, 2025, 2:07 PM
tobiu referenced in commit 690c380 - "Add Error Resilience to AST Processor on Aug 2, 2025, 2:10 PM
tobiu closed this issue on Aug 2, 2025, 2:10 PM