question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

generated trigger lambda missing callback

See original GitHub issue

Note: If your issue/bug is regarding the AWS Amplify Console service, please log it in the Amplify Console GitHub Issue Tracker

Describe the bug I went back and used amplify auth update to generate a Post Auth trigger for my user pool since some how manually selecting it was lost. (would be nice to be able to provide names for trigger lambdas) and I noticed the generated code is slightly different than what I see from amplify function add. It generates a custom.js for my code and has other code in index.js for looking for a MODULES env var. I left if that way and copied my code from the lambda I was using prior to it being unselected into custom.js and push it up. After if completed the build I tried logging in and I was seeing a InvalidLambdaResponseException I went back and noticed that the generated index.js did not include calling callback(null, event). After I added that and pushed/let it build and tried again I was able to log in.

After adding the callback line the code looks like:

/*
  this file will loop through all js modules which are uploaded to the lambda resource,
  provided that the file names (without extension) are included in the "MODULES" env variable.
  "MODULES" is a comma-delimited string.
*/

exports.handler = (event, context, callback) => {
  const modules = process.env.MODULES.split(',')
  for (let i = 0; i < modules.length; i += 1) {
    const { handler } = require(`./${modules[i]}`)
    handler(event, context, callback)
  }
  callback(null, event) // this line was missing

Amplify CLI Version 4.20.0

Also I’m curious if that is the direction the functions generated by amplify function add are heading, will they use a custom.js by default?

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:2
  • Comments:11 (2 by maintainers)

github_iconTop GitHub Comments

3reactions
attilahcommented, May 20, 2020

@cyrfer Thanks for your input, I reopen the issue and marking as a docs enhancement to clear up the confusion around the implementation.

2reactions
smakinsoncommented, May 20, 2020

It was unexpected to to me see the custom.js also. I’m may delete it, but I would also like to know the thoughts behind it.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Troubleshoot invocation issues in Lambda
Invocation errors can be caused by issues with request parameters, event structure, function settings, user permissions, resource permissions, or limits. If ...
Read more >
lambda trigger callback vs context.done - node.js
When executing a function, Lambda will throw an error that the tasked timed out after the configured number of seconds. You should find...
Read more >
Execute a Basic AWS Lambda Function Without Any Triggers
Trigger is an event that causes the AWS lambda function to execute. ... module.exports.handler = function( event, context, callback)
Read more >
Error handling in AWS Lambda triggered by SQS events
In this case we return error in Lambda callback and the same message will return to the queue. Lambda will process it one...
Read more >
Active Record Callbacks
Callbacks allow you to trigger logic before or after an alteration of an ... will run whenever an Active Record object is created,...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found