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

[Bug] Cannot use router.isActive, without first calling router.urlFor #20663

Open
amk221 opened this issue Mar 19, 2024 · 0 comments
Open

[Bug] Cannot use router.isActive, without first calling router.urlFor #20663

amk221 opened this issue Mar 19, 2024 · 0 comments

Comments

@amk221
Copy link
Contributor

amk221 commented Mar 19, 2024

🐞 Describe the Bug

Here is a demo app with a failing test

When calling router.isActive, an error is thrown: Cannot read properties of undefined (reading 'isActiveIntent'). Which seems to suggest routerMicrolib is undefined. Calling router.urlFor first, makes the isActive call work. presumably it sets up routerMicrolib.

Stack trace

isActive	@	router-service.js:250
get isActive	@	foo.js:44
getPossibleMandatoryProxyValue	@	index.js:1611
_getProp	@	index.js:1635
(anonymous)	@	reference.js:164
(anonymous)	@	reference.js:125
track	@	validator.js:660
valueForRef	@	reference.js:124
(anonymous)	@	runtime.js:2971
(anonymous)	@	reference.js:125
track	@	validator.js:660
valueForRef	@	reference.js:124
(anonymous)	@	runtime.js:1736
evaluate	@	runtime.js:1061
evaluateSyscall	@	runtime.js:4920
evaluateInner	@	runtime.js:4898
evaluateOuter	@	runtime.js:4891
next	@	runtime.js:5744
_execute	@	runtime.js:5733
execute	@	runtime.js:5707
handleException	@	runtime.js:5036
handleException	@	runtime.js:5252
throw	@	runtime.js:4979
evaluate	@	runtime.js:1415
_execute	@	runtime.js:4966
(anonymous)	@	runtime.js:4940
debug.runInTrackingTransaction	@	validator.js:115
execute	@	runtime.js:4940
rerender	@	runtime.js:5278
(anonymous)	@	index.js:4724
(anonymous)	@	index.js:4691
(anonymous)	@	index.js:4981
inTransaction	@	runtime.js:4073
_renderRoots	@	index.js:4963
_renderRootsTransaction	@	index.js:5007
_revalidate	@	index.js:5039
invoke	@	backburner.js.js:272
flush	@	backburner.js.js:188
flush	@	backburner.js.js:344
_end	@	backburner.js.js:773
Backburner._boundAutorunEnd	@	backburner.js.js:509
Promise.then (async)		
iterations	@	backburner.js.js:26
flush	@	index.js:40
_scheduleAutorun	@	backburner.js.js:939
_end	@	backburner.js.js:779
Backburner._boundAutorunEnd	@	backburner.js.js:509
Promise.then (async)		
iterations	@	backburner.js.js:26
flush	@	index.js:40
_scheduleAutorun	@	backburner.js.js:939
_end	@	backburner.js.js:779
Backburner._boundAutorunEnd	@	backburner.js.js:509
Promise.then (async)		
iterations	@	backburner.js.js:26
flush	@	index.js:40
_scheduleAutorun	@	backburner.js.js:939
_ensureInstance	@	backburner.js.js:930
ensureInstance	@	backburner.js.js:742
scheduleRevalidate	@	index.js:3396
dirtyTag	@	validator.js:377
(anonymous)	@	index.js:4630
updateRef	@	reference.js:138
setOutletState	@	index.js:4657
(anonymous)	@	setup-rendering-context.js:163
Promise.then (async)		
render	@	setup-rendering-context.js:102
(anonymous)	@	foo-test.js:11
runTest	@	qunit.js:415
run	@	qunit.js:413
eval	@	qunit.js:457
processTaskQueue	@	qunit.js:673
advanceTaskQueue	@	qunit.js:667
advance	@	qunit.js:665
eval	@	qunit.js:543
setTimeout (async)		
internalStart	@	qunit.js:543
release	@	qunit.js:527
resolve	@	qunit.js:528
Promise.then (async)		
resolvePromise	@	qunit.js:530
callHook	@	qunit.js:417
runHook	@	qunit.js:426
processTaskQueue	@	qunit.js:673
advanceTaskQueue	@	qunit.js:667
advance	@	qunit.js:665
eval	@	qunit.js:543
setTimeout (async)		
internalStart	@	qunit.js:543
release	@	qunit.js:527
resolve	@	qunit.js:528
Promise.then (async)		
resolvePromise	@	qunit.js:530
callHook	@	qunit.js:417
runHook	@	qunit.js:426
processTaskQueue	@	qunit.js:673
eval	@	qunit.js:673
Promise.then (async)		
processTaskQueue	@	qunit.js:673
eval	@	qunit.js:673
Promise.then (async)		
processTaskQueue	@	qunit.js:673
advanceTaskQueue	@	qunit.js:667
advance	@	qunit.js:665
advanceTestQueue	@	qunit.js:675
advance	@	qunit.js:665
unblockAndAdvanceQueue	@	qunit.js:1059
Promise.then (async)		
begin	@	qunit.js:1067
eval	@	qunit.js:1059
setTimeout (async)		
scheduleBegin	@	qunit.js:1059
load	@	qunit.js:1058
load (async)		
addEvent	@	qunit.js:1158
eval	@	qunit.js:1250
eval	@	qunit.js:1269
eval	@	qunit.js:1269
./node_modules/qunit/qunit/qunit.js	@	chunk.vendors-node_m…eb5b7192bd18b.js:94
__webpack_require__	@	chunk.tests.3a32729….js:108
eval	@	tests.cjs:20
Module.exports	@	loader.js:106
Module._reify	@	loader.js:143
Module.reify	@	loader.js:130
Module.exports	@	loader.js:104
requireModule	@	loader.js:27
(anonymous)	@	tests-suffix.js:1

🔬 Minimal Reproduction

See demo app

😕 Actual Behavior

Error is thrown

🤔 Expected Behavior

isActive should return whether the route is active

🌍 Environment

ember-cli: 5.6.0
node: 18.16.0
os: darwin arm64

➕ Additional Context

Add any other context about the problem here.

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

No branches or pull requests

2 participants