inngest / inngest-js

The developer platform for easily building reliable workflows with zero infrastructure for TypeScript & JavaScript
https://www.inngest.com/
GNU General Public License v3.0
370 stars 37 forks source link

Sentry middleware example doesn't work #602

Closed opsb closed 2 weeks ago

opsb commented 4 weeks ago

Describe the bug When an error occurs the sentryMiddleware never reports an error. The error should be reported in

  transformOutput({ result, step }) {
    // Capture step output and log errors
    if (step) {
      Sentry.setTags({
        "inngest.step.name": step.displayName,
        "inngest.step.op": step.op,
      });

      if (result.error) {
        Sentry.captureException(result.error);
      }
    }
  },

but step is always undefined.

To Reproduce Add example middleware as per https://www.inngest.com/docs/reference/middleware/examples#adding-sentry-error-reporting-and-tracing.

Throw an error in a handler.

Expected behavior Error should be report to Sentry

Screenshots / Stack trace dump If applicable, add screenshots or paste what is output in your terminal to help explain your problem.

System info

Additional context Workaround is to report the error without the step metadata

  transformOutput({ result, step }) {
    // Capture step output and log errors
    if (step) {
      Sentry.setTags({
        "inngest.step.name": step.displayName,
        "inngest.step.op": step.op,
      });
    }

    if (result.error) {
      Sentry.captureException(result.error);
    }
  },
linear[bot] commented 4 weeks ago

INN-3159 Sentry middleware example doesn't work

linear[bot] commented 4 weeks ago

INN-3161 Sentry middleware example doesn't work

jpwilliams commented 4 weeks ago

Hi, @opsb! 👋

Ah - good find. What version of Sentry are you using?

We have some discussion in #471 which results in the release of a new @inngest/middleware-sentry package in #598.

I'd love it if you could test out the new package and see if this also solves your issue, though we're targeting @sentry/node>=8.0.0 for that.

jpwilliams commented 2 weeks ago

Closing this - please address any further issues here in #471 or #598.