Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AWS Lambda Execution Failed " Cannot find module '/var/task/modules/translate/src/promise" #155

Open
suzettewilliams opened this issue Jan 24, 2023 · 8 comments

Comments

@suzettewilliams
Copy link

I deployed the zotero translation-server on AWS lambda using your previously deleted lambda_deploy script. Every time I make a request via the API Gateway url the translation-server fails with a "Missing authentication token" The error logs show:

Lambda execution failed with status 200 due to customer function error: Error: Cannot find module '/var/task/modules/translate/src/promise'
Method completed with status: 502

I installed the promise module, but cloudformation doesn't update.

Are there updated instructions or documentation for getting the zotero translation server running on AWS lambda?

@SevanBadal
Copy link

The previous deploy script copies over submodules into a new dir named package. It seems possible that your submodules weren't pulled in locally before deploying! Try running git submodule update --init --recursive before running locally and deploying.

See line 18 which copies the modules dir (containing multiple git submodules):

# Skip files that aren't required i.e. ".git"
cp -r config package/
cp -r modules package/
cp -r node_modules package/
cp -r src package/

@suzettewilliams
Copy link
Author

Thank you SevanBadal. I will follow your directions and I will let you know the outcome

@suzettewilliams
Copy link
Author

The modules were copied and the problem still persists. My lambda deploy file is shown below:

#!/bin/bash -e
dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"

if [ -z $1 ]; then
	echo "Usage: $0 config.env" >&2
	exit 1
fi

set -a
. "$dir/$1"
set +a

rm -rf package
mkdir package

# Skip files that aren't required i.e. ".git"
cp -r config package/
cp -r modules package/
cp -r node_modules package/
cp -r src package/

# Remove broken symlinks because "sam package" complains
find -L package/ -maxdepth 10 -type l -delete

j2 "$dir/lambda_template.yaml.j2" > "$dir/package/template.yaml"

sam package --template-file "$dir/package/template.yaml" --s3-bucket $deployment_bucket_name --output-template-file "$dir/package/package.yaml"
aws cloudformation deploy --template-file "$dir/package/package.yaml" --stack-name $stack_name --capabilities CAPABILITY_IAM

@SevanBadal
Copy link

Can you please paste the result of ls modules/translate here? We want to confirm that the translate directory is not empty.

@suzettewilliams
Copy link
Author

swilliams@LAPTOP-I0QMUR48:~/translation-lambda/translation-server$ ls modules/translate
src
swilliams@LAPTOP-I0QMUR48:~/translation-lambda/translation-server$ ls src
args.js            formats.js         proxy.js           textSearch.js   webEndpoint.js
cors.js            http.js            searchEndpoint.js  translation     webSession.js
debug.js           importEndpoint.js  server.js          translators.js  zotero.js
exportEndpoint.js  lambda.js          testEndpoint.js    utilities.js

@SevanBadal
Copy link

SevanBadal commented Feb 28, 2023

I'm not seeing promise.js in the contents of your modules/translate/src directory! This could be related to the error message you reported above which is complaining about not finding a module /var/task/modules/translate/src/promise:

I deployed the zotero translation-server on AWS lambda using your previously deleted lambda_deploy script. Every time I make a request via the API Gateway url the translation-server fails with a "Missing authentication token" The error logs show:

Lambda execution failed with status 200 due to customer function error: Error: Cannot find module '/var/task/modules/translate/src/promise'
Method completed with status: 502

@suzettewilliams
Copy link
Author

Thanks, yes, the promise js file is missing. I will add, and let you know the outcome.

@suzettewilliams
Copy link
Author

suzettewilliams commented Mar 7, 2023

I am tryng to redeploy, by using the updated repository. but I am stuck at ./lambda_deploy: line 15: j2: command not found The jinjacli is installed jinja2 in ./env/lib/python3.8/site-packages (3.1.2). Prior to using the updated code, I deployed with the promise module, but the same error occurred, because the function was looking in /var/task/modules/translate/src/promise for the promise module, but the promise.js file was in my home folder/translation-server/modules/translate/src/promise*. I am thinking of creating a symbolic link. I am unsure if that will work, since I am still stuck at j2 command not found. Any thoughts about the J2 command?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants