Closed lougreenwood closed 5 years ago
Hi @lougreenwood what is your Pember and fastboot version? Can you also take a look at https://github.com/shipshapecode/shipshape.io as mentioned in https://github.com/ember-cli/ember-fetch/pull/143#issuecomment-438046353 to see what's the difference?
@xg-wang I get the same error, I do not use Prember only fastboot 2.0.0.
@davidbilling Were you trying to make a fetch
before the instance initializer?
@xg-wang Not sure of the run-loop scoop of instance initialazer. My first fetch is directly when the page is loaded though. But I have not made any own instance initialaziers.
hey @xg-wang - I'm using:
prember 1.0.0
ember-cli-fastboot 2.0.0
ember 3.5.1
ember-cli 3.5.1
@lougreenwood @davidbilling Do you have reproduction steps?
For me, this happens when doing an ember b -prod
. I was already using ember-fetch
in this codebase and downgrading back to 5.1 fixes the issue.
As a side note, 6.2 works fine in the same codebase with ember s
- for me, it's only at build time where the problem appears.
I'm also using ember-auto-import
v1.2.13, if that's of any use.
@lougreenwood Does 6.1.1 has same issue?
Pretty sure it’s some of the app’s dependency has a ember-fetch with different version and public/fastboot-fetch.js got overwritten
@xg-wang I think you're right, seems that the problem is ember-simple-auth
- adding this to package.json seems to solve it for me:
"resolutions": {
"ember-simple-auth/**/ember-fetch": "^6.2.0"
}
@xg-wang @lougreenwood "resolutions" did not work for me. But I also have "ember-power-select" that uses ember-fetch 3.4.5 and other addons with ember-fetch. I will try to make a better test when I got more time.
I'm also getting this error, via the ember-cli-fastboot-testing
library.
To reproduce:
ember new my-app
ember install ember-cli-fastboot
ember s # works
ember install ember-cli-fastboot-testing
ember s
> Error: Could not find module `fetch/setup` imported from `my-app/instance-initializers/setup-fetch`
I think ember-cli-fastboot-testing
has the only dependency on ember-fetch so I'm not sure anything's getting overwritten. How would I go about finding that out?
I also got this error and I think that's because you have an instance initializer that calls fetch before fetch could be set up.
In my case, I called the current-user service which imported fetch
from an instance initializer. So you have to make sure your instance initializer comes after the fetch
one, but only in Fastboot mode.
Here's the fix that worked for me:
// app/instance-initializers/current-user.js
export function initialize(appInstance) {
let session = appInstance.lookup('service:session');
let currentUser = appInstance.lookup('service:current-user');
session.on('authenticationSucceeded', function() {
currentUser.load();
});
session.on('invalidationSucceeded', function() {
currentUser.unload();
});
}
const exportObject = {
initialize
}
if (typeof FastBoot !== 'undefined') {
exportObject.after = 'fetch';
}
export default exportObject;
I've installed from @xg-wang's https://github.com/ember-cli/ember-fetch/pull/167 PR commit and my builds are now succeeding ✅
"ember-fetch": "git+https://github.com/xg-wang/ember-fetch.git#a98c1b2a0b706cd8e663c90b631785ea49e08de7",
Hopefully https://github.com/ember-cli/ember-fetch/pull/167 can be merged in soon 👍
Released as v6.2.3. Feel free to reopen if this is still an issue.
This release introduced a regression in my app. The following code works in v6.2.2 but breaks in v6.2.3:
// app/instance-initializers/current-user.js
export function initialize(appInstance) {
let session = appInstance.lookup('service:session');
let currentUser = appInstance.lookup('service:current-user');
session.on('authenticationSucceeded', function() {
currentUser.load();
});
session.on('invalidationSucceeded', function() {
currentUser.unload();
});
}
const exportObject = {
initialize
}
if (typeof FastBoot !== 'undefined') {
exportObject.after = 'fetch';
}
export default exportObject;
(currentUser.load
calls fetch)
The error I get is
Error: Could not find module
fetch/setup
imported fromrarwe/instance-initializers/setup-fetch
Am I doing something wrong?
@balinterdi 🤔 fetch/setup
has been removed in v6.2.3 it shouldn't be invoked. https://github.com/ember-cli/ember-fetch/compare/v6.2.2...v6.2.3#diff-2992dd665823759d28df78b0c59aff62L1
@balinterdi
I think I same the same issue when I upgraded to 6.3.0, it was the same incompatibility with ember-simple-auth
's dependency on ember-fetch
5.x which I previously patched with a fork.
IIRC, adding this to package.json
resolutions fixed it for me:
"resolutions": {
"ember-simple-auth/**/ember-fetch": "^6.3.0"
}
@xg-wang I didn't invoke fetch/setup
directly from my code, not sure what did it. Anyway, I've now tested again with both version 6.3.1 and 6.2.3 and it worked fine in both cases – and without the need for the above hack (where I check in the instance-initializer if we're in Fastboot mode) or the resolution @lougreenwood mentioned.
@lougreenwood ember-simple-auth extended the range of acceptable ember-fetch versions in this commit, did you try and see if you need the explicit resolution with ESA master?
@balinterdi sure did, I actually submitted a PR before this commit - I was using my fork for my PR: https://github.com/simplabs/ember-simple-auth/pull/1716
Not sure why my fork stopped working but resolutions fixed it for me
@balinterdi Do you think it could be node_modules cache issue? Seems you don't see it anymore when you test it again.
@xg-wang Sorry, I no longer remember exactly what I did so that it started working. I don't recall doing anything in particular but it's possible that I removed node_modules and ran yarn
again.
Hello, I'm getting the following build error on my CI server. Downgrading to 5.1 (before
/instance-initializers/setup-fetch
was introduced) fixes the issue.