Comments (28)
I ended up getting this working by doing npm install --save abortcontroller-polyfill
in my fastboot repo. It's not great but a temporary workaround that lets me deploy again until this is fixed.
from ember-fetch.
I just ran into this problem and found the root cause.
#112 introduced the use of the abortcontroller-polyfill
library
#113 included the appropriate module in fastbootDependencies
so that consuming apps shouldn't have to do anything
The first release this stuff went out in was v5.0.0
To reproduce the problem, you need to have conflicting versions of ember-fetch
. I've forked @Mciocca's repo and made a small change which should make this reproducable for everyone.
Here's how we know we're in the problematic situation
$ yarn why ember-fetch
=> Found "[email protected]"
=> Found "ember-simple-auth#[email protected]"
✨ Done in 1.08s.
Now when you start the example and navigate to /google
, you should see
the error message.
Error: Unable to require module 'abortcontroller-polyfill/dist/cjs-ponyfill' because it was not in the whitelist.
at Object.require (/Users/mnorth/Development/fastboot-test/node_modules/fastboot/src/ember-app.js:133:15)
at Module.callback (/Users/mnorth/Development/fastboot-test/tmp/broccoli_merge_trees-output_path-5c3odJR1.tmp/ember-fetch/fastboot-fetch.js:4:44)
at Module.exports (/Users/mnorth/Development/fastboot-test/tmp/broccoli_merge_trees-output_path-5c3odJR1.tmp/assets/vendor/loader/loader.js:106:1)
at Module._reify (/Users/mnorth/Development/fastboot-test/tmp/broccoli_merge_trees-output_path-5c3odJR1.tmp/assets/vendor/loader/loader.js:143:1)
at Module.reify (/Users/mnorth/Development/fastboot-test/tmp/broccoli_merge_trees-output_path-5c3odJR1.tmp/assets/vendor/loader/loader.js:130:1)
at Module.exports (/Users/mnorth/Development/fastboot-test/tmp/broccoli_merge_trees-output_path-5c3odJR1.tmp/assets/vendor/loader/loader.js:104:1)
at requireModule (/Users/mnorth/Development/fastboot-test/tmp/broccoli_merge_trees-output_path-5c3odJR1.tmp/assets/vendor/loader/loader.js:27:1)
at Class._extractDefaultExport (/Users/mnorth/Development/fastboot-test/tmp/broccoli_merge_trees-output_path-5c3odJR1.tmp/assets/addon-tree-output/ember-resolver/resolvers/classic/index.js:410:1)
at Class.resolveOther (/Users/mnorth/Development/fastboot-test/tmp/broccoli_merge_trees-output_path-5c3odJR1.tmp/assets/addon-tree-output/ember-resolver/resolvers/classic/index.js:110:1)
at Class.superWrapper (/Users/mnorth/Development/fastboot-test/tmp/broccoli_merge_trees-output_path-5c3odJR1.tmp/assets/ember-utils.js:428:1)
What appears to be happenning here is a ember-fetch@5
is doing the stuff introduced by #112, but because a ember-fetch@3
is a the top-level dependency, the fix in #113 is not picked up. The end result is that a non-whitelisted module is require
d and the error is thrown
from ember-fetch.
So I played around with it and had these results:
Fastboot is require'ing from <your-app>/dist/node_modules/<module-name>
, but the node_modules
are not actually bundled into dist
, they are at <your-app>/node_modules/<module-name>
instead. The above case results in existsSync
check fails for both node-fetch
and abortcontroller-polyfill/dist/cjs-ponyfill
in this test.
When the check fails, Fastboot does require('abortcontroller-polyfill/dist/cjs-ponyfill')
- This succeeds when you serve express server from project root
- But it FAILs when you serve from anothe location
Then I changed to the actual path let nodeModulesPath = path.join(distPath, '..', 'node_modules', moduleName);
src.
Now require('<absolute-path-to>node-fetch')
succeeds but require('<absolute-path-to>abortcontroller-polyfill/dist/cjs-ponyfill')
fails.
I have to do require('absolute-path-to>abortcontroller-polyfill/dist/cjs-ponyfill.js')
and it will work.
Conclusion:
- To fix it @Mciocca can do
node server.js
fromfastboot-test/
- There's a <bug?> in Fastboot to read the node_modules
- ember-fetch should require .js file here and announce fastboot dep as
.js
. I need to check node's documentation about this.
from ember-fetch.
@Mciocca I use fastboot-aws and used above fix and installed the abortcontroller-polyfill in the fastboot-aws repro. That works for now.
from ember-fetch.
I'm seeing this issue as well in spite of upgrading. Should it be closed?
After using @mhluska's fix, I am seeing this:
Error: Cannot find module 'node-fetch'
from ember-fetch.
/cc @tchak @stefanpenner
from ember-fetch.
It looks like fasboot node packages are not properly installed...
from ember-fetch.
@tchak
I followed the instructions on the fastboot website. Where did I go wrong?
It could very well have been a mistake on my end or something not well documented.
from ember-fetch.
@Mciocca I just tried your demo app and it works for me... Can I see your server.js
file?
from ember-fetch.
@tchak Pretty much just copy and pasted from the fastboot-app-server
repo
const FastBootAppServer = require('fastboot-app-server');
const MY_GLOBAL = 'MY GLOBAL';
let server = new FastBootAppServer({
distPath: '/Users/mciocca/fb-test/dist',
gzip: true, // Optional - Enables gzip compression.
host: '0.0.0.0', // Optional - Sets the host the server listens on.
port: 4000, // Optional - Sets the port the server listens on (defaults to the PORT env var or 3000).
sandboxGlobals: { GLOBAL_VALUE: MY_GLOBAL }, // Optional - Make values available to the Ember app running in the FastBoot server, e.g. "MY_GLOBAL" will be available as "GLOBAL_VALUE"
chunkedResponse: true // Optional - Opt-in to chunked transfer encoding, transferring the head, body and potential shoeboxes in separate chunks. Chunked transfer encoding should have a positive effect in particular when the app transfers a lot of data in the shoebox.
});
server.start();
from ember-fetch.
Are you running server.js from another location other than fastboot-test/
?
I notice you're using distPath: '/Users/mciocca/fb-test/dist',
and the example is distPath: 'dist',
.
If you are running server.js from another location without node_modules
having your dependencies the error would be thrown.
from ember-fetch.
/cc @thoov
About the node_modules were missing in dist, I remember you were doing something related?
from ember-fetch.
@xg-wang so what's the fix here? I'm already running node server.js
in the project root. I tried rolling back ember-fetch from v5 to v4 with no improvement. I also tried appending .js to the require but the error persists.
from ember-fetch.
@xg-wang you shouldn't ideally need node_modules in dist if you don't have any whitelisted packages.
from ember-fetch.
@kratiahuja abortcontroller-polyfill
and node-fetch
are whitelisted by ember-fetch
, and should be abled to be required in Fastboot.
from ember-fetch.
@mhluska mind sharing a reproduction? I have @Mciocca 's example repo working by doing node server.js
from fastboot-test/
from ember-fetch.
Just wanted to add that I ran into this issue today after deploying a long overdue update. There were so many package upgrades to remember what exactly changed. @mhluska fix does it for me.
from ember-fetch.
Well, so in the end? How to solve this problem? Above in your answers, I saw nothing.
from ember-fetch.
After building, our app's "fastboot dist" package.json has abortcontroller-polyfill
and node-fetch
whitelisted, but only node-fetch
is included in the dependencies
.
For now, we've installed abortcontroller-polyfill
at the fastboot server level, as @mhluska suggested.
from ember-fetch.
I have the same problem, is there a way to contribute to a solution? This is a showstopper for my production... (I don't know that much about fastboot, yet)
from ember-fetch.
@davidbilling A temporary fix is to just keep your fastboot server in the root of your ember app's directory. It's not great to not be able to separate your ember app from your fastboot app server, but it works.
from ember-fetch.
When hitting this error today, installing npm install fastboot-app-server abortcontroller-polyfill
in a parent folder from dist
, fixed the problem for me.
(installing abortcontroller-polyfill
globally, didn't help)
from ember-fetch.
@mike-north It seems to be a different issue. I can reproduce @Mciocca 's issue with the non-root server.js
. You can compare the error message to confirm.
Actually if you open the file at Object.require (/Users/user/node_modules/fastboot/src/ember-app.js:130:18)
It points to the dist/node_modules/<package>
not found case.
from ember-fetch.
I did more debug.
The reason I have to do require('absolute-path-to>abortcontroller-polyfill/dist/cjs-ponyfill.js')
rather than require('<absolute-path-to>abortcontroller-polyfill/dist/cjs-ponyfill')
is that the exists-sync Fastboot uses is same thing to fs.existsSync()
. The file is ponyfill.js
so ponyfill
wouldn't exist, but we can actually require
it.
I think it's perfectly fine for ember-fetch
to require
abortcontroller-polyfill/dist/cjs-ponyfill
and it's Fastboot's responsibility to require
from the correct location for the module (rather than file).
I'll create an issue in Fastboot repo.
@kratiahuja @mike-north
from ember-fetch.
@Mciocca I modified your repro a bit and added some more description here https://github.com/xg-wang/fastboot-issue.
from ember-fetch.
@mhluska 's fix worked for me.
from ember-fetch.
Ref ember-fastboot/fastboot#227
from ember-fetch.
I have found if you just install ember-fetch
on the encapsulating server this works without the need to install all packages in the dist directory
from ember-fetch.
Related Issues (20)
- Version 6.7.2 onwards seems not to transpile to es5 (Caused IE11 Blank screen, with no console errors) HOT 2
- Could not find module `fetch` imported from `prog/instance-initializers/setup-fetch` HOT 2
- Operation outputFileSync is not allowed to use HOT 15
- Where are all the response headers? HOT 2
- Inconsistent Headers objects with preferNative HOT 1
- fetch is not defined - maybe your browser targets are not covering everything you need HOT 31
- v8.0.3 contains `yarn-error.log` file
- Ember 3.27+ issues deprecation for accessing `window.Ember` HOT 1
- Could not find module `rsvp` imported from `fetch` HOT 6
- Version 8.1.0 not released to NPM? HOT 1
- Migration from jquery.ajax $.ajaxSettings.traditional = true. How remove [] from params
- Dropping Node 10, older versions of Ember
- Archive this repo? HOT 16
- Deprecation warning for assign() from ember/polyfills
- Failed to execute 'fetch' on 'Window': Failed to read the 'signal' property from 'RequestInit': Failed to convert value to 'AbortSignal'.
- ember-polyfills.deprecate-assign deprication in Ember 4.4
- ember-fetch `input` type parameter is incorrect
- Upgrade package "node-fetch" to fix
- `Error: cannot find module rsvp imported from fetch`: Ember 4.12 + embroider-optimized scenario HOT 1
- Maintenance, V2, modern `fetch`, etc
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ember-fetch.