Sign In Register

How can we help you today?

Start a new topic

Script data on challenge start not set


I am setting some initial data in CloudCode ChallengeStartedMessage. Some of the data is constant and some is generated by function defined in a separate module: 

// CustomModule
function getQueuedTiles() {
    var tileValues = [0, 0, 0, 0, 1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 6, 6];
    var numTiles = tileValues.length;
    var result = [];
    for( var i = 0; i < 30; i++ ) {
        var index = Math.floor( Math.random() * numTiles );
        result[i] = tileValues[index];
    return result;


// ChallengeStartedMessage

require( "CustomModule" );

var challenge = Spark.getChallenge( Spark.getData().challenge.challengeId );

challenge.setScriptData( "someConstantData", "data" );

// CustomModule function
var queuedTiles = getQueuedTiles();
challenge.setScriptData( "queuedTiles", queuedTiles );


The problem I am encountering is that the data from the module's function is sometimes (?) not being set and the players receive the ChallengeStartedMessage without it (while "someConstantData" is always set). Note I am only encountering this when accepting challenge using SDK (ActionScript). When accepting challenge using Test Harness then the generated data seems to be set every time.

Any idea on why is this happening?


I have very similar problem in my ChallengeStartedMessage hook. Creating challenge from SDK cause an error, but in Test Harness all is fine. Look into your scipt.log with NoSQL explorer - do you have any errors like this?

"log": {
  "error": "Long running script, terminating",
  "script": "ChallengeStartedMessage",
  "stackTrace": "\tat 288003-message-ChallengeStartedMessage:14\n"

To show newest entries paste {ts: -1} in Sort textfield.

It seems like this problem started with latest platform update 18.09.2015.

Hmm, yes, I have quite a few of these errors.

I noticed your post about this issue. Are you having this problem even without calling any method from a module? Which line in your script does the error point to?

The most frequently it points to the lines with these commands: 

creatorObj.getScriptData("avatar") || "";
challenge.setScriptData("player1Score", playerOneScore);

I think that it is related to commands that get or set data from/to the database.

And, like you, i can't reproduce this error with Test Harness. I'm using JS SDK in my project.

Have you tried submitting a support ticket? Your post has been left unanswered for several days and since it seems like an issue with GS rather than our own mistake, it might be better to file a ticket instead of waiting on forum for an answer.

Of cause, i submitted a support ticket a day ago, because this error happens on our LIVE server. For now we haven't found the cause of error. And yes, i believe that this is GS issue, not ours.

Thank you anyway!

Login to post a comment