I have installed ArangoDB 2.7.3 on Windows 7, 64 bit.
I have an use case where one Foxx application A exposes some functionality in a repository that I want to use in another Foxx application B so that I do not have to duplicate that particular functionality. The application B actually starts a job that is triggered periodically which calls the exported functionality from A. The problem is that sporadically the job throws an error that it does not find the exported module..but after a while it recovers.
I have added the two applications on Github: https://github.com/mphoenixo/arangodb.git
Has anyone experienced this before? I have built the applications using the documentation from ArangoDB but maybe I'm still missing something.
The stacktrace for the error follows:
2016-02-02T15:48:56Z [7380] ERROR TypeError: Cannot read property 'repo' of undefined
2016-02-02T15:48:56Z [7380] ERROR at d:/install/ArangoDB 2.7.3/var/lib/arangodb-apps/_db/DataPushLandingZone/foxx-import-app-example/APP/scripts/myJob.js:3:25
2016-02-02T15:48:56Z [7380] ERROR at [object Object].Module.run (D:\install\ArangoDB 2.7.3\bin\../share/arangodb/js/common/bootstrap/modules.js:1420:10)
2016-02-02T15:48:56Z [7380] ERROR at ArangoApp.loadAppScript (d:/install/ArangoDB 2.7.3/share/arangodb/js/server/modules/org/arangodb/foxx/arangoApp.js:458:24)
2016-02-02T15:48:56Z [7380] ERROR at executeAppScript (d:/install/ArangoDB 2.7.3/share/arangodb/js/server/modules/org/arangodb/foxx/manager.js:510:18)
2016-02-02T15:48:56Z [7380] ERROR at Object.runScript (d:/install/ArangoDB 2.7.3/share/arangodb/js/server/modules/org/arangodb/foxx/manager.js:814:10)
2016-02-02T15:48:56Z [7380] ERROR at Object.exports.work (d:/install/ArangoDB 2.7.3/share/arangodb/js/server/modules/org/arangodb/foxx/queues/worker.js:118:8)
2016-02-02T15:48:56Z [7380] ERROR at eval (<anonymous>:6:60)
2016-02-02T15:48:56Z [7380] ERROR at eval (<anonymous>:9:15)
2016-02-02T15:48:56Z [7380] ERROR at eval (<anonymous>:9:27)
2016-02-02T15:48:56Z [7380] ERROR
2016-02-02T15:48:56Z [7380] ERROR Running script "MyJob" not possible for mount "/foxx-import-app-example":
2016-02-02T15:48:56Z [7380] ERROR TypeError: Cannot read property 'repo' of undefined
2016-02-02T15:48:56Z [7380] ERROR at d:/install/ArangoDB 2.7.3/var/lib/arangodb-apps/_db/DataPushLandingZone/foxx-import-app-example/APP/scripts/myJob.js:3:25
2016-02-02T15:48:56Z [7380] ERROR at [object Object].Module.run (D:\install\ArangoDB 2.7.3\bin\../share/arangodb/js/common/bootstrap/modules.js:1420:10)
2016-02-02T15:48:56Z [7380] ERROR at ArangoApp.loadAppScript (d:/install/ArangoDB 2.7.3/share/arangodb/js/server/modules/org/arangodb/foxx/arangoApp.js:458:24)
2016-02-02T15:48:56Z [7380] ERROR at executeAppScript (d:/install/ArangoDB 2.7.3/share/arangodb/js/server/modules/org/arangodb/foxx/manager.js:510:18)
2016-02-02T15:48:56Z [7380] ERROR at Object.runScript (d:/install/ArangoDB 2.7.3/share/arangodb/js/server/modules/org/arangodb/foxx/manager.js:814:10)
2016-02-02T15:48:56Z [7380] ERROR at Object.exports.work (d:/install/ArangoDB 2.7.3/share/arangodb/js/server/modules/org/arangodb/foxx/queues/worker.js:118:8)
2016-02-02T15:48:56Z [7380] ERROR at eval (<anonymous>:6:60)
2016-02-02T15:48:56Z [7380] ERROR at eval (<anonymous>:9:15)
2016-02-02T15:48:56Z [7380] ERROR at eval (<anonymous>:9:27)
2016-02-02T15:48:56Z [7380] ERROR
2016-02-02T15:48:56Z [7380] ERROR Job 47455086883 failed:
2016-02-02T15:48:56Z [7380] ERROR [ArangoError 3103: failed to invoke module
2016-02-02T15:48:56Z [7380] ERROR File: d:/install/ArangoDB 2.7.3/var/lib/arangodb-apps/_db/DataPushLandingZone/foxx-import-app-example/APP/scripts/myJob.js]
2016-02-02T15:48:56Z [7380] ERROR at [object Object].Module.run (D:\install\ArangoDB 2.7.3\bin\../share/arangodb/js/common/bootstrap/modules.js:1425:20)
2016-02-02T15:48:56Z [7380] ERROR at ArangoApp.loadAppScript (d:/install/ArangoDB 2.7.3/share/arangodb/js/server/modules/org/arangodb/foxx/arangoApp.js:458:24)
2016-02-02T15:48:56Z [7380] ERROR at executeAppScript (d:/install/ArangoDB 2.7.3/share/arangodb/js/server/modules/org/arangodb/foxx/manager.js:510:18)
2016-02-02T15:48:56Z [7380] ERROR at Object.runScript (d:/install/ArangoDB 2.7.3/share/arangodb/js/server/modules/org/arangodb/foxx/manager.js:814:10)
2016-02-02T15:48:56Z [7380] ERROR at Object.exports.work (d:/install/ArangoDB 2.7.3/share/arangodb/js/server/modules/org/arangodb/foxx/queues/worker.js:118:8)
2016-02-02T15:48:56Z [7380] ERROR at eval (<anonymous>:6:60)
2016-02-02T15:48:56Z [7380] ERROR at eval (<anonymous>:9:15)
2016-02-02T15:48:56Z [7380] ERROR at eval (<anonymous>:9:27)
Thanks!
Your code looks fine. I'm not sure what the underlying cause you were experiencing might have been, but I'm fairly confident that for some reason the Foxx service you were trying to import wasn't initialized at the time the job was executed.
One reason you may have been experiencing this problem sporadically is that ArangoDB uses multiple V8 contexts in which JavaScript is executed. Jobs and HTTP requests are executed in any one of them at random. So if one of them was faulty, the job might still run fine if it is executed in another context.
Generally importing a Foxx service should guarantee that that service is properly initialized (just like running a job in that service or serving a request from that service). As you indicate that the problem may have been self-healing (i.e. it stopped happening after a while) this may mean that the contexts were eventually initialized properly.
I haven't been able to reproduce the problem on 2.8 either, but we will keep a close look on this. I don't believe the problem is Windows-specific. I suggest moving further discussion to the Google Groups thread and opening an issue on GitHub if the problem recurs.