A user, merefield, is experiencing issues overriding a getter in a controller using the modifyClass method in Discourse 3.0.0. The issue is a TypeError: this.model is undefined error.
merefield notes that this issue doesn’t occur in the latest version, but only in 3.0.0. After further testing, merefield confirms that the issue occurs in Development mode but not in Production.
merefield discovers that the issue is related to an upstream Ember.js problem, specifically issue #18860. david creates a minimal failing test case to track progress.
david notes that the issue persists in Ember 4.x. However, a fix is proposed in a PR (#20388), which is eventually merged and backported to Ember 3.28. david updates Discourse to use the fixed version, and users are asked to report any further issues after updating.
The example should work, and I’m not aware of any relevant changes between the stable release and now. Let us know if you manage to reproduce the issue!
Uncaught (in promise) TypeError: While generating link to route "adminPlugins": this.model is undefined
get allAdminRoutes admin-plugins.js:20
note that I can put a debugger statement before the return this.model and it never fires the debugger.
@RGJ has kindly also looked at this and can repro this result.
This is a bit of a problem as clearly we need to develop stuff before it goes to production … but I don’t have to tell you that! Also a bit annoying it’s a problem on Stable …
I’m not sure how much we can do to fix this within Discourse - as you noted, the issue seems to be upstream in Ember. Perhaps we can patch the problematic method
To get us started, I’ve added a minimal failing test case so we can track progress. There are some comments in the test which describe why the issue is being triggered by our modifyClass system:
Funnily enough that seems to be the only progress over at the Ember project, within the associated PR which is still in Draft. I wonder if all that would be required is a polite request to prioritise it when the time becomes available?:
Yep, my test is based on theirs (but with the discourse-specific api.modifyClass api). I don’t think we should open a new issue - it’s 100% the same as the one that’s already open. We’ll see if we can do anything to get it prioritised.
This fix has now been released as part of Ember 3.28.12, and we’ve updated Discourse to use it. Please let us know if you’re still seeing any issues with modifyClass after updating to the latest Discourse.