Closed MilosStanic closed 8 years ago
Hm, can you make a small reproduction instead? Not the whole app code? So that we find where exactly is the problem? Without many dependencies?
So you call logout
on the client and server crashes?
yes, I call logout on the client, and server crashes. I don't know how to reduce the app, but I can really point out the critical parts, here's how the code is called:
angular.module('chatapp').config(
function ($urlRouterProvider, $stateProvider, $locationProvider) {
//main routes of the application
$locationProvider.html5Mode(true);
$stateProvider
.state('home', {
url: '/',
templateUrl: 'client/chat/views/chat-main.ng.html',
controller: 'MainChatCtrl',
controllerAs: 'mcc'
})
.state('logout', {
url: '/logout',
resolve: {
"logout": ['$meteor', '$state', function($meteor, $state) {
return $meteor.logout().then(function(){
$state.go('home');
}, function(err){
console.log('logout error - ', err);
});
}]
}
});
$urlRouterProvider.otherwise("/");
});
This is a front-end AngularJS router. located in the /client folder. I don't know how much you know AngularJS, but the code is selfexplanatory. Nothing to explain, actually.
You can see in the logout route, where it calls $meteor.logout
This code is activated by a press of a button in browser page. Really nothing to it, and nothing in between.
Are you sure this has anything with this package? I am more interested in your server-side code.
So the code where you use autorun
on the server.
Here it is, server code, nothing to do with logging out :
/**
* Called upon a client connection, insert the user
*/
Streamy.onConnect(function(socket) {
Tracker.autorun(function() {
var uid = Streamy.userId(socket); // uid will be null if the user is not logged in, otherwise, it will take the userId value
if(uid) {
console.log("New userId state for", Streamy.id(socket), uid);
Clients.update({ uid: uid },
{ $set: { sid: Streamy.id(socket)}},
{ upsert: true});
}
});
});
When I remove server-autorun, here is the error message I get:
I20151123-22:53:56.563(1)? Exception from Tracker recompute function:
I20151123-22:53:56.564(1)? Error: Meteor code must always run within a Fiber. Try wrapping callbacks that you pass to non-Meteor libraries with Meteor.bindEnvironment.
I20151123-22:53:56.564(1)? at Object.Meteor._nodeCodeMustBeInFiber (packages/meteor/dynamics_nodejs.js:9:1)
I20151123-22:53:56.564(1)? at [object Object]._.extend.get (packages/meteor/dynamics_nodejs.js:21:1)
I20151123-22:53:56.564(1)? at Object.DDP.randomStream (packages/ddp-client/random_stream.js:5:1)
I20151123-22:53:56.564(1)? at [object Object].self._makeNewID (packages/mongo/collection.js:75:1)
I20151123-22:53:56.564(1)? at [object Object].Mongo.Collection.(anonymous function) [as update] (packages/mongo/collection.js:522:1)
I20151123-22:53:56.564(1)? at server/chatserver.js:21:1
I20151123-22:53:56.565(1)? at packages/tracker/tracker.js:99:1
I20151123-22:53:56.565(1)? at Object.Meteor._noYieldsAllowed (packages/meteor/fiber_helpers.js:11:1)
I20151123-22:53:56.565(1)? at packages/tracker/tracker.js:98:1
I20151123-22:53:56.565(1)? at [object Object].Tracker.Computation._compute (packages/tracker/tracker.js:323:1)
I20151123-22:53:56.728(1)? removed socket vzyyjyGcwrjhh9qnz
I20151123-22:53:59.183(1)? removed socket eyZbzRQaF6zzJTEDi
I20151123-22:54:06.100(1)? New userId state for ZdB36GM5k7p4hABo2 2f3sdZopwgR6Hnyh5
I20151123-22:54:06.101(1)? [Error: Can't call yield in a noYieldsAllowed block!]
I20151123-22:54:06.105(1)? Exception from Tracker recompute function:
I20151123-22:54:06.105(1)? Error: Meteor code must always run within a Fiber. Try wrapping callbacks that you pass to non-Meteor libraries with Meteor.bindEnvironment.
I20151123-22:54:06.105(1)? at Object.Meteor._nodeCodeMustBeInFiber (packages/meteor/dynamics_nodejs.js:9:1)
I20151123-22:54:06.106(1)? at [object Object]._.extend.get (packages/meteor/dynamics_nodejs.js:21:1)
I20151123-22:54:06.106(1)? at Object.DDP.randomStream (packages/ddp-client/random_stream.js:5:1)
I20151123-22:54:06.106(1)? at [object Object].self._makeNewID (packages/mongo/collection.js:75:1)
I20151123-22:54:06.107(1)? at [object Object].Mongo.Collection.(anonymous function) [as update] (packages/mongo/collection.js:522:1)
I20151123-22:54:06.107(1)? at server/chatserver.js:21:1
I20151123-22:54:06.107(1)? at packages/tracker/tracker.js:99:1
I20151123-22:54:06.107(1)? at Object.Meteor._noYieldsAllowed (packages/meteor/fiber_helpers.js:11:1)
I20151123-22:54:06.107(1)? at packages/tracker/tracker.js:98:1
I20151123-22:54:06.108(1)? at [object Object].Tracker.Computation._compute (packages/tracker/tracker.js:323:1)
but now Logout works normally.
line 21 in chatserver.js, mentioned in the error message, is the line in the previous message quoted code where I call Clients.update
What is Streamy.onConnect
?
So yea, please make a small reproduction and show the whole code. This back and forth will not get us far.
As I said in my opening post, it's part of yuukan:streamy
library, it fires when a websockets connection is open between a client and a server.
ok, will make a small reproduction... as small as I can. Thanks a lot for your effort.
Hello, here, I made a working minimal demo: https://github.com/MilosStanic/angular-meteor-chat-demo
just clone, and run meteor. Open in two browsers, register one user in each browser (with dummy emails), and then under the input box you'll see a button with other user email, click on it, and you can send chat message to the other user.
As things are right now, when you logout, server crashes. If you remove server-autorun, server doesn't crash when you logout.
Thanks a lot. I hope we'll get this fixed ;)
Fixed with 0.5.2. Thanks for reporting.
Thanks for fixing it so fast. Cheers!
Hi guys, thanks for the beautiful work. Makes my life easy using yuukan:streamy serverside.
I'm making an app using angular-meteor. So when calling
$meteor.logout()
which is an async wrapper for Meteor's logout function -- the server crashes.The crash message:
Thanks again for your wonderful work. Is there anything that can be done to fix this? I can share full app code if you want to see how it behaves for yourself. This server crashing is a real deal breaker. And I have no option but to use meteor-server-autorun, while on the other hand server crashes on user logouts, which is unacceptable.
Note: all packages, including Meteor are at their latest versions.