Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Startup Code Never Runs on Server #2239

aldeed opened this issue Jun 18, 2014 · 1 comment

Startup Code Never Runs on Server #2239

aldeed opened this issue Jun 18, 2014 · 1 comment


Copy link

aldeed commented Jun 18, 2014

NOTE: Since I got no replies posting this to meteor-core and because it seems like a bug, I'm submitting it here.

I always thought that passing a function to Meteor.startup meant that it would be executed on startup, but if already started, it would be executed immediately. Recently some things weren't working for me, and I discovered that the way I thought it works is correct on the client but incorrect on the server. On the server, if you call Meteor.startup and startup is already complete, the function is never called.

Here's a repo that shows this:

I tried with several older releases, and it seems as though it has always been this way.

(1) Is the difference between client and server behavior intentional?
(2) If yes, can this aspect be clarified in the docs?

My particular issue was with code in a package which could potentially run before or after startup, but if run before, then I wanted to wait until after startup was done. I worked around this issue with something like this:

if (Meteor.isServer) {
  // A function passed to Meteor.startup is only run on the server if
  // the process has not yet started up. So we need a flag to tell
  // us whether to wrap in Meteor.startup or not
  var hasStartedUp = false;
  Meteor.startup(function () {
    hasStartedUp = true;

  function otherFunctionThatMightRunBeforeOrAfter() {
    function stuffToDoNowOrOnStartup() {
      // etc..

    if (hasStartedUp) {
    } else {
Copy link

glasser commented Jun 19, 2014

Thanks, good catch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
None yet

No branches or pull requests

2 participants