Skip to content

fix: Handle Promise.all errors in environmentContext and gitIgnoreParser#16

Open
BingqingLyu wants to merge 1 commit into
mainfrom
fork-pr-424-fix-promise-all-error-environmentContext
Open

fix: Handle Promise.all errors in environmentContext and gitIgnoreParser#16
BingqingLyu wants to merge 1 commit into
mainfrom
fork-pr-424-fix-promise-all-error-environmentContext

Conversation

@BingqingLyu

@BingqingLyu BingqingLyu commented Apr 27, 2026

Copy link
Copy Markdown
Owner

Problem

This PR fixes the Promise.all error that occurs at index 2 in the getDirectoryContextString function when processing workspace directories. The error was reported from the official upstream repository.

Root Cause

The issue had multiple layers:

  1. Promise.all failure: If any directory in the workspace failed to be processed by getFolderStructure, the entire Promise.all would fail
  2. Unhandled errors in getFolderStructure: Unexpected errors during directory reading weren't properly handled
  3. Path conversion issues in GitIgnoreParser: The ignore library was receiving absolute paths instead of relative paths, causing RangeError

Solution

1. Enhanced Error Handling in \getDirectoryContextString\

  • Added try-catch blocks around each \getFolderStructure\ call within Promise.all
  • Failed directories now return error messages instead of crashing the entire operation
  • Added warning logs for debugging

2. Improved Error Handling in \getFolderStructure\

  • Added comprehensive error handling for unexpected errors beyond EACCES/ENOENT
  • Failed subdirectories are now skipped gracefully instead of throwing errors
  • Added warning logs for better debugging

3. Fixed Path Handling in \GitIgnoreParser\

  • Added try-catch around the ignore library calls
  • Handles path conversion errors gracefully
  • Returns false (don't ignore) as a safe default when errors occur

Testing

  • Added comprehensive test case for error handling in \getDirectoryContextString\
  • All existing tests continue to pass
  • Verified the fix resolves the Promise.all (index 2) error

Files Changed

  • \packages/core/src/utils/environmentContext.ts\ - Added Promise.all error handling
  • \packages/core/src/utils/environmentContext.test.ts\ - Added test for error scenarios
  • \packages/core/src/utils/getFolderStructure.ts\ - Enhanced error handling for unexpected errors
  • \packages/core/src/utils/gitIgnoreParser.ts\ - Added path conversion error handling
    This fix ensures the application remains stable even when encountering problematic directories or path issues.

- Add error handling to getDirectoryContextString to prevent Promise.all failures
- Add comprehensive error handling to getFolderStructure for unexpected errors
- Add error handling to GitIgnoreParser.isIgnored to handle path conversion issues
- Add test case for error handling in getDirectoryContextString
- Fixes Promise.all (index 2) error when processing workspace directories
Resolves the upstream error where Promise.all would fail if any directory
in the workspace encountered an error during folder structure processing.
@BingqingLyu

BingqingLyu commented May 7, 2026

Copy link
Copy Markdown
Owner Author

Conflict Group 3

This PR shares modified functions with 1 other PR(s): #13.

These PRs should be reviewed as a batch — merging one may affect the others.

Function File Also modified by
readFullStructure getFolderStructure.ts #13
graph LR
    PR439["PR #16"]
    FreadFullStructure_7180["readFullStructure<br>getFolderStructure.ts"]
    PR439 -->|modifies| FreadFullStructure_7180
    PR13["PR #13"]
    PR13 -->|modifies| FreadFullStructure_7180
Loading

Posted by codegraph-ai conflict detection.

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

Labels

conflicting-group-3 Conflicting PR group 3 — review as a batch conflicting-pr Shares at least one cross-PR dependency with other PRs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants