Skip to content

Fixes Error - Uncaught Exception Error: write EIO #92 #118

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

shar-mayank
Copy link

  • This PR fixes the issue Error - Uncaught Exception Error: write EIO #92. Thanks to @vinaymaurya14, I went through his provided solution and fix the error message that was continuously popping when I execute the ./stealth-run.sh script. The app won't even quit that time and will through errors whenever any of the shortcut keys were pressed.
    Now both the script and compiled app works as intended.

Error message was:

A JavaScript error occurred in the main process
Uncaught Exception:
Error: write EIO
at afterWriteDispatched (node:internal/stream_base_commons:160:15)
at writeGeneric (node:internal/stream_base_commons:151:3)
at Socket._writeGeneric (node:net:952:11)
at Socket._write (node:net:964:8)
at writeOrBuffer (node:internal/streams/writable:447:12)
at _write (node:internal/streams/writable:389:10)
at Writable.write (node:internal/streams/writable:393:10)
at console.value (node:internal/console/constructor:304:16) at console.log (node:internal/console/constructor:379:26)
at App.<anonymous> (/Users/xxx/Documents/Projects/interview-coder-withoupaywall-opensource/dist-electron/main.js:515:13)

Attached is the video of error:

WhatsApp.Video.2025-07-22.at.15.41.49.mp4
  • I tested it manually, used every shortcut key commands available and concluded that the app works perfectly! @bhaumikmaan and @Anshumansingh01, please look into this.

fs.mkdirSync(this.logDir, { recursive: true })
}
} catch (error) {
// Silently fail - we can't log the error since we're creating the logger
Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't think we should silently fail this - if this fails there is no way of figuring out what went wrong before or after

Copy link
Author

Choose a reason for hiding this comment

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

You're absolutely right. If the log directory creation fails, we should at least attempt to use a fallback location or provide some indication of the failure. I'll update this to try a fallback directory and use stderr as a last resort.

Copy link
Collaborator

@bhaumikmaan bhaumikmaan left a comment

Choose a reason for hiding this comment

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

Thanks for the PR - it is a good addition.
We can merge once the review is addressed

try {
fs.appendFileSync(filePath, message, 'utf8')
} catch (error) {
// Silently fail - we can't use console.log here as it would cause the same issue
Copy link
Collaborator

Choose a reason for hiding this comment

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

This silent failing is fine as everything would be in the log file already.

Copy link
Author

Choose a reason for hiding this comment

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

Agreed, this silent failing is appropriate here since if we can't write to the log file, using console.log would defeat the purpose and potentially cause the original EIO error we're trying to solve.

}
})
} catch (error) {
// Silently fail
Copy link
Collaborator

Choose a reason for hiding this comment

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

This can be logged normally

Copy link
Author

Choose a reason for hiding this comment

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

You're right, since this would be called during normal operation (not during logger initialization), we can safely log this error using our own logging methods.

Comment on lines 85 to 86
// Clean up old logs (optional - call this periodically)
cleanupOldLogs(maxAgeDays: number = 7): void {
Copy link
Collaborator

Choose a reason for hiding this comment

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

When is this called? I don't see any function calls
If it is user driven - how can a user call it?
If not we can make a path redirect where the user can go themselves and manually delete the file

Copy link
Author

Choose a reason for hiding this comment

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

This function isn't currently called anywhere. I'll either remove it entirely since users can manually manage log files, or if we want to keep it, I can add it as a startup routine that runs once when the app initializes. What would you prefer?

Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't think it is wise to clear logs at session startup in case one needs to track past errors.
You could do any of the following:

  1. Give a button for log clearance
  2. Add a message in the initial dialog box with a redirect or a path name so users can do it manually
  3. Clear once a certain size limit is hit like 1 GB threshold (Put a message in the dialog box or the README) that the logs will clear after 1GB

Copy link
Author

@shar-mayank shar-mayank Jul 26, 2025

Choose a reason for hiding this comment

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

I don't think it is wise to clear logs at session startup in case one needs to track past errors.

yeah, you are right!

You could do any of the following:

  1. Give a button for log clearance
  2. Add a message in the initial dialog box with a redirect or a path name so users can do it manually
  3. Clear once a certain size limit is hit like 1 GB threshold (Put a message in the dialog box or the README) that the logs will clear after 1GB

Okay, I'm thinking of doing a combination of 2nd and 3rd by giving the option to delete it manually by redirecting to the logs directory and also implementing the deletion of logs once it hits 1 GB. I'll work on implementing this and will update ASAP!

stealth-run.sh Outdated
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: This shouldn't be a part of the diff - it gets automatically added when you run the application

@shar-mayank
Copy link
Author

I'll make the necessary changes and will commit soon

- Add automatic log directory cleanup when exceeding 1GB in SafeLogger

- Update WelcomeScreen with logs storage location for manual cleanup

- Implement getDirectorySize() and cleanup methods for logs

- Log cleanup actions for debugging purposes
Copy link
Author

@shar-mayank shar-mayank left a comment

Choose a reason for hiding this comment

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

Add Automatic Storage Management (1GB Cleanup)

Changes

  • Logs: Auto-clear when log directory exceeds 1GB
  • UI Updates: Added storage locations and cleanup info to WelcomeScreen and SettingsDialog

Implementation

  • SafeLogger.ts: Added size checking and cleanup before writing logs
  • UI components updated to show file locations for manual cleanup

Testing

Tested manually by different methods like changing the directory size to 1 MB for testing, creating test cases for manual checking and creating a fake log file that exceeds 1GB by dd if=/dev/zero of=test-large.log bs=1024 count=1126400 and verifying the result manually.

Fixes storage accumulation issues while maintaining app functionality.

@bhaumikmaan, @Ornithopter-pilot, @us1415, @dev-opsss and @Anshumansingh01, please verify and merge. Thank you.

@shar-mayank shar-mayank requested a review from bhaumikmaan July 26, 2025 17:47
@shar-mayank
Copy link
Author

Note to self: integrate OpenAI's Whisper when free from placements

@shar-mayank
Copy link
Author

@bhaumikmaan, Please approve when you get time

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants