-
Notifications
You must be signed in to change notification settings - Fork 36
ESModule support failure due to require
-ing our client code
#295
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
Comments
require
-ing our client code
After digging a bit more, it seems like it's not finding datadog-lambda-js/src/runtime/user-function.ts Lines 130 to 137 in 826c36c
|
Hi Paco, is there a package.json next to your app.js file, that specifies it's a ES module? |
I have added a handful of logs to a modified
Yields
I see This means that
Returns
|
Let me follow why EDIT: The lambda environment is picking up the |
I have copied the contents of
The lambda runtime is not picking up that we're working with modules. What. |
I have moved the whole repo to My Dockerfile is lean
And the serverless one too
I know it's all there.
I'm at my wits' end to force it to load the handler. The exception is already telling me that Lambda is using the mjs runtime Why why why |
What happens if you change
to
The reason we have two files, is there is a cjs entry point for the node 12 runtime, (which doesn't support .mjs). If you use one of our lambda layers, we make sure node_modules/datadog-lambda-js/dist/handler.handler uses the right version for your runtime, but in the npm module we don't know which runtime you are using, so we leave both in. If this change does work, I will update our documentation to be cleared for Dockerfile users. If that doesn't work, I think a productive next step would be to send us a zip with a minimum reproduction. |
Your suggestion was helpful but didn't work :( Here's the minimum repro I was able to put together: lambda-failure-example.zip
|
We have the same or a very similar issue. We client code in a container image with modules and no bundling or processing of the JavaScript at all. The Dockerfile is straightforward:
When we change the CMD back to Changing to CMD to
|
@paco-sparta Thanks for the reproduction, it helps a lot. We will work on a fix for this soon. |
@paco-sparta @bgeese-szdm The temporary workaround is to remove the file for now. We will think about the Lambda layer and npm use cases, and come up with a solution for the long term. Thank you both for letting us know the issue!
|
Closing this one now and we will remove this |
Thank you both for the help! EDIT: same guy, personal account :D |
Uh oh!
There was an error while loading. Please reload this page.
Expected Behavior
Pointing the CMD to
handler.handle.mjs
should make the lambda compatible with ESModules.Actual Behavior
When launching our handler with package.json specifying "modules" and pointing our Docker file to "handler.handle.mjs", we see a
require
error at runtime.Where
app.js
is our client code, transpiled to ES2020 usingtsc
withesmoduleinterop
andisolatedModules
enabled. Node is configured to use experimentalnode
resolution for imports so file extensions aren't needed.Steps to Reproduce the Problem
Specifications
Stacktrace
The text was updated successfully, but these errors were encountered: