Skip to content
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

[BUG] Sentry middleware captures errors differently if they cause function failures (missing data) #716

Open
fnimick opened this issue Sep 27, 2024 · 2 comments

Comments

@fnimick
Copy link

fnimick commented Sep 27, 2024

Describe the bug

The Inngest sentry middleware does not capture all error data from errors that cause an immediate function failure. This includes both instances of NonRetriableError, as well as errors that are thrown on the final retry of a function.

To Reproduce
Steps to reproduce the behavior:

Define an error that includes extra data such as:

export class ErrorWithExtra extends Error {
  constructor(
    message: string,
    public extra?: Record<string, unknown>,
  ) {
    super(message);
  }
}

In an Inngest function, throw this error from a step inside a function that retries:

export default inngest.createFunction(
  { id: "hello-world" },
  { event: "demo/event.sent" },
  async ({ event, step }) => {
    await step.run("send-test-error", () => {
      throw new ErrorWithExtra("Test error", { extra: "data" });
    });
    return {
      message: `Hello ${event.name}!`,
    };
  },
);

In Sentry, the first four retries will log the extra data in the context, but the fifth and final retry doesn't.

This also affects any other properties on Error, which are not captured on the final retry attempt.

Expected behavior
The extra field on error should be captured regardless of whether it is the final error thrown in a retry sequence.

Code snippets / Logs / Screenshots

Not final retry:
image

Final retry:
image

System info (please complete the following information):

  System:
    OS: macOS 15.0
    CPU: (10) arm64 Apple M1 Pro
    Memory: 116.80 MB / 16.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 20.13.1 - ~/.asdf/installs/nodejs/20.13.1/bin/node
    Yarn: 1.22.19 - ~/.yarn/bin/yarn
    npm: 10.5.2 - ~/.asdf/plugins/nodejs/shims/npm
    pnpm: 9.7.0 - ~/.asdf/shims/pnpm
  npmPackages:
    @inngest/eslint-plugin: ^0.0.7 => 0.0.7 
    @inngest/middleware-sentry: ^0.1.0 => 0.1.1 
    inngest: ^3.22.0 => 3.22.6 

Framework is Sveltekit.

@fnimick
Copy link
Author

fnimick commented Sep 27, 2024

Found the problem - StepError doesn't preserve any other properties on the Error other than cause https://github.com/inngest/inngest-js/blob/main/packages/inngest/src/components/StepError.ts

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant