dreamfactorysoftware / dreamfactory

DreamFactory API Management Platform
https://www.dreamfactory.com
Apache License 2.0
1.55k stars 314 forks source link

`let` in JavaScript makes scripts fail #141

Closed schoel-bis closed 7 years ago

schoel-bis commented 7 years ago

If a V8js or Node.js event script contains the keyword let it will fail.

To reproduce, add a script (I am using files.{folder_path}.post.post_process), make it V8js or Node.js, type in let x = 0; or similar, activate, and hit the endpoint. It will fail with an error message (which will vary depending on what type of script you selected before).

Changing let to var or const makes the error disappear.

Testet with DSP 2.4.1 and 2.5.0.

geovanisouza92 commented 7 years ago

@schoel-bis Which v8js version you're using?

schoel-bis commented 7 years ago

The one that came with Bitnami's distribution of DF 2.4 and 2.5. 2.4.1 apparently came with V8 4.6.76 which is roughly equivalent to Chrome 46. According to MDN (https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/let) let was supported in Chrome since 41. All my scripts use strict mode.

todda48 commented 7 years ago

I was able to run this code as a V8js script on DF 2.7.0 (Bitnami). Can you try that version?

function test() {
    "use strict";

    let x=1234;
    var_dump(x);
}

test();

php -i shows

V8 Javascript Engine => enabled
V8 Engine Compiled Version => 4.9.99
V8 Engine Linked Version => 4.9.99
schoel-bis commented 7 years ago

I can confirm it works in 2.7.