aws-lambda-image icon indicating copy to clipboard operation
aws-lambda-image copied to clipboard

Lambda fails to run

Open CharlTruter opened this issue 8 years ago • 8 comments

I've set the lambda to point to a specific bucket and resize the image 3 times. Everytime I upload an image to the monitored folder, I get the following error message:

Unable to import module 'index': Error at Function.Module._resolveFilename (module.js:325:15) at Function.Module._load (module.js:276:25) at Module.require (module.js:353:17) at require (internal/module.js:12:17) at Object. (/var/task/libs/ImageResizer.js:3:19) at Module._compile (module.js:409:26) at Object.Module._extensions..js (module.js:416:10) at Module.load (module.js:343:32) at Function.Module._load (module.js:300:12) at Module.require (module.js:353:17)

My configuration is as follows (with bucket name replaced):

{ "bucket": "bucketnamehere", "resizes": [ { "size": 100, "directory": "p/w_100" }, { "size": 192, "directory": "p/w_192" }, { "size": 730, "directory": "p/w_730" } ] }

Also asked a co-worker to set up NodeJS from scratch and regenerate the lambda zip file, but gives the same error message.

CharlTruter avatar May 09 '16 10:05 CharlTruter

I've tried to process with your configuration on Lambda on Node.js 0.10 / 4.3 runtime, and it succeed.

It seems to be able to resolve bundled module path, and make configtest command result was green.

I want to know your settings:

  1. Process image's MimeType. (png or jpg)
  2. Using memory size of Lambda's setting

And, please rebuild this package at upstream master's branch sources.

ysugimoto avatar May 09 '16 11:05 ysugimoto

make configtest also gives me green result.

  1. Images I tested was jpg
  2. Memory size is set to 1536MB

Strangely enough, another co-worker has no issues with the same config, but he's using an older build (https://github.com/ysugimoto/aws-lambda-image/commit/77e17e78f7d2d82c876fa7ac998ff883da640488)

I'll retest and let you know.

CharlTruter avatar May 09 '16 11:05 CharlTruter

Seems like I'm on the latest build and still gives me the same error (0.10 and 4.3 runtime).

Can I provide you with any other information to help solve this issue?

CharlTruter avatar May 09 '16 11:05 CharlTruter

It may be no loaded bootstrap module ( in this pakage, bootstrap module is index.js ). Perhaps, It fails on build phase: make lambda.

Check build archive, extract it, and do you find in index.js at archived directory on top level?

ysugimoto avatar May 11 '16 09:05 ysugimoto

Yep, index.js is there. make lambda also doesn't give me any error message.

CharlTruter avatar May 12 '16 11:05 CharlTruter

I had problem on dependency library, and updated to 0.8.0. Please update package or re-install this, try it.

ysugimoto avatar May 16 '16 09:05 ysugimoto

@ysugimoto I am also getting same issue with latest version

START RequestId: 8b97cd19-8af9-11e6-a8b1-07630d403ce7 Version: $LATEST
Unable to import module 'index': Error
at Function.Module._resolveFilename (module.js:325:15)
at Function.Module._load (module.js:276:25)
at Module.require (module.js:353:17)
at require (internal/module.js:12:17)
at Object.<anonymous> (/var/task/index.js:10:24)
at Module._compile (module.js:409:26)
at Object.Module._extensions..js (module.js:416:10)
at Module.load (module.js:343:32)
at Function.Module._load (module.js:300:12)
at Module.require (module.js:353:17)
END RequestId: 8b97cd19-8af9-11e6-a8b1-07630d403ce7

Here its my config file

{
  "reduce": {
      "directory": "reduced",
      "quality": 90
  },
  "resizes": [
    {
      "size": 900,
      "directory": "tn",
      "quality": 90
    }
  ]
}

Memory size is 1024mb.

Pls suggest.

mitulshah44 avatar Oct 05 '16 15:10 mitulshah44

Not a help for the issue above, but if your symptoms are similar make sure your handler in lamda is called index.handler. I called mine after the function and it didn't work due to module name mismatch.

tenitski avatar Feb 06 '17 20:02 tenitski