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

Sending events in local dev environment should not fail if the local devserver is not running #271

Open
mmachatschek opened this issue Jul 24, 2023 · 0 comments
Labels
📦 inngest Affects the `inngest` package ✨ new New features, integrations, or exports

Comments

@mmachatschek
Copy link
Contributor

Is your feature request related to a problem? Please describe.
When developing e.g. a CMS it's not always essential to have the local inngest dev server running in order for the app to work.

When sending an event, most of the time you'll have hooks in your CMS that call inngest.send() to trigger events on the system. If the local dev server isn't running, the Inngest SDK will try to send the event to the official https://inn.gs/ which fails with an 401 Event key Not Found error.

I want an option locally to make the inngest SDK silently fail instead throwing an error if the inngest event could not be sent.

Describe the solution you'd like
A flag that will allow allowSendingEventsWithoutDevServer

Describe alternatives you've considered

The workaround I implemented looks like this:

export const inngest = new Inngest({
  name: 'app',
  inngestBaseUrl: process.env.NODE_ENV === 'development' ? 'http://localhost:8288/' : undefined,
  fetch:
    process.env.NODE_ENV === 'development'
      ? async (input: RequestInfo | URL, init?: RequestInit) => {
          try {
            const response = await fetch(input, init);

            return response;
          } catch (e) {
            console.warn(
              'Local inngest dev server not running. Events not being processed. Start the dev server with "npx inngest-cli@latest dev"'
            );
            return {
              status: 200,
            } as Response;
          }
        }
      : undefined,
});
@mmachatschek mmachatschek added the ✨ new New features, integrations, or exports label Jul 24, 2023
@jpwilliams jpwilliams added the 📦 inngest Affects the `inngest` package label Nov 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
📦 inngest Affects the `inngest` package ✨ new New features, integrations, or exports
Projects
None yet
Development

No branches or pull requests

2 participants