bitspook / channikhabra-hot-loader

Meteor package for assisting hot push code into your meteor app
2 stars 0 forks source link

Can't get it to work #1

Open neoromantic opened 9 years ago

neoromantic commented 9 years ago

So, I've installed this module as readme says it to. It runs some daemon on :3333. When I open localhost:3333 in browser I get code in raw text:

(function () { var baseUrl = 'http://localhost:3333'; var socketScriptsrc = baseUrl + '/public/socket.io-1.3.5.js'; var socketScript = document.createElement('script'); socketScript.src = socketScriptsrc; document.head.appendChild(socketScript);

var socketInterval = setInterval(function() { if (typeof window.io === 'undefined') return;

clearInterval(socketInterval);
putSocketsToWork();

}, 100);

function putSocketsToWork() { var socket = io(baseUrl); checkForLiveUpdate();

socket.on("push code", function(doc) {
  if (! checkForLiveUpdate())
    return;

  console.warn("Hot Pushing file", doc.filepath);
  var LiveUpdate = window.LiveUpdate;

  var filepath = doc.filepath,
      filetype = doc.filetype,
      content = doc.content,
      oldContent = doc.oldContent,
      dontEval = doc.dontEval,
      prePush = doc.prePush;

  if (!filetype || !content) {
    console.error('Invalid doc for Dispatching to LiveUpdate');
    return;
  }

  if (dontEval) {
    if (prePush) {
      return;
    }

    console.warn("First time pushing file, has to reload. It'll be hot-pushed for any further changes");
    LiveUpdate.forceRefreshPage();
    return;
  }

  console.warn("Hot pushing ", filepath);
  LiveUpdate.refreshFile({
    fileType: filetype,
    newContent: content,
    oldContent: oldContent
  });

});

}

function checkForLiveUpdate() { if (typeof window.LiveUpdate === 'undefined') { console.warn("You don't have LiveUpdate installed. Please install it with meteor add nucleuside:live-update for hot-push"); return false; } return true; }

}());

Nothing else happens.

neoromantic commented 9 years ago

I've started meteor alongside (as I understand that's what I should do, right?)

I got "A CLIENT CONNECTED" message in meteor-hot-reload console output.

Then, after I modified my code a little bit, it crashed like that:

SyntaxError: Unexpected end of input at Object.parse (native) at parse (/Users/neoromantic/.nvm/versions/node/v0.12.3/lib/node_modules/meteor-hot-loader/node_modules/body-parser/lib/types/json.js:84:17) at /Users/neoromantic/.nvm/versions/node/v0.12.3/lib/node_modules/meteor-hot-loader/node_modules/body-parser/lib/read.js:102:18 at done (/Users/neoromantic/.nvm/versions/node/v0.12.3/lib/node_modules/meteor-hot-loader/node_modules/body-parser/node_modules/raw-body/index.js:250:14) at IncomingMessage.onEnd (/Users/neoromantic/.nvm/versions/node/v0.12.3/lib/node_modules/meteor-hot-loader/node_modules/body-parser/node_modules/raw-body/index.js:296:7) at IncomingMessage.g (events.js:199:16) at IncomingMessage.emit (events.js:104:17) at _stream_readable.js:908:16 at process._tickCallback (node.js:355:11) Hot push failed socket hang up

bitspook commented 9 years ago

Hey,

Yea you don't need to open that *:3333 domain. I think I shouldn't show that message.

Thanks for trying it out. I am looking into that bug. Apparently it's occurring with marketplace example app too.

bitspook commented 9 years ago

Hey Sergey,

I've fixed that bug. Please give it a shot again.

Moral of the story is, always use Buffer.byteLength(dataString) when setting Content-Length header. I was using dataString.length. Stupid me.

I've also removed the silly message which gave the indication that user might need to do something on localhost:3333.