Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

iOS crash when running with release/production flag: Can't find variable: __metadata #8778

Closed
nabilzhafri opened this issue Aug 19, 2020 · 15 comments · Fixed by #8903
Closed

Comments

@nabilzhafri
Copy link

nabilzhafri commented Aug 19, 2020

Simply copy steps from here: https://nativescript.org/blog/upgrading-tips-for-angular-10/

npm i -g @angular/cli // You could be needing to prefix sudo on GNU/Linux and other Unix-like OSes.
npm i -g nativescript // You could be needing to prefix sudo on GNU/Linux and other Unix-like OSes.
npm i -g @nativescript/schematics // You could be needing to prefix sudo on GNU/Linux and other Unix-like OSes.

ng new workspace
cd workspace
ng add @nativescript/schematics --skipAutoGeneratedComponent

// start apps:
npm run ios --> this runs fine
npm run ios -- --release   --> this will cause error below
npm run ios -- --env.production   --> this will cause error below

Any idea why? Tried to search for solution but can't find any.
Happens to my existing project as well after upgrading to angular 10. Right now I can't seem to deploy the iOS app due to this issue. It's causing the app to crash on launching.

JavaScript stack trace:
file:///app/vendor.js:90935:15
at __webpack_require__(file:///app/runtime.js:75:34)
at file:///app/vendor.js:84982:90
at file:///app/vendor.js:85830:34
at __webpack_require__(file:///app/runtime.js:75:34)
at file:///app/vendor.js:42890:97
at __webpack_require__(file:///app/runtime.js:75:34)
at file:///app/vendor.js:62743:87
at __webpack_require__(file:///app/runtime.js:75:34)
at file:///app/vendor.js:35266:89
at __webpack_require__(file:///app/runtime.js:75:34)
at file:///app/vendor.js:64700:87
at __webpack_require__(file:///app/runtime.js:75:34)
at file:///app/vendor.js:66519:95
at file:///app/vendor.js:71822:34
at __webpack_require__(file:///app/runtime.js:75:34)
at file:///app/bundle.js:51:47
at __webpack_require__(file:///app/runtime.js:75:34)
at checkDeferredModules(file:///app/runtime.js:44:42)
at webpackJsonpCallback(file:///app/runtime.js:31:39)
at anonymous(file:///app/bundle.js:2:61)
at evaluate([native code])
at moduleEvaluation([native code])
at [native code]
at asyncFunctionResume([nativ<…>
JavaScript error:
file:///app/vendor.js:90935:15: JS ERROR ReferenceError: Can't find variable: __metadata
(CoreFoundation) *** Terminating app due to uncaught exception 'NativeScript encountered a fatal error: ReferenceError: Can't find variable: __metadata
at
file:///app/vendor.js:90935:15
at __webpack_require__(file:///app/runtime.js:75:34)
at file:///app/vendor.js:84982:90
at file:///app/vendor.js:85830:34
at __webpack_require__(file:///app/runtime.js:75:34)
at file:///app/vendor.js:42890:97
at __webpack_require__(file:///app/runtime.js:75:34)
at file:///app/vendor.js:62743:87
at __webpack_require__(file:///app/runtime.js:75:34)
at file:///app/vendor.js:35266:89
at __webpack_require__(file:///app/runtime.js:75:34)
at file:///app/vendor.js:64700:87
at __webpack_require__(file:///app/runtime.js:75:34)
at file:///app/vendor.js:66519:95
at file:///app/vendor.js:71822:34
at __webpack_require__(file:///app/runtime.js:75:34)
at file:///app/bundle.js:51:47
at __webpack_require__(file:///app/runtime.js:75:34)
at checkDeferredModules(file:///app/runtime.js:44:42)
at webpackJsonpCallback(file:///app/runtime.js:31:39)
at anonym<…>
NativeScript caught signal 6.
Native Stack:
1   0x103596171 sig_handler(int)
2   0x7fff522ab5fd _sigtramp
3   0x7fff5219ff39 itoa64
4   0x7fff5219bb7c abort
5   0x7fff500a2858 abort_message
6   0x7fff50093cbf demangling_unexpected_handler()
7   0x7fff51253c0b _objc_terminate()
8   0x7fff500a1c87 std::__terminate(void (*)())
9   0x7fff500a440b __cxa_get_exception_ptr
10  0x7fff500a43d2 __cxxabiv1::exception_cleanup_func(_Unwind_Reason_Code, _Unwind_Exception*)
11  0x7fff51253ad6 _objc_exception_destructor(void*)
12  0x103545b6f NativeScript::reportFatalErrorBeforeShutdown(JSC::ExecState*, JSC::Exception*, bool)
13  0x103597524 -[TNSRuntime executeModule:referredBy:]
14  0x102e8f4bf main
15  0x7fff520ce1fd start
JS Stack:
@nabilzhafri nabilzhafri changed the title iOS crash when running with release flag: Can't find variable: __metadata iOS crash when running with release/production flag: Can't find variable: __metadata Aug 19, 2020
@Ross-Olivares
Copy link

Hi @nabilzhafri
Thank you for reporting this issue.
We are going to try replicate this case on our end. Let me know if you can send us a sample project that can reproduce the issue.
For now, can you try doing following steps and let me know how it goes:

  1. Delete the following files/folders:
    node_modules
    platforms
    hooks
    package-lock.json
    webpack.config.js

  2. Run: npm i

  3. Then just rebuild the project: tns run <platform_name>

@nabilzhafri
Copy link
Author

@Ross-Olivares hi. for sample project, you can just follow instruction above.

Simply copy steps from here: https://nativescript.org/blog/upgrading-tips-for-angular-10/

@grey280
Copy link

grey280 commented Sep 23, 2020

If you'd like another sample project that exhibits this behavior, ns create and choose the Angular 'hello world' template - it has the same issue.

@farfromrefug
Copy link
Collaborator

@grey280 @nabilzhafri I think your issue is fixed in 7.0.5

@grey280
Copy link

grey280 commented Sep 24, 2020

@farfromrefug Nope - tested again with the Angular 'hello world' template after updating @nativescript/core to 7.0.5, same issue. Here's the stack trace from Xcode, if it's any help:

Terminating app due to uncaught exception 'NativeScript encountered a fatal error: Uncaught ReferenceError: __metadata is not defined
 at 
	(file:///app/vendor.js:91370:5)
	at __webpack_require__(file:///app/runtime.js:75:30)
	at (file:///app/vendor.js:85324:71)
	at (file:///app/vendor.js:86173:30)
	at __webpack_require__(file:///app/runtime.js:75:30)
	at (file:///app/vendor.js:42898:78)
	at __webpack_require__(file:///app/runtime.js:75:30)
	at (file:///app/vendor.js:62042:68)
	at __webpack_require__(file:///app/runtime.js:75:30)
	at (file:///app/vendor.js:35262:70)
	at __webpack_require__(file:///app/runtime.js:75:30)
	at (file:///app/vendor.js:69704:68)
	at __webpack_require__(file:///app/runtime.js:75:30)
	at (file:///app/vendor.js:64190:76)
	at (file:///app/vendor.js:69531:30)
	at __webpack_require__(file:///app/runtime.js:75:30)
	at 326(file:///app/bundle.js:51:28)
	at __webpack_require__(file:///app/runtime.js:75:30)
	at checkDeferredModules(file:///app/runtime.js:44:23)
	at webpackJsonpCallback(file:///app/runtime.js:31:19)
	at (file:///app/bundle.js:2:57)
	at require(:1:137)
', reason: '(null)'

@farfromrefug
Copy link
Collaborator

Did you update @nativescript/webpack? It needs an update too

@grey280
Copy link

grey280 commented Sep 24, 2020

This is with @nativescript/webpack@3.0.4, which is the latest version I see available on NPM.

@grey280
Copy link

grey280 commented Sep 24, 2020

I also tested by pulling this repo, building @nativescript/webpack from source, and dropping the result into node_modules, and had the same issue. (Admittedly, I'm not certain that I built @nativescript/webpack correctly, or that moving it into node_modules like that will even work how I was expecting it to.)

@farfromrefug
Copy link
Collaborator

@grey280 you are right a new webpack release is missing #8884

@grey280
Copy link

grey280 commented Sep 25, 2020

I saw the new WebPack release go out earlier this morning, and just finished testing the 'hello world' app using that. Didn't resolve the problem.

@NathanWalker
Copy link
Contributor

Fix published with 7.0.6
https://github.com/NativeScript/NativeScript/releases/tag/7.0.6-core

@farfromrefug
Copy link
Collaborator

@NathanWalker we need a new wepback release don't we? Will still fail because of the bundle config loader

@grey280
Copy link

grey280 commented Sep 25, 2020

@nativescript/core@7.0.6 and @nativescript/webpack@3.0.5 seems to be working, thank you!

@farfromrefug Nathan released @nativescript/webpack@3.0.5 a couple hours ago.

@farfromrefug
Copy link
Collaborator

Awesome then!

@NathanWalker
Copy link
Contributor

Thanks for confirmation @grey280 please let us know if you encounter anything else.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants