NativeScript / NativeScript/nativescript-cli

Livesync hangs when modifying App_Resources in before-prepare hook

オープン
#3,251 コメント 4 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

run to-be-checked
主要言語
JavaScript
スター
1.1k
フォーク
204
平均マージ
1日 9時間
マージ済み PR(30日)
8

説明

Tell us about the problem

When using nativescript-localize with "tns run ios", it tries to sync Localizable.strings without rebuilding the app.

Which platform(s) does your issue occur on?

iOS, haven't tried on Android

Please provide the following version numbers that your issue occurs with:
  • CLI: 3.3.1
  • Cross-platform modules: 3.3.0
  • Runtime(s): 3.3.0
  • Plugin(s): nativescript-localize (2.0.5)
  • iOS 11 on iPhone X emulator
Please tell us how to recreate the issue in as much detail as possible.
git clone --depth 1 --branch v2.0.5 https://github.com/lfabreges/nativescript-localize.git
cd nativescript-localize
npm install
npm run compile
cd demo
npm install
tns run ios

Then make a change in the app/i18n/en.default.js file, change "Hello World !" to "Hello" for example.

Executing before-prepare hook from /Users/lfabreges/Documents/Developpement/nativescript-localize/demo/hooks/before-prepare/nativescript-localize.js
Preparing project...
Project successfully prepared (iOS)
Successfully transferred en.default.js.
Refreshing application...
Successfully synced application org.nativescript.demo.javascript on device ED5FEB43-DDA2-43FD-B693-4E07FD78CB1C.
Skipping prepare.
Successfully transferred Localizable.strings.
Refreshing application...
Successfully synced application org.nativescript.demo.javascript on device ED5FEB43-DDA2-43FD-B693-4E07FD78CB1C.
More

I think the problem occurs because :

  • The plugin modifies Localizable.strings in the App_Resources
  • Prepare is done and savePrepareInfo save the .nsprepareinfo file with a modified time greater that Localizable.strings modified time
  • The watcher detects that a change has been made to the Localizable.strings and add it to the queue
  • Prepared is skipped because no change is detected, appResourcesChanged is not set to true because containsNewerFiles returns false because Localizable.strings has been modified before .nsprepareinfo file is written to disk
  • Localizable.strings is synced but without a rebuild and the app hangs, I need to stop tns run, remove the platforms directory and fully rebuild and resinstall the app to make it work again

I tried to hook into the process but did not find a way to fix it, I triggered a build by modifying appResourcesChanged directly into the plugin, it works but Localizable.strings is stilled synced afterwards, so it hangs again.

I'm the author of the plugin, so I can change it if needed. I definitly need some help on it.

Regards.

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

一覧にある nativescript-localize のデモコマンドで問題を再現し、その後 hooks/before-prepare/nativescript-localize.js、App_Resources、および .nsprepareinfo の処理を調査します。watcher、prepare-skip の判断、Localizable.strings の同期がどのように連動するかを追跡します。app/i18n/en.default.js を変更しても iOS アプリがハングせず、必要な再ビルドまたはリソースの更新が正常に完了すれば完了です。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
ios, javascript
領域
build-system, cli, mobile-dev
issue の種類
バグ
難易度
4/5
見積もり時間
3〜5日
活発さ
停滞
明瞭さ
おおむね明確
初心者へのやさしさ
38/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。