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] cause not populated in onFailure handler (event.data.error), no type for result property #797

Open
halfbakedsneed opened this issue Jan 9, 2025 · 1 comment · May be fixed by inngest/inngest#2088

Comments

@halfbakedsneed
Copy link

halfbakedsneed commented Jan 9, 2025

Describe the bug

After throwing a NonRetriableError with a cause property, In the object passed to onFailure:

  • event.data.error.cause is not populated.
  • result.cause is populated but the handler type does not surface result as a property that exists.

To Reproduce
Steps to reproduce the behavior:

  1. Create a function with an onFailure handler:
const inngestFn = inngest.createFunction(
  {
    id: 'some-function',
    onFailure: async ({ event, env }) => {
      const eventData = event.data;

      const inputEvent = event.data.event;
      const inputEventData = inputEvent.data;

      const output = {
        expectedEventErrorCauseMessage: inputEventData.message,
        actualEventErrorCauseMessage: eventData.error.cause ?? null,
        // @ts-expect-error for some reason `result` is not in the type
        actualResultCauseMessage: eventData.result?.cause?.message,
      };

      return output;
    },
  },
  { event: 'app/some-event' },
  async ({ event, step }) => {
    throw new NonRetriableError('Some inngest error', {
      cause: { message: event.data.message }, // new Error(event.data.message) doesn't work either
    });
  },
);
  1. Send this event:
{
  name: "app/some-event",
  data: {
    message: "some error message",
  },
},
  1. Observe the output of the onFailure handler:
{
  "expectedEventErrorCauseMessage": "some error message",
  "actualEventErrorCauseMessage": null,
  "actualResultCauseMessage": "some error message"
}

MRE repository here

Expected behavior

In the above reproduction:

  • actualEventErrorCauseMessage should equal some error message.
  • Types should surface the result property in the object passed to the onFailure handler.

System info (please complete the following information):

  • OS: MacOS Sonoma 14.4.1
  • npm package Version 3.29.0
  • Inngest CLI version 1.3.3
  • Framework [e.g. Next.js, Express] N/A
  • Platform [e.g. Vercel, AWS Lambda] Cloudflare Worker / Dev
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

Successfully merging a pull request may close this issue.

1 participant