personium / personium-engine

Additional module for personium-core to enable server-side JavaScript execution.
Apache License 2.0
16 stars 7 forks source link

Engine returns timeout immediately #87

Open yoh1496 opened 5 years ago

yoh1496 commented 5 years ago

The code below is executed correctly.

function(request) {
  var Context = org.mozilla.javascript.Context,
  currentContext = Context.getCurrentContext,
  rhinoVersion = currentContext.getImplementationVersion;

  return personium.createResponse(200, rhinoVersion );
};

var _ = require("underscore")._;
var personium = require('personium').personium;
var console = require('console').console;

And the engine returns Timeout , but it doesn't take as long as a few seconds.

Is this correct ?

yoh1496 commented 5 years ago

All of exception thrown while executing are caught and treated as Timeout.

https://github.com/personium/personium-engine/blob/48822cae647c2497606af3693ee54edb65a524f7/src/main/java/io/personium/engine/PersoniumEngineContext.java#L300

shimono commented 5 years ago

Is this code really executed correctly returning rhino version ? Or does it just return timeout error response? I guess it just return error immediately, which is intended behavior.

This probably occurs because the script accesses internal java object, org.mozilla.javascript.Context. Personium Engine is designed to be a sandboxed JS runtime, so this should return error response for that reason.

As you point out, the error message should not be "Timeout".