"fastbootMiddleware is not a function"
See original GitHub issueWe’re seeing this error from time to time when switching branches while leaving ember s
running. I haven’t digged deeper into it but though I’d open this as a heads up already.
Stacktrace:
TypeError: fastbootMiddleware is not a function
at app.use (/Users/<Redacted>/Projets/mweb/node_modules/ember-cli-fastboot/index.js:256:11)
at Layer.handle [as handle_request] (/Users/<Redacted>/Projets/mweb/node_modules/express/lib/router/layer.js:95:5)
at trim_prefix (/Users/<Redacted>/Projets/mweb/node_modules/express/lib/router/index.js:312:13)
at /Users/<Redacted>/Projets/mweb/node_modules/express/lib/router/index.js:280:7
at Function.process_params (/Users/<Redacted>/Projets/mweb/node_modules/express/lib/router/index.js:330:12)
at next (/Users/<Redacted>/Projets/mweb/node_modules/express/lib/router/index.js:271:10)
at err (/Users/<Redacted>/Projets/mweb/node_modules/ember-cli/lib/tasks/server/middleware/broccoli-watcher/index.js:54:11)
at watcher.then (/Users/<Redacted>/Projets/mweb/node_modules/broccoli-middleware/lib/watcher-middleware.js:35:7)
at tryCatch (/Users/<Redacted>/Projets/mweb/node_modules/rsvp/dist/lib/rsvp/-internal.js:215:12)
at invokeCallback (/Users/<Redacted>/Projets/mweb/node_modules/rsvp/dist/lib/rsvp/-internal.js:230:13)
at /Users/<Redacted>/Projets/mweb/node_modules/rsvp/dist/lib/rsvp/then.js:29:16
at flush (/Users/<Redacted>/Projets/mweb/node_modules/rsvp/dist/lib/rsvp/asap.js:85:5)
at _combinedTickCallback (internal/process/next_tick.js:73:7)
at process._tickDomainCallback (internal/process/next_tick.js:128:9)
Update
By looking at the code it’s pretty clear when this would happen (this.fastboot
being false
here resulting in undefined(req, resp, next)
here), I’m just not sure what the scenario is in which that could be the case.
I’m not sure if something like this would make sense?
if (!this.fastboot || !this.fastbootMiddleware) {
// TODO(future): make this configurable for allowing apps to pass sandboxGlobals
// and custom sandbox class
this.ui.writeLine(chalk.green('App is being served by FastBoot'));
this.fastboot = new FastBoot({
distPath: outputPath
});
this.fastbootMiddleware = FastBootExpressMiddleware({
fastboot: this.fastboot
});
}
this.fastbootMiddleware(req, resp, next);
Issue Analytics
- State:
- Created 6 years ago
- Comments:5 (5 by maintainers)
Top Results From Across the Web
getURL is not a function · Issue #210 · ember-fastboot ... - GitHub
Hi I am trying to run fastboot 1.0.0-beta.3 for the first time but I can't get any URLs to load. They all result...
Read more >fastboot-express-middleware - npm
An Express middleware for rendering Ember apps with FastBoot. Latest version: 3.3.2, last published: 6 months ago.
Read more >TypeError: middleware is not a function - Stack Overflow
When you use the function applyMiddleware , the middlewares shouldn't be called as functions. So instead of:.
Read more >Shoebox - Ember FastBoot
Now that this middleware is parsing the body of request, you can access it on the fastboot service. Depending on what method on...
Read more >Secrets of the Ember-CLI server: Express middleware with ...
But did you know this server isn't limited to serving Ember app assets? ... The function passed to get() is called a “middleware...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Cool, I’ll revert and release today
I was able to reproduce the error. I added some logging to https://github.com/ember-fastboot/ember-cli-fastboot/blob/master/index.js#L243:
When the error occurs,
this.fastboot
is defined so that theif
block is not entered butfastbootMiddleware
isundefined
. Thus, reverting #427 would actually fix this bug.