-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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 Problem Node.js & Latest #12465
Comments
Assigning to @getsentry/support for routing ⏲️ |
Routing to @getsentry/product-owners-settings-integrations for triage ⏲️ |
Having the same problem in production today. Had to rollback and remove our Sentry setup. |
hello, sorry that you've experienced that. Version While it's not a true fix for your problem, you can continue to use a v7 version of the layer. We specifically published one for Let me know if that helps at all. |
Hey @andreiborza, Thank you for following up. I am still not able to use AWS Lambda Layer. So this is what I've tried so far, all combinations of the following values. Nothing seems to work. ARNS: NODE_OPTIONS SENTRY_DSN SENTRY_TRACES_SAMPLE_RATE |
Having this issue as well. Had to turn off sentry lambda layer for all of our lambdas. Updating to the latest version of the lambda layer via the sentry UI caused this. |
For |
Thank you @andreiborza I also have set With that said, neither errors nor performance data is being sent to Sentry. Is there a way to debug it better? |
@fnfilho try setting |
Hey @andreiborza I did try by changing the package, but still did not work. This is what I did:
Logging than said: |
@fnfilho you should be able to set |
Thank you for following up, @andreiborza.
Than I forced an error to happen by using throw new Error("Sentry test"). No erros captured by Sentry and no logs in AWS about Sentry neither. |
I tried updating to the new version 252 (arn: Error: Env variables: |
@fnfilho that's because all the versions above |
Hey @andreiborza This is my configuration: This builds correctly.
Which prints something that looks ok:
I than throw an error:
Which prints me a log with an ID that I think is the error Code from Sentry:
|
I can add that I thought the reason why I didn't see my test errors etc was caused by us being over our limit, but I don't see any dropped errors. The 3 errors I got in was not via the layer, but with So I'm in the same ⛵ as @fnfilho 👋 |
@lforst I tried this and still see nothing in Sentry. In the response I do see a Sentry id. export const getAppVersionsController = async () => {
const sentryId = Sentry.captureMessage("test message");
await Sentry.flush();
return createResponse({
android: ANDROID_VERSION,
ios: IOS_VERSION,
sentryId,
});
}; |
Hey @lforst Tried that a few hours ago.
I also get the "Sentry exception captured" log with a response Id. |
My recommendation is to work backwards from the code snippet I posted here and see if it works and then gradually replace code with your own implementation. Also note that we are still working on better support for ESM, see this issue: #12409. |
To make it work, I have to: Sentry.init({
dsn: process.env.SENTRY_DSN,
}); and Is that how it is supposed to work @andreiborza |
@webjay if you don't configure the DSN via env variables yes. Try it with this: const Sentry = require("@sentry/aws-serverless");
Sentry.init({
dsn: "__DSN__",
tracesSampleRate: 1.0,
});
// Wrap your handler with `Sentry.wrapHandler`
exports.handler = Sentry.wrapHandler(async function(event, context) {
throw new Error('This should show up in sentry.')
}); |
@andreiborza I would say I do configure the DSN via env variables: import { LayerVersion } from "aws-cdk-lib/aws-lambda";
import { type StackContext } from "sst/constructs";
export function SentryStack({ app, stack }: StackContext) {
const sentryLayer = LayerVersion.fromLayerVersionArn(
stack,
"SentryLayer",
`arn:aws:lambda:${app.region}:943013980633:layer:SentryNodeServerlessSDK:255`,
);
app.addDefaultFunctionLayers([sentryLayer]);
app.addDefaultFunctionEnv({
// SENTRY_ENABLED: app.local ? "false" : "true",
SENTRY_DSN: process.env.SENTRY_DSN ?? "",
SENTRY_ENVIRONMENT: app.stage,
SENTRY_TRACES_SAMPLE_RATE: "1.0",
});
} However, it only works if I also do this: Sentry.init({
dsn: process.env.SENTRY_DSN,
tracesSampleRate: 1.0,
}); If I use I am not sure what the purpose of the layer is, when I still need to init and wrap? |
@webjay please add Here is another lambda function I successfully tried and the environment variables for it, without calling
const Sentry = require("@sentry/aws-serverless");
exports.handler = async function(event, context) {
Sentry.captureException(new Error('This error should show in sentry.'))
await Sentry.flush()
}; |
Should I use Is it a problem to use the layer and have |
@webjay are there any more logs? Looks like it's missing some earlier parts.
You don't have to, you can. Depending on how you want to init sentry.
Installed where? The layer comes with its own version. |
Hey @andreiborza and @lforst I did as requested and tried to simplify my code to something as similar as what you had there. Still no errors show up in Sentry. This is it. FYI. I'm using serverless to build and deploy to lambda using version ^3.35.2. I have configured esbuild to for import * as Sentry from "@sentry/aws-serverless";
import { nodeProfilingIntegration } from "@sentry/profiling-node";
Sentry.init({
dsn: "https://[email protected]/4507538786549760",
integrations: [nodeProfilingIntegration()],
tracesSampleRate: 1.0,
profilesSampleRate: 1.0,
debug: true,
});
// Handler
export const main = Sentry.wrapHandler(async function (event, context) {
try {
console.log("options", JSON.stringify(Sentry.getClient().getOptions()));
console.log("## ENVIRONMENT VARIABLES: " + serialize(process.env));
console.log("## CONTEXT: " + serialize(context));
console.log("## EVENT: " + serialize(event));
Sentry.captureException(new Error("This error should show in sentry 10."));
await Sentry.flush();
} catch (err) {
return {
statusCode: 500,
body: JSON.stringify(err),
};
}
});
var serialize = function (object: any) {
return JSON.stringify(object, null, 2);
}; There are a few errors in log, all like this below. Full logs are here.
|
My colleague @Lms24 has overworked the documentation around our AWS lambda offering. Please see https://docs.sentry.io/platforms/javascript/guides/aws-lambda for various options we support. Especially note the different installation methods we offer, and how to decide which to choose based on your setup. We also removed documentation around the AWS Lambda container, as we don't support that anymore. If you still have issues, please feel free to file a new issue. Thank you all for the discussion and help that allowed us to fix underlying issues and bugs. |
Environment
SaaS (https://sentry.io/)
Steps to Reproduce
We had an existing aws lambda integration in place and noticed that some of our lambdas were missing from the configure list. In trying to correct this we created a new installation and selected an existing project and aws stack, this updated our lambdas to the "latest". The lambdas immediately began producing errors (see below).
Here's what changed:
Lambda ARN changed from arn:aws:lambda:us-east-1:943013980633:layer:SentryNodeServerlessSDK:184 to arn:aws:lambda:us-east-1:943013980633:layer:SentryNodeServerlessSDK:245
NODE_OPTIONS env value changed from -r @sentry/serverless/dist/awslambda-auto to -r @sentry/aws-serverless/cjs/awslambda-auto
We had to disable sentry on all of our node.js lambdas so that they would continue to operate, in order for us to restore sentry reporting we'll have to manually update every lambda with the old layer and NODE_options values, we have hundreds of lambdas.
node:internal/modules/cjs/loader:597
throw e;
^
Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: Package subpath './cjs/awslambda-auto' is not defined by "exports" in /opt/nodejs/node_modules/@sentry/aws-serverless/package.json
at new NodeError (node:internal/errors:405:5)
at exportsNotFound (node:internal/modules/esm/resolve:371:10)
at packageExportsResolve (node:internal/modules/esm/resolve:718:9)
at resolveExports (node:internal/modules/cjs/loader:590:36)
at Module._findPath (node:internal/modules/cjs/loader:664:31)
at Module._resolveFilename (node:internal/modules/cjs/loader:1126:27)
at Module._load (node:internal/modules/cjs/loader:981:27)
at internalRequire (node:internal/modules/cjs/loader:174:19)
at Module._preloadModules (node:internal/modules/cjs/loader:1569:5)
at loadPreloadModules (node:internal/process/pre_execution:628:5) {
code: 'ERR_PACKAGE_PATH_NOT_EXPORTED'
}
Node.js v18.20.2
INIT_REPORT Init Duration: 156.91 ms Phase: init Status: error Error Type: Runtime.ExitError
node:internal/modules/cjs/loader:597
throw e;
^
Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: Package subpath './cjs/awslambda-auto' is not defined by "exports" in /opt/nodejs/node_modules/@sentry/aws-serverless/package.json
at new NodeError (node:internal/errors:405:5)
at exportsNotFound (node:internal/modules/esm/resolve:371:10)
at packageExportsResolve (node:internal/modules/esm/resolve:718:9)
at resolveExports (node:internal/modules/cjs/loader:590:36)
at Module._findPath (node:internal/modules/cjs/loader:664:31)
at Module._resolveFilename (node:internal/modules/cjs/loader:1126:27)
at Module._load (node:internal/modules/cjs/loader:981:27)
at internalRequire (node:internal/modules/cjs/loader:174:19)
at Module._preloadModules (node:internal/modules/cjs/loader:1569:5)
at loadPreloadModules (node:internal/process/pre_execution:628:5) {
code: 'ERR_PACKAGE_PATH_NOT_EXPORTED'
}
Node.js v18.20.2
INIT_REPORT Init Duration: 634.31 ms Phase: invoke Status: error Error Type: Runtime.ExitError
START RequestId: e2961f2a-10cc-4980-affa-a616efaaa7b8 Version: $LATEST
RequestId: e2961f2a-10cc-4980-affa-a616efaaa7b8 Error: Runtime exited with error: exit status 1
Runtime.ExitError
END RequestId: e2961f2a-10cc-4980-affa-a616efaaa7b8
REPORT RequestId: e2961f2a-10cc-4980-affa-a616efaaa7b8 Duration: 655.34 ms Billed Duration: 656 ms Memory Size: 256 MB Max Memory Used: 15 MB
Expected Result
N/A
Actual Result
N/A
Product Area
Settings - Integrations
Link
No response
DSN
No response
Version
No response
The text was updated successfully, but these errors were encountered: