Local Imposter Doesn't Error but when deployed on AWS lambda it complains about issues.
Opened this issue · 2 comments
I have the following mock config
plugin: rest
resources:
- path: /air-buzz/oauth/token
method: POST
requestHeaders:
content-type: application/json
response:
statusCode: 200
scriptFile: plugnplay/auth-response.js
and plugnplay/auth-response.js
file has following content. Which has some syntax error, ( no closing braces for authResponse object).
var authResponse = {
"access_token": "thisismyauthorizationvalueforplugnplay",
"expires_in": 100
respond()
.withStatusCode(200)
.withHeader("content-type","application/json")
.withContent(JSON.stringify(authResponse));
When I run imposter up
in local environment. It doesn't complain ( it does complain when I actually only hit the url /air-buzz/oauth/token
but doesn't complain in the compile phase or for other urls).
The same code when I am deploying in AWS lambda, it complains at the time compiling while booting).
I wanted to know if there are some settings/configs that I can add in the local Docker Image as well so that whenever I run locally (imposter up)
I get all these errors up front.
Other Informations:
- I am using imposter-awslambda.zip zip in my AWS lambda.
- I am using Docker image
outofcoffee/imposter:4.0.3
.
Happy to provide more details if needed.
Thanks in Advance.
Hi @tusharjajodia thank you for raising this. From Imposter 4.0 onwards, the default JavaScript engine is Graal, which doesn't precompile at startup, which makes diagnosing this issue challenging.
Are you able to share the CloudWatch logs for the Lambda function (preferably from the point of startup), to see what might be triggering the script invocation (and thus prompting the script to be interpreted)? If at all possible, doing this with the environment variable IMPOSTER_LOG_LEVEL=trace
set would be great.
Hi @tusharjajodia, this should be improved somewhat in v4.3.0, which performs basic syntax checking at init time, both locally and when running in Lambda.
Please let us know how you get on.