Skip to content

backstackEntry exception using .navigate in blank template #6590

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

Closed
ajoslin103 opened this issue Nov 21, 2018 · 3 comments
Closed

backstackEntry exception using .navigate in blank template #6590

ajoslin103 opened this issue Nov 21, 2018 · 3 comments
Assignees

Comments

@ajoslin103
Copy link

Environment
Provide version numbers for the following components (information can be retrieved by running tns info in your project folder or by inspecting the package.json of the project):
tns version 5.0.1
✔ Component nativescript has 5.0.1 version and is up to date.
✔ Component tns-core-modules has 5.0.3 version and is up to date.
✔ Component tns-android has 5.0.0 version and is up to date.
✔ Component tns-ios has 5.0.0 version and is up to date.
Mac os x 10.14.1
VSCode 1.29.1
Node 10.13.0

Describe the bug
runtime exception when trying to navigate

CONSOLE WARN file:///app/tns_modules/tns-core-modules/application/application.js:273:26: Fatal JavaScript exception - application has been terminated.
file:///app/tns_modules/tns-core-modules/ui/frame/frame.js:49:57: JS ERROR TypeError: undefined is not an object (evaluating 'backstackEntry.resolvedPage.ios')

To Reproduce
clone blank template (tns create my-blank-js --template tns-template-blank)
add page-two.js & page-two.xml files (see below)
modify home-page.xml to add a Label with a tap to home-page.xml
modify home-page.js to export a function to navigate on the tap
run the project in the VSCode Debugger
tap the 'go to page two' label
get exception [above]

  • here is the full console output
[NativeScriptCli] execute: tns --analyticsClient VSCode --version
Version: 0.8.3
Build version: v.2018.10.19.1
Commit id: 3d1f5eb4413af34503e018fe35ccf21831c4b1d9
NativeScript CLI: 5.0.1
[NativeScriptCli] execute: tns --analyticsClient VSCode --version
[NSDebugAdapter] Using tns CLI v5.0.1 on path 'tns'
[NSDebugAdapter] Running tns command...
[NativeScriptCli] execute: tns --analyticsClient VSCode debug ios --watch 
[NSDebugAdapter] Watching the tns CLI output to receive a connection token
Searching for devices...
Executing before-watchPatterns hook from /Users/ajoslin/Documents/Als/Development/NativeScript/my-blank-js/hooks/before-watchPatterns/nativescript-dev-webpack.js
Executing before-watch hook from /Users/ajoslin/Documents/Als/Development/NativeScript/my-blank-js/hooks/before-watch/nativescript-dev-webpack.js
Executing before-shouldPrepare hook from /Users/ajoslin/Documents/Als/Development/NativeScript/my-blank-js/hooks/before-shouldPrepare/nativescript-dev-webpack.js
Skipping prepare.
Successfully transferred all files on device DB836343-1BA7-4D2B-B19C-3C8E4B1C0411.
org.nativescript.myblankjs: org.nativescript.myblankjs: 71224
Setting up debugger proxy...
Press Ctrl + C to terminate, or disconnect.
Opened localhost 41000
To start debugging, open the following URL in Chrome:
chrome-devtools://devtools/remote/serve_file/@02e6bde1bbe34e43b309d4ef774b1168d25fd024/inspector.html?experiments=true&ws=localhost:41000
Successfully synced application org.nativescript.myblankjs on device DB836343-1BA7-4D2B-B19C-3C8E4B1C0411.
Traceback (most recent call last):
  File "<input>", line 1, in <module>
  File "/usr/local/Cellar/python@2/2.7.14_3/Frameworks/Python.framework/Versions/2.7/lib/python2.7/copy.py", line 52, in <module>
    import weakref
  File "/usr/local/Cellar/python@2/2.7.14_3/Frameworks/Python.framework/Versions/2.7/lib/python2.7/weakref.py", line 14, in <module>
    from _weakref import (
ImportError: cannot import name _remove_dead_weakref
[NSDebugAdapter] Ready to attach to application on 41000
Frontend client connected.
NativeScript debugger has opened inspector socket on port 18183 for org.nativescript.myblankjs.
Backend socket created.
CONSOLE LOG file:///app/tns_modules/tns-core-modules/inspector_modules.js:1:82: Loading inspector modules...
CONSOLE LOG file:///app/tns_modules/tns-core-modules/inspector_modules.js:6:12: Finished loading inspector modules.
NativeScript debugger attached.
CONSOLE LOG file:///app/home/home-page.js:16:16: HomeViewModel Tap
CONSOLE WARN file:///app/tns_modules/tns-core-modules/application/application.js:273:26: Fatal JavaScript exception - application has been terminated.
file:///app/tns_modules/tns-core-modules/ui/frame/frame.js:49:57: JS ERROR TypeError: undefined is not an object (evaluating 'backstackEntry.resolvedPage.ios')

Expected behavior
to see page two

Sample project
start with blank template
add page-two.js [empty file]
add page-two.xml

<Page class="page"
    xmlns="http://schemas.nativescript.org/tns.xsd">
    <ActionBar class="action-bar">
        <Label class="action-bar-title" text="Page Two"></Label>
    </ActionBar>
</Page>

modify home-page.xml to insert a Label into the GridLayout

<Label tap="gotoPageTwo" text="Go To Page Two"></Label>

modify home-page.js to add&export a tap function

function gotoPageTwo(args) {
    console.log("HomeViewModel Tap");
    frameModule.topmost().navigate("page-two");
}
exports.gotoPageTwo = gotoPageTwo;

Additional context
I've been reading everything I can find about navigation and looking at other samples - I know I'm missing something... (or it would be working) -- but on the off chance that something is missing in the given configs, or a tip can be added to aid too-weary-too-soon travelers...

Thank you for your time and attention

@tsonevn tsonevn self-assigned this Nov 21, 2018
@tsonevn
Copy link
Contributor

tsonevn commented Nov 21, 2018

Hi @ajoslin103,
I have created a sample project using the described steps, however, was unable to recreate the issue, you are facing. For your convenience, I am attaching the project. Please review it and make the needed changes, which will allow me to reproduce the problem.
Archive.zip

@ajoslin103
Copy link
Author

#1 I am very happy to say that your project worked also for me. I really was starting to doubt myself.

#2 I am very mystified to report that my sample project now works! I am really starting to doubt myself!!

I had created that minified project as a minimal test case -- my existing project is still failing...

Ok, I moved the sample pages into my app and navigate to them and it works, I put my original 2nd pages into their place and that works, I put them back where they were and that fails..

Ah! I was navigating with a relative path, not an absolute path. I had created a 'map' folder as a sibling to the 'home' folder and was navigating to "../map/map-page" from home/home-page -- and that path doesn't exist given a starting point above 'home' as opposed to inside 'home'. No wonder it couldn't figure out how to build a backstackEntry.

"It's never Too Late to make a Rookie Mistake"

I'll go do a PR suggesting that they add the Tip (mentioning the absolute path) from "The Basics" article (in the Docs) to the basics section of the "Architecture and Navigation" document

Thank you so much for your time,
Al;

@tsonevn tsonevn closed this as completed Nov 22, 2018
@lock
Copy link

lock bot commented Nov 22, 2019

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked and limited conversation to collaborators Nov 22, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants