Skip to content

fix: properly await all async operations and add error handling#5

Open
shivv23 wants to merge 5 commits into
IPFS-Meshkit:mainfrom
shivv23:fix/missing-await-and-async
Open

fix: properly await all async operations and add error handling#5
shivv23 wants to merge 5 commits into
IPFS-Meshkit:mainfrom
shivv23:fix/missing-await-and-async

Conversation

@shivv23

@shivv23 shivv23 commented Jul 23, 2026

Copy link
Copy Markdown

Summary

This PR fixes all missing await keywords and unhandled Promise rejections across the codebase. Several async operations were called without await, causing data corruption, silent failures, and unhandled Promise rejections.

Critical Bugs Fixed

File Issue Impact
Menu.tsx doSave() _getFile() called without awaitdata was a Promise object, so .created was undefined File constructed with corrupted metadata
Menu.tsx doSave() _saveFile() called without await — save could silently fail User sees "success" even when data is lost
NewFile.tsx newFile() Same _getFile() and _saveFile() missing await Same data corruption + silent failure
Files.tsx delete handler _deleteFile() called without await Delete can silently fail; UI refreshes before deletion completes

Changes by File

Menu.tsx

  • doSave(): Made async, added await to both _getFile() and _saveFile(), added try/catch
  • doSaveAs(): Added await before _saveFile(), wrapped in try/catch
  • doPrint(): Made async, added await to printer.print(), added try/catch
  • sendEmail(): Made async, added await to EmailComposer.open(), added try/catch

NewFile.tsx

  • newFile(): Made async, added await to _getFile() and _saveFile(), added try/catch

Dashboard.tsx

  • useEffect: Added .catch() to loadData() call to handle unhandled rejections
  • handleOpen(): Converted from .then() chain (with no .catch()) to async/await with try/catch
  • Added await to all 5 loadData() calls inside async handlers (handleBackup, handleRestore, handleShare, confirmDelete, handleNewFile)

Files.tsx

  • editFile(): Converted from .then() chain (with no .catch()) to async/await with try/catch
  • Delete handler: Made async, added await to _deleteFile() and loadFiles(), added try/catch
  • Added await to loadFiles() calls in handleBackup and handleRestore

BackupSuccessModal.tsx

  • Added console.warn to previously empty catch block in copyToClipboard

Verification

  • npx tsc --noEmit passes with zero new errors (only pre-existing @meshkit/ionic module stub error)

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.

1 participant