question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

"fastbootMiddleware is not a function"

See original GitHub issue

We’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:closed
  • Created 6 years ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
kratiahujacommented, Aug 10, 2017

Cool, I’ll revert and release today

0reactions
marcoowcommented, Aug 10, 2017

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:

console.log('debug', this.fastboot, fastbootMiddleware);
if (!this.fastboot) {
  …

When the error occurs, this.fastboot is defined so that the if block is not entered but fastbootMiddleware is undefined. Thus, reverting #427 would actually fix this bug.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found