Skip to content

GraphQL plug-in prevents Sentry middleware from catching errors #10354

@jorisw

Description

@jorisw

Bug report

Describe the bug

Because the Sentry plug-in's middleware comes after that of the GraphQL plug-in, and the GraphQL plug-in catches fatal errors for reporting in the response, fatal errors as part of GraphQL operations are not reported to Sentry.

Other middlewares are likely to suffer from the GraphQL plug-in catching the errors, too.

Steps to reproduce the behavior

  1. Enable the GraphQL plug-in
  2. Enable the Sentry plug-in
  3. Put a sendError() call somewhere and trigger the call
  4. Notice the error is reported to Sentry
  5. Put some nonsensical code in a controller or model such as hi()
  6. Do a GraphQL query that reaches this code
  7. Notice the error is part of the GraphQL response
  8. Notice the error is not caught by the Sentry plug-in/middleware, therefore not reported to Sentry

Expected behavior

I expect fatal errors to be both reported by the GraphQL response, as well as reported by the Sentry plug-in to Sentry

Screenshots

These console logs, added to node_modules/strapi-sentry-plugin/middlewares/sentry/index.js, are not logged when calling a GraphQL query that triggers an error:

image

I also tried to put the Sentry middleware before that of GraphQL, to no avail, probably because we're talking about middlewares as part of plug-ins:

// config/middleware.js

module.exports = () => ({
  load: { order: ['sentry', 'graphql'] },
})

System

  • Node.js version: v14.15.0
  • Yarn version: 1.22.5
  • Strapi version: 3.6.2
  • Database: MySQL
  • Operating system: macOS 11.3

Metadata

Metadata

Assignees

Labels

issue: bugIssue reporting a bugseverity: lowIf the issue only affects a very niche base of users and an easily implemented workaround can solvestatus: confirmedConfirmed by a Strapi Team member or multiple community members

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions