1.3 beta 11: Commenting out import of an unused, undefined variable causes my app to crash

So I’m at a loss as to what to do next. I’m using Meteor 1.3 beta 11, attempting to refactor an app to modules and Mantra.

In client/modules/authentication/index.js I had the following code:

const authState = {
  passwordResetToken: null,
  emailVerifyToken: null,
  authDoneCallback: null

export {authState}

And I used this to store tokens for password reset/email verification. There was a point where client/modules/core/components/home.jsx imported authState and used it to determine whether to show my main homepage or the password reset component. I’ve since eliminated that dependency, moved that check into client/modules/authentication/router.jsx and have generally made things nicer. I then removed authState from client/modules/authentication/index.js and instead placed the following in client/modules/authentication/state.js:

export default {
  passwordResetToken: null,
  emailVerifyToken: null,
  authDoneCallback: null

I then set about importing state.js from various components/containers in my authentication module, then removing the authState import (and, again, authState no longer exists anywhere in my source.)

I have the following in client/modules/authentication/containers/reset_password.js. Please excuse the mess, I’m separating out code into actions:

import {useDeps, composeWithTracker, composeAll} from "mantra-core"

import {authState} from "../"
import ResetPassword from "../components/reset_password.jsx"

const composer = ({context}, onData) => {
  const {Accounts, Meteor} = context()
  onData(null, {
    onSubmit: (token, password) => new Promise((resolve, reject) => {
      Accounts.resetPassword(token, password, (err) => {

export default composeAll(

Now, here’s the crazy bit. If I comment out:

import {authState} from "../"

my app fails to render with the following:

Error: Curry function of composeAll needs an input.

Apparently this means react-komposer is getting an undefined component. I get that. But why would that error appear if I comment out an import for a variable that is no longer defined, but go away if I uncomment the import? I’ve grepped through my entire source tree and authState is never ever mentioned except for in this single import. Why would commenting it out cause the above error and my app to not render?

I’ve tried this with 1.3 beta 11 and a checkout of the release-1.3 branch as of this morning. Same results. I’ve created a minimal app with just my authentication module. Unfortunately I don’t see the error. I’ve tried commenting out and removing unrelated modules, but I can’t find a distinct point where cutting out modules and returning them causes the error to appear. When I do add back a module and cause the error, I’ve tried stripping that module down to the bare minimum and adding in bits one-by-one. Enlightenment never comes. I guess I could add back components line-by-line but I have no guarantee that this will do anything but waste my time, and I’ve already spent hours doing just that with no luck. :confused:

I tried using --production In that instance I get the above error and:

detailed error: TypeError: Package['service-configuration'] is undefined

I don’t doubt there’s an error in my code somewhere. But why don’t I get that error? I’d imagine that importing an undefined variable would cause an error, so to my mind I’ve removed a source of problems, and it is that removal which causes the problem. Why does the success or failure of my code hinge on whether or not the import of an undefined variable that is never used is present? I’ve even changed authState to authStat with the exact same results.

Thoughts on how to debug this? I’ve filed this issue. Unfortunately I’m at a loss since I can’t create a reproduction smaller than my app, which unfortunately isn’t something I can make public. This feels like it has to be a module error, but unfortunately I’m not smart enough to dig through Meteor and figure out how this is failing. I did create a zip of my app with secrets/local provisioning stripped out which I could provide to anyone with the knowledge to potentially dive into and fix a Meteor modules bug if in fact this is one, but I don’t want to just post it everywhere for everyone.

Thanks for any help, I’ve been dealing with this issue for days and it’s driving me a bit crazy. :slight_smile:

OK, I swear I’m not on crack.

Commenting out the dreaded line whose tokens I will not type causes my Home component, the one that renders my app’s homepage, to be undefined at the point where it is constructed into a container. That at least would explain the composeAll failure even though it doesn’t get at underlying causes. I placed console.log calls around every composeAll call and saw the one for Home not completing. Even worse, I place a console.log call on top of home.jsx. Commenting out the infernal no-op import of doom somehow causes home.jsx not to import, thus causing Home to be undefined. I don’t understand how not importing an undefined variable that is never used anywhere can cause an unrelated file in a different module to never import when it is explicitly imported.

This has to be a subtle module bug. I’m sure my code has an error somewhere–maybe I’m not importing a module correctly–but Meteor needs to report that rather than uber-fail.

Taking a mental health break from this app until I get some responses. :slight_smile: I’ve been programming for nearly 30 years and this is probably one of the most (if not the most) baffling bugs I’ve ever encountered.

Thanks for any help.

Just to pre-empt the question, this issue is still unfortunately present in beta 12. Was hoping there might be a difference between beta 12 and the release-1.3 branch as of yesterday, but no luck. :frowning:

Updated the issue, but if anyone feels like taking a crack at the mystery, I created a reproduction: https://github.com/ndarilek/meteor-modules-mystery It’s possible that I made a stupid mistake since I’ve been trying to figure this one out for the past 4-5 days and am mentally fatigued, but if so then I’d expect Meteor to throw an error rather than just stop importing stuff. :slight_smile: It’s also possible that browsers other than Firefox and tools other than Firebug throw more useful errors. Unfortunately, as a blind web developer, Firefox and Firebug are the only real accessible tools I can use. Chrome’s dev tools were inaccessible when last I checked.