Timeout problem between 2 executions (In the Query Console) of Javascript function declared in a module - module

I defined the following module in the Modules database under '/test/test.mjs':
// test.mjs
export function test(message){
xdmp.log("Received: "+message);
return "Received: "+message;
}
I have the following code in the query console and I run it from a test database:
'use strict';
declareUpdate(); // I do not need here in this test case but I need it for my real code
import { test } from '/test/test.mjs';
test("Hello");
It is working fine the first time.
If I run it again, I am getting:
[javascript] XDMP-MODNOTFOUND: result: evalScriptOrModule(q) -- Module /test/test.mjs not found"
If I am waiting between 5 or 6 minutes and I run it again, it is working.
=> So it seems that a timeout is set somewhere when I am using a module inside the Query console (between 2 executions). Could you please give me an hint about it?

We solved the problem. It seems that it was coming from the configuration of the app server that we defined. Since we played also with it. The root was not equal to "/" anymore. We set it to "/" and now we do not have timeout problem between 2 executions.

Related

Cache files always created with wrong permissions in Yii 2

I get this error in my log files every time a cache file doesn't exist it seems. On the first page load, I always get this error
[message] => filemtime(): stat failed for [...]/runtime/cache/my/myapp03eab921185f7b68bbca50d8debc0dda.bin
[file] => [...]/vendor/yiisoft/yii2/caching/FileCache.php
[line] => 113
It doesn't happen anymore on next page loads but that one time is really annoying since the slack bot watcher is spamming our channel with this useless warning. Is there a way to avoid that, or is it a permission problem?
The "runtime", "cache" and "my" folders all have 775.
Update
Turns out the issue is that I'm using error_get_last() that is also getting warning-level errors. So it's a different issue entirely, not Yii-related
Make sure that you don't have enabled scream in your php.ini. Warnings from this filemtime() call should be suppressed by # operator, but scream setting can override this operator and generate warning anyway.
if (#filemtime($cacheFile) > time()) {
// ...
}
You must be getting this in PHP 7.1. try to run this with PHP 5.5 and see if you are getting the same error.
To reproduce you need to delete all files from runtime/cache directory
Then start app again(reload page) and look into runtime/cache. It is empty
Yii2 doesn't make cache again
Got same issue in Yii. The error was on the same string (FileCache.php:113)
if (#filemtime($cacheFile) > time()) {...
In my case reason was that my custom php error handler (heir
of the class yii\base\ErrorHandler) didn't check if
error type need to be handled according error_reporting().
Custom handlers allways gets every error, even muted by Error Control operator (#)
https://www.php.net/manual/en/function.set-error-handler.php
error_reporting() settings will have no effect and your error handler will be called regardless

Coldbox module event dying in renderLayout call

tl;dr: renderLayout(layout="myLayout", view="alpha/bravo/viewFile") resolves alpha as a module name rather than a package name in the host application, even if code execution is in the package rather than the module.
How do I get the path resolution to be consistent when either running the handler directly or when calling it via runEvent from a module?
I posted this on the CB google group, but then thought it may be best to ask here.
Working example here: https://github.com/jinglesthula/cbModuleExample
If you run install (I .gitignored the coldbox folder), then cd into the /app folder and server start --rewritesEnable you can visit http://127.0.0.1:<whatever port>/example/admin/test/ajax to see it in action.
From the example:
/app/modules_app/example/handlers/admin/test.cfc -> ajax() calls runEvent("admin.test.ajax")
/app/handlers/admin/test.cfc -> ajax() calls `renderLayout( layout = "layout.div", view = "admin/test/ajax" )
"admin/test/ajax" normally resolves to /app/views/admin/test/ajax.cfm, but in this case it's resolving to /app/modules_app/admin/views/test/ajax.cfm.
You can comment out line 18 and uncomment line 19 in /modules_app/example/admin/handlers/test.cfc to see a workaround.
You can also go to /admin/test/ajaxDirect in your browser to see that the renderLayout() call in the non-working example is correct.
Note: I have this.viewParentLookup = true in my ModuleConfig.cfc. I've tried reloading the module with it set to false and I get the same result.

Values lifetime in mod_perl

.pm file:
package fo_condition_editor;
use utf8;
use diagnostics -trace;
use strict;
use warnings FATAL => 'all';
{...}
use Encode;
my $msg = {};
return 1;
{..}
sub ..() {
$msg->{saved} = 1;
I use this pm to show popup. When form is submitted, popup is refreshed.
In my local server everything works fine, but in other server i had problem with variables $msg. $msg is empty during printing, but when i submit again in $msg are old things.
I think is problem with apache configuration.
The probloem - if I get this correctly - is that the code
my $msg = {};
is only executed when this package is required/used for the first time. After that (in the current mod_perl Instance) this wont be executed any more, and $msg keeps whatever value it has for the next requests.
There are a lot of ways to work around this problem. One schema, I use some times, is to define a "tear-down/reset" method for each "package / module-Entity" I use. In the package itself I push a reference of this method to a global Variable. And in my "core-Handler" called by mod_perl I have a tear-down/reset method, which iterates over the registered handlers and calls them to reset the data.
HTH
Georg

Access window object / browser scope from protractor

I'm running tests with protractor, but it seems impossible to access the JS 'window' object. I even tried adding a tag in my html file that would contain something like
var a = window.location;
and then try expect(a) but I couldn't make it work, I always get undefined references...
How should I process to access variables that are in the browser scope ?
Assuming you are using a recent version of Protractor, let's say >= 1.1.0, hopefully >= 1.3.1
Attempting to access Browser side JS code directly from Protractor won't work because Protractor runs in NodeJS and every Browser side code is executed through Selenium JsonWireProtocol.
Without further detail, a working example:
browser.get('https://angularjs.org/');
One-liner promise that, as of today, resolves to '1.3.0-rc.3'
browser.executeScript('return window.angular.version.full;');
You can use it directly in an expect statement given Protractor's expect resolves promises for you:
expect(browser.executeScript('return window.angular.version.full;')).
toEqual('1.3.0-rc.3');
Longer example passing a function instead of a string plus without expect resolving the promise for you. i.e. for more control and for doing some fancy thing with the result.
browser.driver.executeScript(function() {
return window.angular.version.full;
}).then(function(result) {
console.log('NodeJS-side console log result: ' + result);
//=> NodeJS-side console log result: 1.3.0-rc.3
});

Google Apps Script ScriptDb permissions issue

I am having an issue trying to query the ScriptDb of a resource file in Google Apps Script. I create a script file (file1), add it as a resource to another script file (file2). I call file1 from file2 to return a handle to its ScriptDb. This works fine. I then try to query the ScriptDb but have a permissions error returned.
Both files owned by same user and in same google environment
See code below:
file 1:
function getMyDb() {
return ScriptDb.getMyDb;
}
file 2 (references file1):
function getDataFromFile1() {
var db = file1.getMyDb(); // This works
var result = db.query({..............}); // This results in a permissions error!
}
I am at a loss to understand why I can access file1 and get back a handle on the ScriptDb, but then am not able to query it, due to an permissions issue.
I have tried to force file1 to require re-authorization, but have not yet been successful. I tried adding a new function and running it, so any suggestions there would be gratefully received.
Thanks in advance
Chris
There appears to be an error in file1/line2. It says "return ScriptDb.getMyDb;" but it should say "return ScriptDb.getMyDb();"
If you leave out the ()s then when you call file1 as a library, file1.getMyDb() will return a function which you store in var db. Then the line var result = db.query({..............}) results in an error because there is no method "query" in the function.
Is that what's causing your error?
I have figured out what the problem was, a misunderstanding on my part regarding authorisation. I was thinking of it in terms of file permissions, when in fact that problem was that my code was not authorised to run the DbScript service. As my code calls a different file and receives back a pointer to a ScriptDb database it is not using the ScriptDb service, so then when it calls the db.query() it invokes the ScriptDb service, for which it is not authorised.
To resolve this I just had to create a dummy function and make a ScriptDb.getMyDb() call, which triggered authorisation for the service. The code then worked fine.
Thanks for the input though.
Chris