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

Routeless engines using components from addons which have class based helper don't work #238

Open
vstefanovic97 opened this issue Jun 14, 2024 · 4 comments

Comments

@vstefanovic97
Copy link

engine-gjt-gts-bug

Repo with minimal reproduction: https://github.com/vstefanovic97/engine-gjs-gts-bug/tree/master

There is a problem when using gjs/gts in engines.

The problem happens when we import a component from a gjs/gts file inside of an engine.
The component can come from a v1 or v2 addon, if that component uses a class based helper it will error

In our case we have test-app which mount engine-foo which imports a foofoobar component from random-v2-addon, the foofoobar component uses an or helper which is a class based helper. The same also happens if component comes from a v1 addon.

Reproduction

cd test-app
npm run start

After the test-app is served click the show engine button, it will work the first time,
but if you close the engine, and open it again it will fail with the following error

Uncaught (in promise) Error: Cannot create new instances after the owner has been destroyed (you attempted to create helper:or)
    at InternalFactoryManager.create (index.js:355:1)
    at Proxy.create (index.js:204:1)
    at ClassicHelperManager.createHelper (index.js:2518:1)
    at manager.js:245:1
    at Object.evaluate (runtime.js:3097:1)
    at AppendOpcodes.evaluate (runtime.js:1037:1)
    at LowLevelVM.evaluateSyscall (runtime.js:4851:1)
    at LowLevelVM.evaluateInner (runtime.js:4829:1)
    at LowLevelVM.evaluateOuter (runtime.js:4822:1)
    at VM.next (runtime.js:5659:1)
@NullVoxPopuli
Copy link
Collaborator

In your repo, I see you're using ember-source 5.9 -- Does this happen in ember-source 5.4 as well? (I'm curious if the glimmer-vm changes are potentially the cause of the behavior (or the bug has always been there because we didn't really have strict--mode-using things for a while))

@vstefanovic97
Copy link
Author

vstefanovic97 commented Jun 14, 2024

@NullVoxPopuli I didn't try 5.4, but the app where we first saw this is still on 4.12 and it happens there

@vstefanovic97
Copy link
Author

@NullVoxPopuli from what I could see when debugging this when the engine first mounts we lookup the factory for the or helper
image

That factory has the owner saved on itself and it's the current engine instance and seems like when we un-mount and re-mount the engine, the engine instance is a new instance, but we use the same factory for the helper we don't lookup a new factory

That's what I'm observing so far

@vstefanovic97
Copy link
Author

vstefanovic97 commented Jun 17, 2024

@NullVoxPopuli the workaround I found is that if I convert the components from random-v1-addon and random-v2-addon into gjs/gts then everything works.

So basically the problem is when we have non-strict mode templates inside of strict mode templates it seems.
I guess the fix for this might be in glimmer vm or somewhere? I'm just don't have the expertise to figure out exact fix for this one :/

Do you think I need to file an issue to glimmer-vm repo?

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

No branches or pull requests

2 participants