I have a meteor application that starts to be quite large. I have still quite important problems to debug my application for exemple I have a error :
Uncaught TypeError: Cannot read property 'nodeType' of null domutils.js?52c3c7ff9e0acd52ac427a8f103760e222ba2722:295
Uncaught TypeError: Cannot read property '_spark_bY6hxpJRdJcb2nynQ' of null
I cannot find the source of the error.
I was having the same problem. For me it occurred when I clicked a link which caused a new template to load. When I added:
event.stopImmediatePropagation();
as shown below, the error was corrected.
Template.define_blocks.events({
'click #tb_yes': function(event) {
event.preventDefault();
event.stopImmediatePropagation();
});
Related
I am not sure if I am just doing something wrong or if this is actually not working. I want to display the original publication error on the client, in case I catched one:
Meteor.publish('somePub', function (args) {
const self = this
try {
// ... publication logic
catch (pubErr) {
self.error(pubErr)
}
})
On the client I am "catching" this error via the onStop callback:
Meteor.subscribe('somePub', args, {
onStop: function (e) {
// display e to user
}
})
However, while on the server the pubErr is a Meteor.Error and according to the documentation it should be sent to the client, the client just receives a generic sanitized error message:
on the server
{
stack: "useful stack of actual method calls",
error: "somePub.failed",
reason: "somePub.invalidArguments",
details: { arg: undefined }
}
on the client
{
stack: "long list of ddp-message calls",
isClientSafe: true,
error: 500,
reason: "Internal server error",
details: undefined,
message: "Internal server error [500]",
errorType: "Meteor.Error"
}
Note: I also tried to add the error to itself as sanitizedError field, as in the documentation mentioned, but no success either.
Am I missing something here?
Actually I found the answer to the issue after being pointed into the right direction.
The example code works fine on a new project, so I checked why not in my project and I found, that I did not surround the arguments validation using SimpleSchema by the try/catch (unfortunately my question was poorly designed as it missed this important fact, mainly because I abstracted away the schema validation from the publication creation):
Meteor.publish('somePub', function (args) {
pubSchema.validate(args) // throws on fail
const self = this
try {
// ... publication logic
catch (pubErr) {
self.error(pubErr)
}
})
So I thought this could not be the issue's source but here is the thing: Simple Schema is not a pure Meteor package but a NPM package and won't throw a Meteor.Error but a custom instance of Error, that actually has the same attributes (error, errorType, details) like a Meteor.Error, see this part of the source code of a validation context.
So in order to pass the correct information of a SimpleSchema validation error to the client you should
wrap it in a try/catch
add the isClientSafe flag to it
alternatively convert it to a Meteor.Error
Attach a custom Meteor.Error as sanitizedError property to it
Since upgrading to meteor 1.8.0.2 from 1.6.x I've noticed that any method call that results in an error is printed on the server console as:
Exception while invoking method 'login' [object Object]
Exception while invoking method 'customMethodByMe' [object Object]
This happens both on development on my mac and deployed on Galaxy.
Before, the whole stack trace was printed, but this Object object logging doesnt help me figure out the actual problem. My solution so far has been to wrap method implementation in a try catch statement that logs the original exception and rethrows it for the client to know.
Meteor.methods({
'customMethodByMe'() {
try {
return customMethodByMeImpl();
} catch (e) {
console.log(e)
throw e;
}
}
});
In this case, since the error is on the login method which is in a package, I cannot update it to print the real problem. On the client, all I get on any error is that there was a 500 error on the server, so no root cause either.
{"isClientSafe":true,"error":500,"reason":"Internal server error","message":"Internal server error [500]","errorType":"Meteor.Error"}
Any ideas on how to temporarly solve this? I've been searching for a server level error handler but so far have found nothing.
thanks
I did not get to experience this directly, but when I need to print an object, I usually use JSON.stringfy.
Meteor.methods({
'customMethodByMe'() {
try {
return customMethodByMeImpl();
} catch (e) {
console.log(JSON.stringify(e));
throw e;
}
}
});
This should resolve so that you can at least read the error log.
This is curious.
I created a hook to update some data of related collections after an update. The code is like this:
#Votes.after.insert (userId, doc) ->
person = People.findOne name: doc.candidate
person.votes += 1
When I insert a new Vote everything works fine: the hook is called and the votes are updated just fine. However I got this on the server log:
Exception while invoking method '/votes/insert' TypeError: Object [object Object] has no method 'findOne'
and this on the console of the browser:
errorClass {error: 500, reason: "Internal server error", details: undefined, message: "Internal server error [500]", errorType: "Meteor.Error"}
I didn't understand why I got those errors if everything worked fine.
I have seen a strange exception in the onData() function of a Route Controller in iron-router. The exception only seems to occur after I make a change to a file which of course causes meteor to restart the app. I've put up a sample in github that demonstrates the problem here: https://github.com/benmonro/iron-router-bug
If you add a person by clicking submit, then click on that person's name, everything will load fine. However, if you then make a change to some js (say add a comment). Meteor will reload and you'll get the exception in the 'onData()' method which is attempting to use a property of the data returned from the 'data()' function.
The exception is here:
> Exception in defer callback: TypeError: Cannot read property 'name' of
> undefined
> at RouteController.extend.onData (http://localhost:3000/irDataBug.js?8327f0bf1bedee2437ec14bc4509d8f7e85079ab:33:19)
> at RouteController.runHooks (http://localhost:3000/packages/iron-router.js?e9fac8016598ea034d4f30de5f0d356a9a24b6c5:827:16)
> at http://localhost:3000/packages/iron-router.js?e9fac8016598ea034d4f30de5f0d356a9a24b6c5:2137:16
> at Utils.extend._run.withNoStopsAllowed (http://localhost:3000/packages/iron-router.js?e9fac8016598ea034d4f30de5f0d356a9a24b6c5:2098:21)
> at _assign._compute (http://localhost:3000/packages/deps.js?4a82362ae66e863a1c1a8b0a5fec6f665e2038d1:228:38)
> at new Deps.Computation (http://localhost:3000/packages/deps.js?4a82362ae66e863a1c1a8b0a5fec6f665e2038d1:160:10)
> at Object._assign.autorun (http://localhost:3000/packages/deps.js?4a82362ae66e863a1c1a8b0a5fec6f665e2038d1:380:13)
> at http://localhost:3000/packages/iron-router.js?e9fac8016598ea034d4f30de5f0d356a9a24b6c5:2134:12
> at Utils.extend._run.withNoStopsAllowed (http://localhost:3000/packages/iron-router.js?e9fac8016598ea034d4f30de5f0d356a9a24b6c5:2098:21)
> at _assign._compute (http://localhost:3000/packages/deps.js?4a82362ae66e863a1c1a8b0a5fec6f665e2038d1:228:38)
The data isn't ready after the reload so you need to add a guard or an early return to the callback. Here's a simple fix:
onData: function() {
var thePerson = Router.current().data();
if (!thePerson)
return;
if (thePerson.name === "Fred") {
console.log("it's fred");
} else {
console.log("it's not fred");
}
}
Because the callback is reactive, it will rerun once thePerson is found. Alternative solutions could involve a waitOn callback and then checking for this.ready().
I'm trying to get have users be able to post to their Facebook walls on my external site.
I've encountered a problem in Safari. If the user isn't logged in, i.e. they have not gone through the flow that calls FB.login(), I get the following JS error when calling FB.ui():
TypeError: 'undefined' is not an object (evaluating 'b.fbCallID=a.id')
However, if they are logged in, the dialog appears just fine.
FB.ui() is called in a callback function -- I'm retrieving a unique url from my server, and then calling FB.ui(). If I call FB.ui() directly, it works fine, but not when it's asynchronous.
Here's the code:
retrieveUrl(param1, param2, function(result) {
FB.ui({ method: 'feed',
description: 'My Description',
display: 'dialog',
link: result.uniqueUrl,
picture: 'http://foo.com/bar.jpg'
}, function(response) {
if (response && response.post_id) {
//Posted message
} else {
//Not posted message
}
});
});
This works in other browsers, regardless of logged in state or not.
FB.login or FB.ui methods must be called on a user initiated action (click) in Safari for new window/popup/iframe to be rendered by FB.UIServer.
If you try calling these methods on a network callback event it will be blocked and the exception you described will occur:
TypeError: 'undefined' is not an object (evaluating 'b.fbCallID=a.id')
Can you retrieve the unique URL before the user interacts with the page and then present the feed dialog when they click on a button?