-
Notifications
You must be signed in to change notification settings - Fork 3
Terminal output capture is unreliable due to race conditions and fixed timeouts #4
Copy link
Copy link
Open
Labels
Description
Location
src/environment.ts (approx. lines 87–96)
Problem
The environment detection logic captures terminal output by writing to a temporary file and reading it after a fixed delay. This approach is unreliable and can fail on slower systems or under load.
Current behavior
terminal.sendText(`${checkCommand} ghci > /tmp/ghci_path 2>/dev/null || echo "not found" > /tmp/ghci_path`);
setTimeout(async () => {
const content = await vscode.workspace.fs.readFile(
vscode.Uri.file('/tmp/ghci_path')
);
}, 500);Issues Identified
Race condition
- The file may be read before the terminal finishes writing to it
- Results in false negatives even when tools are installed
Fixed timeout
- Hard-coded
500msdelay is unreliable - Slower machines or busy systems may require more time
Missing error handling
- No clear handling if the file does not exist
- Errors are silently ignored, making debugging difficult
Fragile design
- Depends on terminal behavior and filesystem timing
- Not suitable for reliable environment detection in a VS Code extension
Expected Behavior
- Tool detection should be deterministic and reliable
- No dependency on arbitrary timeouts
- Proper error handling if a tool is missing
- Works consistently across different system speeds and platforms
How to Test
-
Install the extension from the VS Code marketplace (or via VSIX).
-
Clone this repository, which contains simple Haskell files for testing:
https://github.com/midhunann/haskell-test -
Open the repository in VS Code.
-
Run the extension’s Haskell execution commands.
-
Verify that:
- Environment detection is consistent
- No false “tool not found” errors occur
- Behavior is stable on slower systems as well
Priority
High — causes intermittent failures and makes environment detection unreliable, especially on slower or heavily loaded systems.
NOTE: Come up with a solution and then start working on this.
Reactions are currently unavailable