Skip to content

Filesystem.readdir returns platform-dependent order between iOS and Android #74

@antonymarion

Description

@antonymarion

Bug Report

Plugin

@capacitor/filesystem

Current behavior

Filesystem.readdir() does not guarantee a deterministic order across platforms. In practice, iOS and Android can return entries in different orders for the same logical dataset.

For offline-first apps, this can lead to subtle cross-platform bugs when application code assumes chronological ordering (for sync queues, local media timelines, pending uploads, etc.).

Real-world scenario

A mobile app available on both iOS and Android stores files locally while offline (e.g. photos, notes, or sync payloads). Files are written in chronological order and then listed with readdir() to process oldest-first.

Even when the storage/write behavior is chronologically identical on both platforms, readdir() may return a different order, causing:

  • different processing order between platforms,
  • inconsistent UI ordering,
  • duplicate/conflicting sync behavior in edge cases.

Expected behavior

Filesystem.readdir() should return entries in a deterministic, cross-platform order (for example by mtime, then ctime, then name as stable tie-breaker), or explicitly document and expose sorting controls.

Reproduction idea

  1. Create multiple files in quick succession in the same directory on iOS and Android.
  2. Call Filesystem.readdir() for that directory.
  3. Compare returned arrays between platforms.
  4. Observe order differences despite equivalent file creation behavior.

Why this matters

Offline-first applications commonly rely on deterministic local ordering to avoid cross-platform divergence. Platform-dependent directory iteration order can cause hard-to-debug functional regressions.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions