Feature/Fix: Implement Atomic Write Pattern for Instance File Integrity#503
Closed
FaiThiX wants to merge 65 commits intoalexemanuelol:instance_invalidfrom
Closed
Feature/Fix: Implement Atomic Write Pattern for Instance File Integrity#503FaiThiX wants to merge 65 commits intoalexemanuelol:instance_invalidfrom
FaiThiX wants to merge 65 commits intoalexemanuelol:instance_invalidfrom
Conversation
alexemanuelol#324) * add credentials guide for web version * add rustplusplus credentials app extension links * add rustplus token description
* New translations en.json (French) * New translations en.json (Spanish) * New translations en.json (Czech) * New translations en.json (German) * New translations en.json (Italian) * New translations en.json (Korean) * New translations en.json (Polish) * New translations en.json (Russian) * New translations en.json (Swedish) * New translations en.json (Turkish)
* Temporary solution to fcm notifications problem * fix smart switch/storage monitor/smart alarm pairing * fcm -> authtoken, hoster -> steamId * Update RustPlus.js removed extra lines * Update discordEmbeds.js removed extra lines * Update guildMemberRemove.js removed extra lines * Update discordMessages.js fixed merge conflict * Update AuthTokenListener.js whitespace correction and changed data to notification --------- Co-authored-by: Alexander Emanuelsson <alexander.emanuelsson94@gmail.com> Co-authored-by: FaiThiX <admin@faithix.gg>
…ow start a 5min polling session
…se notifications are basically useless when notification listening only lasts 5 min
* New translations en.json (French) * New translations en.json (Spanish) * New translations en.json (Czech) * New translations en.json (German) * New translations en.json (Italian) * New translations en.json (Korean) * New translations en.json (Polish) * New translations en.json (Russian) * New translations en.json (Swedish) * New translations en.json (Turkish)
* Update FcmListener.js * Update FcmListenerLite.js
* add travelingvendor map stuff * add traveling vendor commands for ingame and discord * fixes and img change for testing * changed the traveling vendor command from trvendor to vendor * updated image links for the discord embed * update docs for traveling vendor * changed spawned event message * add vendor image. thanks to davinator for the image * added halted and moving again setting * added missing translation * fixxed misspell * add information embed * vender -> vendor * new icon for traveling vendor (thanks to threedm on discord)
* New translations en.json (French) * New translations en.json (Spanish) * New translations en.json (Czech) * New translations en.json (German) * New translations en.json (Italian) * New translations en.json (Korean) * New translations en.json (Polish) * New translations en.json (Portuguese) * New translations en.json (Russian) * New translations en.json (Swedish) * New translations en.json (Turkish)
* New translations en.json (French) * New translations en.json (Russian)
* Add issue template * fix: adapt bug_report for nodejs project
* Updated Items November 2025 * Added CCTV for Cargo Ship and Ferry Terminal * Updated items.json with build-in script
* Updated Items November 2025 * Added CCTV for Cargo Ship and Ferry Terminal * Updated items.json with build-in script * add choices to the context menu - bugfix
* Updated Items November 2025 * Added CCTV for Cargo Ship and Ferry Terminal * Updated items.json with build-in script * add choices to the context menu - bugfix * fix vendingMachines sellorders
…rruption issues during system crashes.)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request addresses a critical issue where instance configuration files ([guildId].json) could become corrupted or truncated if the application or the host system crashed (e.g., power outage) during a file write operation.
🛠️ Solution Implemented: Atomic Write Pattern
The writeInstanceFile function has been refactored to use the Atomic Write Pattern:
Data is written to a temporary file (.tmp).
The file contents are explicitly synchronized to the disk using fsyncSync.
The temporary file is then atomically renamed to replace the original file (Fs.renameSync()).
This ensures that the targetPath file will always be either the last complete version or the new, complete version, thus preventing partial writes and corruption.
🧹 Cleanup
The readInstanceFile function was also updated to check for and remove any lingering .tmp files left behind by a previous, failed write attempt (cleanup of "stale temporary files").
🛡️ Benefit
This change significantly improves the data integrity and fault tolerance of the application.
Also updated the instance_invalid branch to the latest changes