Closed deanmarano closed 1 year ago
Looks like this is the same issue I have been seeing in fastboot mode here: https://github.com/simonihmig/ember-stargate/issues/413 - however I do not transition to a different route (I haven't seen that issue in non fastboot mode though...). Also it only appears when there is content rendered inside the portal.
Today I was finally debugging fastboot mode and I had very similar findings.
this.portalService.unregisterPortal(this._target)
. This causes the error.next()
block in the modify
hook is executed, which tries to register the portal for the first timeI am a bit puzzled why the destructor is being called before the stargate setup is completed - except that the app seems to be torn down before ember-stargate is done initializing itself fully. If I go back in the stacktrace, I end up in ember-app.js where the _destroy() method is called inside the visit() method. I also noticed that in ember-stargate Portals are not rendered in FastBoot mode - makes sense if the portal isn't even registered before the app is torn down. I just have no idea why this is happening.
Probably the best way to fix this is by setting a destroyed flag in the destructor, so one can make the code in the next() method a noop and stop trying to destroy a portal that hasn't been registered yet? Otherwise wrapping the destructor content in next() as well might also work. Then the portal would likely be registered and very soon deregistered again. However, the question also comes up, why the next() block is needed in first place? Also that will not fix that fastboot is unable to render the portals - but just remove the error.
@simonihmig any thoughts about that?
I think the original bug report should get fixed by #644. Will look into the fastboot story next...
Hi! I'm upgrading from
ember-stargate
0.2.0 to 0.4.3 (on Ember 3.24). It looks like this PR moved theregisterPortal
call into anext
call.This causes a bug when transitioning to my error route. When the
PortalTarget
first renders, it callsregisterPortal
. The transition to theerror
route happens before thenext
is called, andunregisterPortal
is called beforeregisterPortal
gets to thenext
call, which throws the error from the title.I'd be happy to work on a fix for this, but I'd like to do it in a way that makes sense. My first thought is to put the contents of
unregisterPortal
into anext
loop as well.