Skip to content

Perform atomic write#57

Merged
slimbuck merged 3 commits intoplaycanvas:mainfrom
slimbuck:atomic-write
Sep 23, 2025
Merged

Perform atomic write#57
slimbuck merged 3 commits intoplaycanvas:mainfrom
slimbuck:atomic-write

Conversation

@slimbuck
Copy link
Copy Markdown
Member

WebGPU errors can result in hard exit of the application, sometimes leaving half-written SOG files (see #54).

This PR:

  • write the output to a temporary file
  • on sucess, rename tmp file to target filename
  • check for target overwrite before doing any work

This PR doesn't fix the underlying issue (WebGPU is being addressed separately), but at least means half files are not output.

@slimbuck slimbuck requested review from a team and Copilot September 23, 2025 14:41
@slimbuck slimbuck self-assigned this Sep 23, 2025
@slimbuck slimbuck added the bug Something isn't working label Sep 23, 2025
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR implements atomic file writes to prevent creation of corrupted half-written SOG files when WebGPU errors cause application crashes. The implementation creates temporary files first and renames them to the target filename on successful completion.

  • Replaces direct file writing with temporary file creation followed by atomic rename
  • Moves overwrite checking to occur before any processing work begins
  • Adds proper file handle cleanup with error handling

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment thread src/index.ts
Comment thread src/index.ts
@slimbuck slimbuck merged commit 6564f8b into playcanvas:main Sep 23, 2025
2 checks passed
@slimbuck slimbuck deleted the atomic-write branch September 23, 2025 15:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants