Skip to content
This repository has been archived by the owner on Jan 30, 2023. It is now read-only.

Cannot override ajax service #428

Open
Gaurav0 opened this issue Feb 4, 2019 · 17 comments
Open

Cannot override ajax service #428

Gaurav0 opened this issue Feb 4, 2019 · 17 comments

Comments

@Gaurav0
Copy link

Gaurav0 commented Feb 4, 2019

After upgrading to latest ember-ajax, it is no longer possible to override the ajax service using a js (not ts) file.

Minimal Reproduction (Run ember test): https://github.com/Gaurav0/repro-ajax-ts

@alexlafroscia
Copy link
Collaborator

Hey @Gaurav0, thanks for opening this issue! I'll try to talk with the ember-cli-typescript folks and see if we can figure out what's going on here... Worst case scenario, I suppose we can remove the TypeScript support.

@boris-petrov
Copy link
Contributor

I'm still having the same issue even with ember-ajax version 5. Is anyone else having the same problem?

@lifeart
Copy link

lifeart commented Mar 7, 2019

@boris-petrov same for me

@lifeart
Copy link

lifeart commented Mar 7, 2019

Looks like it's floating bug, some of our builds broken, some working well.

@boris-petrov
Copy link
Contributor

Yes, it was like that for me before also. 5.0.0 doesn't seem to have changed that. @Turbo87 - can we reopen this issue?

@dfreeman
Copy link

The only time I've run into this issue with ember-ajax@5 was when there was also an older version of it as a transitive dependency somewhere in my project. For those of you still having this problem, can you confirm (either by checking your lockfile or using something like ember-cli-dependency-lint) that you only have v5 of ember-ajax in your build?

@lifeart
Copy link

lifeart commented May 16, 2019

ya, found
image will try to catch it having only one dep

@boris-petrov
Copy link
Contributor

@dfreeman - I confirm that I have only ember-ajax 5 in my lock file and the issue appears. I am also using ember-cli-dependency-lint.

@dfreeman
Copy link

@boris-petrov do you have a reproduction you can share? I've tried everything I can think of to trigger the issue for myself and haven't ever managed it. At this point I don't think I'm going to be able to offer a diagnosis or fix until I can see the problem in action ☹️

@boris-petrov
Copy link
Contributor

@dfreeman - unfortunately I can't. :( I tried when we hit it and couldn't. Perhaps I'll try again at some point but the problem is that it's not consistent - it only fails sometimes. Are you sure you've tried it enough times?

Sorry I can't be of more help. Hopefully some day someone will come up with a nice reproduction. Let's leave the issue open until then if no one has something against that.

@dfreeman
Copy link

I've done things like leave ember test running in a loop overnight and still nothing, which makes me think there must be something in common in projects that have this issue that isn't the case in an out-of-the-box app. Even just a project where it sometimes happens would be helpful, because then I could look for what's different between that project and one where it never happens.

@boris-petrov
Copy link
Contributor

I don't know it will work by just looping ember test. Perhaps there has to be some change in a file somewhere so that the build-order is changed and then the bug to appear. Not sure about that, just shouting out ideas.

@lifeart - after you've fixed your duplicate ember-ajax does the bug appear on your side?

@lifeart
Copy link

lifeart commented May 17, 2019

@dfreeman
Copy link

@lifeart that repo has exactly the same issue as the one we talked about yesterday—the .ts service file in app is nondeterministically conflicting with the .js one in the addon.

@lifeart
Copy link

lifeart commented May 18, 2019

@dfreeman, right! After changing app/services/ajax.ts to app/services/ajax.js cannot reproduce issue with around 40 builds.

@boris-petrov
Copy link
Contributor

@dfreeman - I've obviously missed that. So having a .ts service file in an application, not in an addon, is not allowed when the names are in conflict? But a .js file works fine? Is this a bug or... I'm not sure how this can not be a bug. :) Is it an issue in ember-cli-typescript or somewhere else?

@chriskrycho
Copy link

@boris-petrov it's effectively a caching problem. When addons inject .js files into the app namespace, and we're compiling .ts files to .js files in the consuming app (always in the app namespace), we can end up in a situation where Ember CLI sees that there is already a .js file there, so it ignores the one generated from .ts. Which one it picks up seems to be semi-random (at least: we haven't chased it down to see if it's strictly replicable).

We don't have any good way to work around this so far as we've been able to see.

It's also an anti-pattern for addons to do this in my opinion—but unfortunately, a very common anti-pattern.

(Sorry for the long delay in one of the Typed Ember crew responding; we've all had full summers.)

I recommend closing this issue; I'll reference it with a link from a new documentation-focused issue on the ember-cli-typescript repo, to which we'll point addon authors in the future.

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

No branches or pull requests

7 participants