Skip to content

fix: createDirectorySync reporting success without creating directory - #187

Open
tx3stn wants to merge 1 commit into
Snapchat:mainfrom
tx3stn:fix-mkdir
Open

tx3stn wants to merge 1 commit into
Snapchat:mainfrom
tx3stn:fix-mkdir

Conversation

@tx3stn

@tx3stn tx3stn commented Sep 13, 2026

Copy link
Copy Markdown
Contributor

Description

Ran into an edge-casey issue where createDirectorySync can report success without creating the directory.

FileStat derives isDir / isFile / size from a struct stat without checking whether the stat() call actually succeeded. POSIX leaves the buffer unspecified on failure.
statFromPath zeroes it beforehand, so on platforms where a failed stat leaves the buffer untouched it reads back as "not a directory" and everything works.
Where a failed stat writes into the buffer, isDirectory() returns true for a path that doesn't exist, and the early return added in #107 then skips creation entirely.

Observed on linux/amd64 under Docker Desktop emulation on Apple Silicon. minimal C reproduction gets it wrong in both directions:

stat before: ret=-1 errno=2 isdir=1     # call failed, yet reports a directory
mkdir:       ret=0                      # created fine
stat after:  ret=0  isdir=0             # exists, yet reports not a directory

Type of Change

  • Bug fix (non-breaking change that fixes an issue)
  • Documentation improvement
  • Performance optimization
  • Test improvement
  • Other (please describe)

Testing

  • Tests pass locally (bazel test //...)
  • Added/updated tests for changes (if applicable)
  • Tested on multiple platforms (iOS/Android/Web/macOS as applicable)
  • Manual testing performed (describe below)

Testing Details

Checklist

  • Code follows project style guidelines
  • Documentation updated (if needed)
  • No breaking changes (or documented in description)
  • Commit messages follow conventional format
  • No secrets, API keys, or internal URLs included

Related Issues

Additional Context

@github-actions

Copy link
Copy Markdown

🎉 Bazel & CI Test Results

Test Suite Result
Snapshot Tests ✅ success
Valdi Smoke Tests ✅ success
Linux: Module Tests ✅ success
Test Coverage Delta ✅ success
valdi_web Integration Test ✅ success
API Surface Check ✅ success
Linux: Hotreload Smoke ✅ success
Linux: Registry Validation ✅ success
Linux: C++ Tests ✅ success
Linux: Build & Export ✅ success
Linux: Build Compiler ✅ success
macOS: C++ & Platform Tests ✅ success

All Bazel configuration and CI tests passed!

The build system and core tooling are working correctly.

🚀 Bazel remote cache is now enabled - future builds will be faster!

Workflow: Valdi CI

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