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

未关闭
#11,630 3 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
48/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
活跃
技术栈
typescript
领域
backend

调研方向

Start by tracing File.readTextSync() and File.writeTextSync() in @nativescript/core, then compare their Windows implementations with the working async methods. Reproduce the reported behavior in a packaged Windows app and identify the relevant tests or entry points. Done means synchronous reads return file contents and repeated writes update the file on Windows.

由索引模型根据 Issue 内容生成。

描述

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.

主要语言
TypeScript
星标
25.7k
派生
1.7k
平均合并
4 天 2 小时
30 天内合并 PR
41

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

NativeScript/NativeScript 的其他 Issue

查看 NativeScript/NativeScript 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。