Skip to content

[windows] File.readTextSync / File.writeTextSync are stubs — reads yield "undefined", writes silently no-op #11630

Open

Description

@aleclarson

On NativeScript Windows (packaged WinUI/MSIX x64 app), the synchronous file APIs in @nativescript/core are non-functional while their async counterparts work:

  • File.fromPath(p).readTextSync() returns the string "undefined" rather than file contents (feeding it to JSON.parse throws "undefined" is not valid JSON).
  • File.fromPath(p).writeTextSync(text) returns without throwing but does not modify the file. Subsequent calls in the same process also report success without writing — the file keeps its initial contents regardless of write count.

File.readText() / File.writeText() (async) perform real IO on the same paths.

Evidence: a packaged app calling writeTextSync 18 times per boot (instrumented counter, no thrown errors) produced a file containing only the first write's data; readTextSync of that file threw a JSON parse error on "undefined". This caused a preferences-persistence feature to silently lose every write — a real consumer-facing data-loss path for any app relying on the sync APIs (e.g. settings stores, caches).

Environment: Windows 11 x64 (10.0.26200.9711), packaged MSIX, NativeScript Windows runtime current as of Nov 2026.

Activity

  1. triniwiz commented on Nov 10, 2026

    @triniwiz
    Member

    Is this a report from the alpha runtime ?

  2. aleclarson commented on Nov 10, 2026

    @aleclarson
    ContributorAuthor

    @triniwiz No — the original report was already on the beta runtime: @nativescript/windows 1.0.0-beta.24 (core/vite pinned to the abae298 PR #11272 pkg.pr.new builds), packaged x64 MSIX.

    Revalidated on beta.24 again today in the same packaged context:

    • File.readTextSync() on a file with real contents returns undefined (the value, not a string)
    • File.writeTextSync() returns without throwing but does not reliably write — on a fresh file it produces an empty file, after which async writeText on the same File then throws Windows.Foundation.HResult
    • File.exists() also returns undefined rather than false for a missing path

    Async readText/writeText still perform real IO on the same paths, so the gap is specific to the *Sync projections. Still reproduces.

  3. triniwiz commented on Nov 11, 2026

    @triniwiz
    Member

    You can try updating the pkg version to 4fe2d65 windows supported core or 3456c82 linux supported core with some extra core fixes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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