I'm using jsreport to render HTML and generate a PDF file and it works locally, but on Lambda, it throws this error:
{
"errorMessage": "Error during rendering report: Cannot read property 'filter' of undefined",
"errorType": "TypeError",
"stackTrace": [
"Phantom.execute (/var/task/node_modules/jsreport-phantom-pdf/lib/phantom.js:169:53)",
"/var/task/node_modules/jsreport-core/lib/render/render.js:118:23",
"tryCatcher (/var/task/node_modules/bluebird/js/release/util.js:16:23)",
"Promise._settlePromiseFromHandler (/var/task/node_modules/bluebird/js/release/promise.js:512:31)",
"Promise._settlePromise (/var/task/node_modules/bluebird/js/release/promise.js:569:18)",
"Promise._settlePromise0 (/var/task/node_modules/bluebird/js/release/promise.js:614:10)",
"Promise._settlePromises (/var/task/node_modules/bluebird/js/release/promise.js:693:18)",
"Async._drainQueue (/var/task/node_modules/bluebird/js/release/async.js:133:16)",
"Async._drainQueues (/var/task/node_modules/bluebird/js/release/async.js:143:10)",
"Immediate.Async.drainQueues (/var/task/node_modules/bluebird/js/release/async.js:17:14)",
"runCallback (timers.js:672:20)",
"tryOnImmediate (timers.js:645:5)",
"processImmediate [as _immediateCallback] (timers.js:617:5)"
]
}
Same environment variables, same Node version.
Here's the line that generates the error above: https://github.com/jsreport/jsreport-phantom-pdf/blob/ad8d42e640348abffe77f2fed818528bee3eed98/lib/phantom.js#L169
var phantom = this.definition.options.phantoms.filter(function (p) {
return p.version === request.template.phantom.phantomjsVersion
})
which implies the object path options.phantoms is undefined.
You'll have to check how definitions is set up in your Lambda.
As it turned out, it was a problem of this library: node-app-root-path.
I fixed it by passing the correct rootDirectory option to jsreport.
Related
I'm trying to set up a simple Batch Compute Environment using a LaunchTemplate, so that I can specify a larger-than-default volume size:
const templateName = 'my-template'
const jobLaunchTemplate = new ec2.LaunchTemplate(stack, 'Template', {
launchTemplateName: templateName,
blockDevices: [ ..vol config .. ]
})
const computeEnv = new batch.CfnComputeEnvironment(stack, 'CompEnvironment', {
type: 'managed',
computeResources: {
instanceRole: jobRole.roleName,
instanceTypes: [
InstanceType.of(InstanceClass.C4, InstanceSize.LARGE).toString()
],
maxvCpus: 64,
minvCpus: 0,
desiredvCpus: 0,
subnets: vpc.publicSubnets.map(sn => sn.subnetId),
securityGroupIds: [vpc.vpcDefaultSecurityGroup],
type: 'EC2',
launchTemplate: {
launchTemplateName: templateName,
}
},
})
They both initialize fine when not linked, however as soon as the launchTemplate block is added to the compute environment, I get the following error:
Error: Resource handler returned message: "Resource of type 'AWS::Batch::ComputeEnvironment' with identifier 'compute-env-arn' did not stabilize." (RequestToken: token, HandlerErrorCode: NotStabilized)
Any suggestions are greatly appreciated, thanks in advance!
For anyone running into this - check the resource that is being created in the AWS Console - i.e go to aws.amazon.com and refresh the page over and over until you see it created by CF. This gave me a different error message regarding the instance profile not existing (A bit more helpful than the terminal error...)
A simple CfnInstanceProfile did the trick:
new iam.CfnInstanceProfile(stack, "batchInstanceProfile", {
instanceProfileName: jobRole.roleName,
roles: [jobRole.roleName],
});
I faced similar error.
But in my case cdk had created subnetGroups list in cdk.context.json and was trying to use the same in the CfnComputeEnvironment definition.
The problem was; I was using the default vpc and had manually modified few subnets. and cdk.context.json was not updated.
Solved by deleting the cdk.context.json
This file was recreated with correct values in next synth.
Tip for others facing similar problem:
Don't just rely on the error message; watch closely the Cloud-formation Script that's generated from CDK for the resource.
I am working on an automation prototype using Nightwatch js and when I am trying to save screenshot, it is giving below error
Error while running .getScreenshot() protocol action: An unknown
server-side error occurred while processing the command. – An unknown
server-side error occurred while proces...
TEST FAILURE: 1 error during execution; 0 tests failed, 0 passed
(10.032s)
TypeError: The "data" argument must be of type string or an instance
of Buffer, TypedArray, or DataView. Received an instance of Object
at Object.writeFile (fs.js:1487:5)
at FSReqCallback.oncomplete (fs.js:180:23)
FAILED: 1 errors and 1 passed (9.662s)
relevant data for nightwatch.config.js:
test_settings: {
"screenshots": {
"enabled": true, // if you want to keep screenshots
"path": './screenshots' // save screenshots here
},
test file data:
.pause(3000).saveScreenshot('./screnshots/test.png');
Nightwatch version: "1.5.1"
please note that due to office policy cannot paste complete testcase data here.
I have a code distributed in 2 Script files. One is the logic.js provided by Hyperledger Composer Playground. And another script file - optedServices.js in which I have a function getService() defined. I need to call this function getService() in the code of logic.js. Please let me know how to do this. Thanks in advance - Madhu
I tried 'Add a file' link in the bottom left corner. And drag and dropped the optedServices.js and pressed 'add' button. That included the file in UI of playground.
The file logic.js contains:
function numToString(optedService) {
if (optedService == "") {
return ""
}
var optedService2 = require('./optedService');
optedServices = optedService2.getService('2' + optedService);
.......
return optedServices;
}
The file optedService.js contains:
function getService (number)
{
.
.
.
return 'Sting1 & String2';
}
module.exports = {
getService:getService
}
Expected result: 'Sting1 & String2'
Actual Result:
Error: Error trying invoke business network with transaction id 22b513d8dbbf765bd23e3f448c45d2464e19b6c35628e23989c0a25f6a018b49. Error: No valid responses from any peers. Response from attempted peer comms was an error: Error: 2 UNKNOWN: error executing chaincode: transaction returned with failure: ReferenceError: module is not defined
I am creating my first Alexa skill which fetches data from dynamodb table. I am naive in node.js and alexa both. I was successfully able to create a sample Space geek skill set , and then when I created my own skill set I used the same package( to make sure the libraries, response files remain the same) but only changed the index.js ( which is my lambda funnction). When I am testing this function on lambda console , I am getting the below error:
{
"errorMessage": "event is not defined",
"errorType": "ReferenceError",
"stackTrace": [
"Module._compile (module.js:570:32)",
"Object.Module._extensions..js (module.js:579:10)",
"Module.load (module.js:487:32)",
"tryModuleLoad (module.js:446:12)",
"Function.Module._load (module.js:438:3)",
"Module.require (module.js:497:17)",
"require (internal/module.js:20:19)"
]
}
This function used to work perfectly fine without using alexa. Now I am not able to debug the issue. I tested this from alexa skill testing then got the below error:
The remote endpoint could not be called or response it returned was invalid
My folder structure is:
-Node_Modules
-index.js
-template.yaml
Any pointers are highly appreciated.
In your index.js, you should have a function with event in argument, even if you don't use it :
exports.handler = (event, context, callback) => { [...] };
I am using Plovr to compile my javascript with this config file.
// File: config.js
{
"debug": true,
"id": "myfirstapp",
"paths": ".",
"inputs": "main.js",
"level": "VERBOSE",
"mode": "ADVANCED",
"pretty-print": true
}
Strangely, my app works, but I am consistently getting these 2 errors in Chrome Console.
GET http://www.myunreleasedapp.com/deps.js 404 (NOT FOUND) a.js:181
Uncaught TypeError: Cannot read property 'debug' of undefined
I examined the second error and discovered that the property Params.settings is undefined, so calling Params.settings.debug produces this error. However, I am not sure where in my Closure code to resolve either of these two errors. Any advice on what to look out for in my code?
The second error (Uncaught TypeError: Cannot read property 'debug' of undefined
) oddly occurs on this really long line in 58852.user.js:
saveSettings();Extend(that,Params);Params.enabled=
(Registry.getKey("enabled","enabled")=="enabled"?true:false);Params.isPage=
(getFromId("jewelFansTitle")?
true:false);Params.debug=Params.settings.debug;try{Params.iFrame=
(window.top!=self)}catch(exception){new ErrorHandler(exception)}try{if(Params.mobile)
{Params.mobileId=getFromId("m_user_DEPRECATED").value}}catch(exception){new
ErrorHandler(exception)}function trace(){if(!Params.dev)
{return}try{if(!traced[arguments.callee.caller.name]){traced[arguments.callee.caller.name]=0
Again, Params.settings seems to be undefined. This is a Facebook app, so I think this code may be relevant to Facebook.