Skip to content

Conversation

@sensei-hacker
Copy link
Member

@sensei-hacker sensei-hacker commented Jan 31, 2026

Summary

Fixes the "fs is not defined" ReferenceError that occurs when trying to save mission files from the Mission Control tab.

Problem

Users encountered a JavaScript error when attempting to save mission files:

mission_control.js:4050 Uncaught (in promise) ReferenceError: fs is not defined

The legacy code was using Node.js fs.writeFile() directly from the renderer process, but the fs module is not accessible in Electron's renderer process due to context isolation.

Changes

  • Replaced fs.writeFile() with window.electronAPI.writeFile()
  • Updated from callback pattern to Promise-based API (.then())
  • Moved success messages inside .then() block to ensure they execute after file write completes

Testing

  • Mission file save dialog opens correctly
  • Files save successfully to selected location
  • No console errors during save operation
  • Tested with live configurator (yarn start)

This follows the same pattern already used in cli.js and other tabs that were previously updated.

Fixes the "fs is not defined" ReferenceError when saving mission files
from the Mission Control tab.

**Problem:**
- Legacy code was using Node.js fs.writeFile() directly from renderer
- fs module is not accessible in Electron's renderer process
- Users got error: "ReferenceError: fs is not defined" at line 4050

**Solution:**
- Replace fs.writeFile() with window.electronAPI.writeFile()
- Use Promise-based API (.then) instead of callback pattern
- Move success messages inside .then() block to ensure they execute
  after file write completes

**Testing:**
- Configurator builds without errors
- Mission file save dialog opens correctly
- Files save successfully to selected location
- No console errors

Follows the same pattern used in cli.js and other tabs.
@Jetrell
Copy link
Collaborator

Jetrell commented Feb 3, 2026

I tested this with Windows. When the 'save eeprom mission' button is pressed, the tab will go blank and then reappear with the mission WP's gone.
But if I load it, then save it again. It will then save fine. And every time after that.

I also noticed that other 9.0 builds before this fix will also work once a mission is saved via this build. i.e. before the PC is shutdown and cache is dumped.

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