question

John Peterson avatar image
John Peterson asked

CloudScript revision has no functions.

(TitleID 44B1)

Dear PlayFab community,

I am using TypeScript and Visual Studio Code with which to develop CloudScript functions for use with PlayFab. I also have GitHub integration activated on my account.

I committed some changes (no errors in VS Code or during the tsc execution), and PlayFab correctly got the latest version.

However, I'm showing no functions are available to execute. :-(

When I search the Forums for this issue, I see the following link:

https://community.playfab.com/questions/7823/this-revision-has-no-functions.html

And there is a hint that maybe I have the "wrong code syntax" somewhere? However, I'm not showing any obvious signs of incorrect syntax.

My tsconfig.json has the following:

{
  "compilerOptions": {
    /* Basic Options */
    "target": "es6",                          /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', or 'ESNEXT'. */
    "module": "commonjs",                     /* Specify module code generation: 'none', commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */
    "strict": true                            /* Enable all strict type-checking options. */
  }
}

I should mention that I changed the "target" from "es5" to "es6" to take advantage of the .find() method on collections:

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/find

I'm almost positive I saw the .find() method in an earlier CloudScript example, so I just assumed that it is supported by PlayFab. Maybe this is a bad assumption?

If I try to set the "target" back to "es5" and compile, I will get the following errors:

InventoryManagement.ts(66,16): error TS2339: Property 'find' does not exist on type 'CatalogItem[]'.
InventoryManagement.ts(97,13): error TS2339: Property 'find' does not exist on type 'ItemInstance[]'.

How can I debug this issue to discover what's going on? There doesn't seem to be any information in the PlayStream at the time of upload, other than it was successful.

Thanks in advance for any help anyone can provide!

CloudScript
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

John Peterson avatar image
John Peterson answered

Just to follow-up:

I *was* able to load from the Editor Extensions! That way I didn't have to perturb my existing environment with GitHub. :-D

I loaded the following script, and it successfully executed the function on my behalf:

var TestFind = function (args, context) {
    var ages = [3, 10, 18, 20];
    var age = ages.find(function (age) { return (age >= 18); });
};
handlers["testFind"] = TestFind;

I'm guessing there must have been other aspects that threw off V8. When I look at my commit diff between compiling with es5 vs. es6, I see that some of my global "const" declarations in es6 were converted to "var". And also a function parameter default was not permitted with es5. I bet one of those are the culprit (most likely the default parameter).

[EDIT] I removed the default value for the function parameter, and it seems to be loading the functions successfully when compiling with "es6". Sorry for the false alarm on .find(), and thank you for the information regarding Google V8.

Here's a good link that has other links to show where V8 tracks in terms of JavaScript support.

1 comment
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

brendan avatar image brendan commented ·

Ah, excellent - thanks for the additional info!

0 Likes 0 ·
John Peterson avatar image
John Peterson answered

Well, poo: I changed my tsconfig.json to use a "es5" instead of an "es6" target, manually wrote a .find() function for the arrays, and it appears as if that worked successfully with PlayFab.

Does this mean PlayFab doesn't support "es6"? Because it's not that new:

https://en.wikipedia.org/wiki/ECMAScript

2 comments
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

brendan avatar image brendan commented ·

What we're running is specifically the latest V8 engine (https://github.com/v8/v8/wiki), so that seems odd. I'll open a bug to have the team look into this, as I'm not aware of any es6 specific issues in V8.

1 Like 1 ·
John Peterson avatar image John Peterson brendan commented ·

Frustratingly, it's kind of difficult to determine exactly what ECMA-262 specification that Google V8 is supporting. This V8 blog entry (from early last year) seems to suggest that they'd be on ES7 (and beyond) by now:

https://v8project.blogspot.com/2016/04/es6-es7-and-beyond.html

I will craft a sample test that uses .find() without any other trappings to see how CloudScript responds and follow-up with my results.

[EDIT] Shoot -- I see that I can't easily upload another CloudScript.js file through the Game Manager (once it's been established with GitHub). Maybe I can do it through the PlayFab Unity Editor Extensions?

0 Likes 0 ·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.