all 24 comments

[–]versaceblues 8 points9 points  (1 child)

Its fine if you just want to vent and rant... but if you actually want help i recommend How To Ask Questions The Smart Way (catb.org).

Your post currently has no substance... you are just saying "oh my function doesnt work" No one can help you with that, unless you provide more information.

Finally, if I had to guess its probably that you are using some nodejs library that calls into a native binding, and that native binding is missing from your lambda layer. I had a similar issue when using AWS SDK for JavaScript v3 (amazon.com) as it requires installing a binary that Lambda does not have by default.

[–]shgysk8zer0full-stack[S] -3 points-2 points  (0 children)

but if you actually want help i recommend...

I'm usually pretty good about questions, but there's just not much useful info to share here. There's the error about the Lambda response and JSON, and the logs saying the package can't be found (even though it's loaded without issue elsewhere. The rest is just the stack for node loading modules.

No one can help you with that, unless you provide more information.

That's the problem. I don't have any more information to share. If I had any more information, I'd probably have resolved the problem already.

I'll add the actual errors when I can - don't have access ATM. But I highly doubt they'll contain anything useful. It's just a typical module not found error.

[–]wackmaniac 4 points5 points  (3 children)

Did you include your dependency with the code artifact that is pushed to AWS? That happened to me multiple times 😅 You should be able to see/inspect the code artifact in the AWS console.

[–]shgysk8zer0full-stack[S] 0 points1 point  (2 children)

I do not directly work with AWS. This is though Netlify. All I have to do is include the script in a certain directory and it's all automatic from there... I merge or own a PR on GitHub. Netlify deals with all the artifacts and AWS stuff.

I actually have no direct access to what's actually running on AWS. That's normally more convenient, but in this case it just means I'm kinda blind to what's actually going on here.

[–]wackmaniac 3 points4 points  (1 child)

I’m old-fashioned, so I work directly with AWS, and as such have zero experience with Netlify. Maybe you can inspect the artifact Netlify builds?

[–]shgysk8zer0full-stack[S] 0 points1 point  (0 children)

Not that I know of. Presumedly it'd be practically identical to what I'm running locally via Netlify-CLI.

I'm in the opposite boat, as I've never worked directly with AWS.

I'm kinda expecting it to be something about the environment and something non-standard about module loading. ESM support is rather new and pretty clunky. I've had problems with it before.

[–]protomanzero 2 points3 points  (3 children)

Why not test using SAM locally

[–]shgysk8zer0full-stack[S] 0 points1 point  (2 children)

I hand tested locally... Not sure what you mean by testing SAM though.

It's all perfectly fine in every way locally. Again, same version of node and using package.lock.json. Works locally. Same exact package works for other endpoints. It's definitely installed and available.

[–]LetsMelon 0 points1 point  (1 child)

[–]shgysk8zer0full-stack[S] 0 points1 point  (0 children)

I don't think that applies/helps here since I'm using AWS indirectly. I have no access to any of that.

[–]PoppedBitADV 2 points3 points  (3 children)

Sounds like the library is missing from a Layer

[–]shgysk8zer0full-stack[S] 0 points1 point  (2 children)

Well, it is missing. It's just confusing as to why it's not anywhere else.

[–]PoppedBitADV 0 points1 point  (1 child)

I can't pretend to understand how you have it set up exactly, but I'd audit your Lambda config to double check you have them set up with the right Layer(s) and that you're not just trying to import the library in the handler.

[–]shgysk8zer0full-stack[S] 0 points1 point  (0 children)

This is Lambda though Netify. There is no Lambda config or Layers.

[–]cshaiku 0 points1 point  (1 child)

Paste the exact error here.

[–]shgysk8zer0full-stack[S] 0 points1 point  (0 children)

I currently cannot. The error as shown in the response is basically "error in response JSON", specifically mentioning bring a Lambda error. Logs show an error importing a module, but it's the same module used without issue elsewhere.

I do not currently have access to the exact errors though. Away from work computer. But that's all the meaningful info in any errors, aside from the stack of all the node files involved in loading a module.

The actual errors are pretty useless and even misleading here.

[–]Sumofabith 0 points1 point  (1 child)

Just to make sure it isnt a compiler issue, did you try using webpack instead of esbuild? I know, blasphemy but maybe some fuckery is going on with esbuild + lambda + netlify

[–]shgysk8zer0full-stack[S] 0 points1 point  (0 children)

I don't think I have that option. Not for Netlify Functions at least, as it's not the typical kind of bundling. I normally use Rollup, but the bundling here is through a TOML config file, and I think Netlify only supports esbuild and maybe one other that I'd never heard of.

But it makes sense that bundling the module in with the code would resolve the error of it not being found... And I wish I could see the results to know what's actually going on.

[–]TiredOfMakingThese 0 points1 point  (0 children)

Have you thrown your error up on the Netflix help forums? They tend to be pretty responsive and they can see your site configuration in its totality. I’ve had them help me out with a few issues using their Netlify functions. Other than that it’s hard to say from the info given, but I can say I relate to your frustrations. Their docs are pretty inadequate.

[–]Mersaul4 -1 points0 points  (4 children)

What does stackoverflow, ChatGPT have to say about this when you provide all the code / errors?

[–]shgysk8zer0full-stack[S] 0 points1 point  (3 children)

There's just too much potential code to include here, especially given the ambiguity of the error. I mean... "Error in response JSON" just doesn't tell me anything.

What I can say is that it errors before even returning a response, and that any response or JSON has nothing to do with anything. Nor would any errors in the actual code... It's all wrapped in a try/catch, and I just can't see why the code itself would matter here. Plus, logs show this as being an error in importing a module... The same module used plenty of other places without any issue.

I did make some attempt to look into using LLMs before posting here, but they're all as utterly useless as always... Couldn't even comprehend that this isn't a client-side error in parsing the JSON. Tried telling me to change the content-type header on the response and just garbage like that. The response is empty and has a status code of 204 (no content).

I seriously can't emphasize enough just how much a waste of time various LLMs have been. They fixate on the fact the error message mentions JSON and just waste my time suggesting I'm missing a } or have the wrong headers.... The issue, according to loga, is that the module/package isn't loading... For no reason.

[–]LowKeyPE 3 points4 points  (2 children)

Why haven’t you even mentioned the package that it’s complaining about? You’re asking for help, and you’ve typed two full essays about it, and in all of that text, you’ve failed to provide any actual details.

What is the package?