NativeScript / NativeScript/nativescript-cli

Livesync hangs when modifying App_Resources in before-prepare hook

Đang mở
#3,251 4 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

run to-be-checked
Ngôn ngữ chính
JavaScript
Star
1.1k
Fork
204
Merge trung bình
1 ngày 9 giờ
Pull request đã merge (30 ngày)
8

Mô tả

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.

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Hướng nghiên cứu

Tái hiện sự cố bằng các lệnh demo nativescript-localize được liệt kê, sau đó kiểm tra hooks/before-prepare/nativescript-localize.js, App_Resources và cách xử lý .nsprepareinfo. Theo dõi cách watcher, quyết định prepare-skip và việc đồng bộ Localizable.strings tương tác với nhau. Được xem là hoàn tất khi việc thay đổi app/i18n/en.default.js không còn khiến ứng dụng iOS bị treo và quá trình rebuild bắt buộc hoặc cập nhật tài nguyên hoàn tất thành công.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
ios, javascript
Lĩnh vực
build-system, cli, mobile-dev
Loại issue
Lỗi
Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức độ hoạt động
Đình trệ
Độ rõ ràng
Khá rõ ràng
Mức phù hợp với người mới
38/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.