Skip to content
This repository has been archived by the owner on Dec 5, 2022. It is now read-only.

hmr is activated even without --hmr flag when creating release build #101

Closed
n0v1 opened this issue Sep 28, 2018 · 3 comments
Closed

hmr is activated even without --hmr flag when creating release build #101

n0v1 opened this issue Sep 28, 2018 · 3 comments

Comments

@n0v1
Copy link
Contributor

n0v1 commented Sep 28, 2018

Version

2.0.0

Platform and OS info

tns-ios 4.2.0
tns 4.2.4
macOS High Sierra

Steps to reproduce

  • Create new project with vue init nativescript-vue/vue-cli-template test
  • Create release build via tns build ios --bundle --release --env.production --forDevice
  • Install on device via Xcode

What is expected?

The app should run

What is actually happening?

The app crashes immediately after start with this error

CONSOLE LOG file:///app/bundle.js:1056:32: 'HMR: Sync...'
CONSOLE INFO file:///app/vendor.js:720:32: HMR: Hot Module Replacement Enabled. Waiting for signal.
2018-09-27 10:15:59.291 nativescriptvuetest[268:20927] ***** Fatal JavaScript exception - application has been terminated. *****
2018-09-27 10:15:59.292 nativescriptvuetest[268:20927] Native stack trace:
1   0x62b56d NativeScript::reportFatalErrorBeforeShutdown(JSC::ExecState*, JSC::Exception*, bool, bool)
2   0x6561c9 -[TNSRuntime executeModule:referredBy:]
3   0x57c5f main
4   0x224af873 <redacted>
2018-09-27 10:15:59.320 nativescriptvuetest[268:20927] JavaScript stack trace:
2018-09-27 10:15:59.321 nativescriptvuetest[268:20927] 1   onError@file:///app/vendor.js:21818:18
2   getFile@file:///app/vendor.js:21028:20
3   getFile@file:///app/vendor.js:21821:38
4   getCurrentHash@file:///app/vendor.js:850:30
5   checkState@file:///app/vendor.js:863:17
6   __onLiveSync@file:///app/bundle.js:1057:91
7   @file:///app/bundle.js:1071:36
8   ./main.js@file:///app/bundle.js:1089:34
9   __webpack_require__@file:///app/bundle.js:752:34
10  checkDeferredModules@file:///app/bundle.js:45:42
11  @file:///app/bundle.js:828:38
12  anonymous@file:///app/bundle.js:829:12
13  evaluate@[native code]
14  moduleEvaluation@[native code]
15  @[native code]
16  promiseReactionJob@[native code]
17  require@[native code]
18  anonymous@file:///app/starter.js:2:8
19  evaluate@[native code]
20  moduleEvaluation@[native code]
21  @[native code]
22  promiseReactionJob@[native code]
2018-09-27 10:15:59.321 nativescriptvuetest[268:20927] JavaScript error:
file:///app/vendor.js:21818:18: JS ERROR Error: Failed to create file at path '/var/containers/Bundle/Application/E298897F-6982-4964-B40B-2C33787CF4AB/nativescriptvuetest.app/app/2bffa5368eeae9388cb7.hot-update.json'
2018-09-27 10:15:59.324 nativescriptvuetest[268:20927] *** JavaScript call stack:
(

)
2018-09-27 10:15:59.324 nativescriptvuetest[268:20927] *** Terminating app due to uncaught exception 'NativeScript encountered a fatal error: Error: Failed to create file at path '/var/containers/Bundle/Application/E298897F-6982-4964-B40B-2C33787CF4AB/nativescriptvuetest.app/app/2bffa5368eeae9388cb7.hot-update.json'
 at 
1   onError@file:///app/vendor.js:21818:18
2   getFile@file:///app/vendor.js:21028:20
3   getFile@file:///app/vendor.js:21821:38
4   getCurrentHash@file:///app/vendor.js:850:30
5   checkState@file:///app/vendor.js:863:17
6   __onLiveSync@file:///app/bundle.js:1057:91
7   @file:///app/bundle.js:1071:36
8   ./main.js@file:///app/bundle.js:1089:34
9   __webpack_require__@file:///app/bundle.js:752:34
10  checkDeferredModules@file:///app/bundle.js:45:42
11  @file:///app/bundle.js:828:38
12  anonymous@file:///app/bundle.js:829:12
13  evaluate@[native code]
14  moduleEvaluation@[native code]
15  @[native code]
16  promiseReactionJob@[native code]
17  require@[native code]
18  anonymous@file:///app/starter.js:2:8
19  evaluate@[native code]
20  moduleEvaluation@[native code]
21  @[native code]
22  promiseReactionJob@[native code]
', reason: '(null)'
*** First throw call stack:
(0x228f791b 0x22092e17 0x62bb97 0x6561c9 0x57c5f 0x224af873)
libc++abi.dylib: terminating with uncaught exception of type NSException
warning: could not execute support code to read Objective-C class data in the process. This may reduce the quality of type information available.
(lldb) 

Cause

The variable hmr has value "undefined" (type string!) and thus is truthy when not specifying --hmr. So this check:


is always true and HotModuleReplacementPlugin gets injected no matter what.

Workaround

Add this code before destructuring env in webpack.config.js:

    // Make sure undefined environment variables are actually undefined
    Object.keys(env).forEach(key => {
      if (env[key] === "undefined") {
        env[key] = void 0
      }
    })

Not sure if this is by design or actually a bug somewhere else.

Related

@n0v1
Copy link
Contributor Author

n0v1 commented Sep 28, 2018

If env is provided by nativescript-dev-webpack, I guess this error would be fixed by upgrading to the latest version of nativescript-dev-webpack that includes the mentioned pull request.

@CoreyKaylor
Copy link

Ran into the same problem with different steps to reproduce. We use fastlane to do our appstore publishes and so for CI on travis we only use tns prepare ios / android and then use the fastlane tools to build using the typical xcode build steps. I worked around the issue, but it's definitely requiring manual intervention.

@nativescript-vue-bot
Copy link
Collaborator

We are locking this issue because it has been closed for more than 14 days.

If the issue comes up again please open a new issue with additional details.

@nativescript-vue nativescript-vue locked as resolved and limited conversation to collaborators Sep 8, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Development

No branches or pull requests

4 participants