Skip to content

Serverless graphql not reporting errors #4155

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

Closed
dborstelmann opened this issue Nov 13, 2021 · 4 comments
Closed

Serverless graphql not reporting errors #4155

dborstelmann opened this issue Nov 13, 2021 · 4 comments
Labels
Package: serverless Issues related to the Sentry Serverless SDK

Comments

@dborstelmann
Copy link

dborstelmann commented Nov 13, 2021

I have followed this document directly: https://blog.sentry.io/2020/07/22/handling-graphql-errors-using-sentry

Running local servers like so works fine and reports to sentry:

import * as Sentry from '@sentry/node';
import { ApolloServer } from 'apollo-server';
import { SENTRY_OPTIONS, serverOptions } from 'index';

Sentry.init(SENTRY_OPTIONS);

const server = new ApolloServer(serverOptions);

server.listen().then(({ url }) => {
  console.log(`🚀 Server ready at ${url}`);
});

However, when you switch it to a lambda using @sentry/serverless, the errors don't get populated to sentry like so:

import * as Sentry from '@sentry/serverless';
import { ApolloServer } from 'apollo-server-lambda';
import { createContext } from 'context';
import { schema } from 'resolvers';

const SENTRY_DSN = 'redacted';

export const SENTRY_OPTIONS: Sentry.NodeOptions = {
  env: 'redacted',
  tracesSampleRate: 1.0,
  dsn: SENTRY_DSN,
  release: process.env.RELEASE,
};

Sentry.AWSLambda.init(SENTRY_OPTIONS);

export const serverOptions = {
  context: createContext,
  plugins,
  schema,
};

const server = new ApolloServer(serverOptions);

export const serverlessHandler = Sentry.AWSLambda.wrapHandler(
  server.createHandler(),
);

Any idea why this could be? The apollo plugins iterates through the errors and runs captureException in withScore as you can see in the docs.

EDIT: by the way, the warm start lambda function slows from ~500ms to ~2.5s with this change, while cold starts are always about ~4.5s.

@dborstelmann
Copy link
Author

dborstelmann commented Nov 13, 2021

Adding debug context (FYI this doesn't always show in the logs):

2021-11-13T01:08:55.917Z	281c54bd-3052-4b7d-a6f6-525da472a5ee	ERROR	Sentry Logger [Error]: Error while sending event: Error: connect ETIMEDOUT 34.120.195.249:443
--
2021-11-13T01:08:55.918Z	281c54bd-3052-4b7d-a6f6-525da472a5ee	ERROR	Sentry Logger [Error]: Error while sending event: Error: connect ETIMEDOUT 34.120.195.249:443
2021-11-13T01:08:55.918Z	281c54bd-3052-4b7d-a6f6-525da472a5ee	ERROR	Sentry Logger [Error]: Error while sending event: Error: connect ETIMEDOUT 34.120.195.249:443
2021-11-13T01:08:55.918Z	281c54bd-3052-4b7d-a6f6-525da472a5ee	ERROR	Sentry Logger [Error]: Error while sending session: Error: connect ETIMEDOUT 34.120.195.249:443
2021-11-13T01:08:55.918Z	281c54bd-3052-4b7d-a6f6-525da472a5ee	ERROR	Sentry Logger [Error]: Error while sending event: Error: connect ETIMEDOUT 34.120.195.249:443
2021-11-13T01:08:55.918Z	281c54bd-3052-4b7d-a6f6-525da472a5ee	ERROR	Sentry Logger [Error]: Error while sending event: Error: connect ETIMEDOUT 34.120.195.249:443

@dborstelmann dborstelmann changed the title Serverless Grapql not reporting errors Serverless graphql not reporting errors Nov 13, 2021
@sl0thentr0py sl0thentr0py added the Package: serverless Issues related to the Sentry Serverless SDK label Nov 19, 2021
@github-actions
Copy link
Contributor

This issue has gone three weeks without activity. In another week, I will close it.

But! If you comment or otherwise update it, I will reset the clock, and if you label it Status: Backlog or Status: In Progress, I will leave it alone ... forever!


"A weed is but an unloved flower." ― Ella Wheeler Wilcox 🥀

@dborstelmann
Copy link
Author

Would love to see an example of anyone getting AWS Lambda working with Sentry, I still have not been able to.

@dborstelmann
Copy link
Author

Turns out this had nothing to do with Sentry (or my implementation for that matter). The Lambdas don't have access to the network by default in a VPC. Feel pretty stupid admitting that was the issue but if anyone else is searching for this issue, you may want to start there as well.

https://www.serverless.com/framework/docs/providers/aws/guide/functions#vpc-configuration

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Package: serverless Issues related to the Sentry Serverless SDK
Projects
None yet
Development

No branches or pull requests

2 participants