Meteor: The Loop of Death - meteor

I have noticed something really embarrassing with Meteor. When an error occurs inside a method on the server, this makes the entire code of the method to be rerun. This can lead to some unexpected results and some kind of trouble. For instance:
Meteor.methods
'someMethod': ->
# we insert an element in the database
Collection.insert({ record: "We want this record to be inserted only once." })
# We just made a mistake here, let's say that the object is not defined.
variable = object.property
return variable
What happened in my case is that Meteor throws an error saying that it cannot read the property of undefined (I can see it within the server logs) and then rerun the code of the method repeatedly throwing the same error again. I can see a lot of records inserted on my database when it should have one.
I don't know if there is a way to ask meteor to not rerun the code when an error occurs or some kind of thinking I need to learn while developing an application with it.

Related

Using a date-time-picker in react and meteorjs

I am trying to place a date time picker in my form. However, I get an error that says Invariant Violation, Target is not in the DOM. I am very new to javascript as well as meteor and react. What does this error mean and how can I fix it?
Here is the code: https://gist.github.com/drwofle21/8cffed99312711ddfb3f
As the comment on the Gist said "document.getElementsByClassName("calendar") Will return an array, not single node."
That array contains a list of nodes that you can loop through. Best thing to do is console log it out and see what it's actually returning and how you can best handle it.

Creating many batches (SysOperation Framework) very quickly doing similar processes - "Cannot edit a record in LastValue (SysLastValue)"?

I have a SysOperation Framework process that creates a ReliableAsynchronous batch to post packing slips and several get created at a time.
Depending on how quickly I click to create them, I get:
Cannot edit a record in LastValue (SysLastValue).
An update conflict occurred due to another user process deleting the record or changing one or more fields in the record.
And
Cannot create a record in LastValue (SysLastValue). User ID: t edit a, Class.
The record already exists.
On a couple of them in the BatchHistory. I have this.parmLoadFromSysLastValue(false); set. I'm not sure how to prevent writing to SysLastValue table.
Any idea what could be going on?
I get this exception a lot too, so I've created the habit of catching DuplicateKeyException in my service operation. When it is thrown, catch it and retry (for a default of 5x).
The error occurs when a lot of processes run simultaneously, like you are doing now.
DupplicateKeyException can be caught inside a transaction so you could improve by putting a try/catch around the code that does the insert in the SysLastValue table if you can find the code.
As far as I can see these are the only to occurrences where a record is inserted in this table (except maybe in kernel):
InventUnusedDimCleanUp.serialize()
SysAutoSemaphore.autoSemaphore()
Put a breakpoint there and see if that code is executed. If so you can add a try/catch with retry and see if that "fixes" it.
You could also use the tracing cockpit and the trace parser to figure out where that record is inserted if it's not one of those two.
My theory about LoadFromSysLastValue: I believe setting this.parmLoadFromSysLastValue(false) does not work since it is only taken into account when the dialog is started, not when your operation is executed. When in batch, no SysLastValue will be used to initialize your data contract as you want it to use the exact parameters you have supplied in your data contract .
It's because of the code calling SysOperationController.savelast() while in batch, my solution is to set loadFromSysLastValue to false in SysOperationController.loadFromSysLastValue() as part of the in batch check:
if (!this.isInBatch())
{
.....
}
//Begin
else
{
loadFromSysLastValue = false;
}
//End

QtSQL: "prepared statement "qpsqlpstmt_1" does not exist" on clear() of model

I am getting the following error message printed in the console:
Unable to free statement: ERROR: prepared statement "qpsqlpstmt_1" does not exist
It is printed when the the following function is called in the application (or when the object is deleted (if clear() is not called before delete):
sqlQueryModel->clear();
sqlQueryModel object is of type QSqlQueryModel and is used throughout a derived class to communicated with a PostgreSQL database. It also serves as a model for QCompleter. I have never declared or used the name "qpsqlpstmt_1".
Could someone help me interpret the error message please, and explain what might be causing it? Is this indicative of a problem in my code or a Qt bug? (likely the former :))
On reviewing the PostgreSQL log file on the server, the exact same statement appears plus an additional line:
STATEMENT: DEALLOCATE pqsqlpstmt_1
See these Qt issue tracker entries:
https://bugreports.qt.io/browse/QTBUG-8860
https://bugreports.qt.io/browse/QTBUG-16007
https://bugreports.qt.io/browse/QTBUG-15979
... all of which mention your prepared statement name and relate to deletion.
After a considerable amount of time, I realized that I was simply closing the connection to the database before calling clear... not a good strategy.

Flex Error #1009: Cannot access a property or method of a null object reference

I'm getting error while running a game I created with flex.
I know there has been some question about this, but my case is quite weird. I created a simple typing game that is running OK on my computer, but when I tried to deploy it online to facebook, I got those errors. I used code from the tutorial from adobe here http://www.adobe.com/devnet/facebook/articles/flex_fbgraph_pt4.html to deploy my flex game to facebook
This is the error message:
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at FacebookUserStatusWeb/init()
at FacebookUserStatusWeb/___FacebookUserStatusWeb_Application1_creationComplete()
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at mx.core::UIComponent/dispatchEvent()
at mx.core::UIComponent/set initialized()
at mx.managers::LayoutManager/doPhasedInstantiation()
at mx.managers::LayoutManager/doPhasedInstantiationCallback()
And here is snippet of the init() function:
protected var text1:String="Text to be typed"; //hard-coded temporarily
protected const TIMER_INTERVAL:int = 10;
protected var t:Timer = new Timer(TIMER_INTERVAL);
protected var topURL:String=ExternalInterface.call('top.location.toString');
protected function init():void
{
t.addEventListener(TimerEvent.TIMER, updateTimer);
ProblemText.text = new String(text1);
Facebook.init("<my app id>",loginHandler);
currentState = (topURL) ? "loggedout": "loggedoutonfacebook";
}
Some notes:
1.my app id is my facebook app id which I prefer not to show
2.ProblemText is a richtext which I placed the paragraph to be typed by the player.
3.I have deleted the method Application1_creationComplete() but it still appears at the error listing
And also I am curious about the errors other than the first two. What do they mean?
Ah, and if it is helpful, I can post some more of the code
First: You're only seeing one error. Everything you see below the #1009 error is your stack trace, not additional errors.
The stack trace basically tells you the series of things that happened prior to the error occurring, with the most recent at the top. This is useful because often things which happen prior to the actual error you see will contribute to said error.
Second: The null object reference is occurring because something in your init() function tried to access a property in an object that doesn't exist, or an object that doesn't exist. One (slightly messy but effective) way to debug this would be to drop some trace statements in the code to see how far it gets before barfing with the error -- the idea being to isolate the specific line that's causing the problem. Once you've done that, you need to work backwards to figure out why the object or property you're trying to use is null. It could be something simple, like a typo, or it could be more complex. You'll have to sleuth it out, one way or another =)
Good luck!
Finally got the bug. Just in case people have the same case with me, what exactly happened is at my computer I simulated the game with just one state, but when I'm deploying to facebook I have several states (loggedin,loggedout,etc). In the init() I tried to access ProblemText Label that is not present in the current state.

ASP.NET Cannot evaluate expression because a thread is stopped at a point where garbage collection is impossible

I have a weird problem, I get an object from my DB, like this:
var user = BLL.Managers.Users.UserTmpManager.GetUser((int)customerID);
when I debug that code, and expand the user object, for each property I see the error as I mentioned at this topic's title. What causes it ?
unfortunately, it is still not being resolved, as I thought at the beginning..
I got this too, when I hit a NullReferenceException from a 3rd party control.
In this one case, I found that if I set a breakpoint before I hit the exception, I could then single step through the rest of the code without seeing the problem.
No idea why, but this worked for me - in this case at least.

Resources