Skip to content

Commit

Permalink
Better document auto-discovery
Browse files Browse the repository at this point in the history
  • Loading branch information
djfarrelly committed Jan 20, 2025
1 parent 2683286 commit 24b5ba6
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 3 deletions.
38 changes: 36 additions & 2 deletions pages/docs/dev-server.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ The Inngest dev server is an [open source](https://github.com/inngest/inngest) e

![Dev Server Demo](/assets/docs/local-development/dev-server-demo-2025-01-15.gif)

You can start the dev server with a single command. The dev server will attempt to find an Inngest `serve` API endpoint by scanning ports and endpoints that are commonly used for this purpose. (See the [list of ports](https://github.com/inngest/inngest/blob/ea67219e7e7c33451416249f98fd5ca48e99ba28/pkg/devserver/discovery.go#L15-L28) the dev server scans.) Alternatively, you can specify the URL of the `serve` endpoint:
You can start the dev server with a single command. The dev server will attempt to find an Inngest `serve` API endpoint by scanning ports and endpoints that are commonly used for this purpose (See "[Auto-discovery](#auto-discovery)"). Alternatively, you can specify the URL of the `serve` endpoint:

<CodeGroup>
```shell {{ title: "npx (npm)" }}
Expand Down Expand Up @@ -37,7 +37,7 @@ There are two ways to connect apps to the Dev Server:
![Dev Server demo manually syncing an app](/assets/docs/local-development/dev-server-apps-demo-2025-01-15.gif)

<Tip>
The dev server does "auto-discovery" which scans popular ports and [endpoints](https://github.com/inngest/inngest/blob/ea67219e7e7c33451416249f98fd5ca48e99ba28/pkg/devserver/discovery.go#L32-L40) like `/api/inngest` and `/.netlify/functions/inngest`. **If you would like to disable auto-discovery, pass the `--no-discovery` flag to the `dev` command**.
The dev server does "auto-discovery" which scans popular ports and endpoints like `/api/inngest` and `/.netlify/functions/inngest`. **If you would like to disable auto-discovery, pass the `--no-discovery` flag to the `dev` command**. Learn more about [this below](#auto-discovery)
</Tip>

### How functions are loaded by the Dev Server
Expand Down Expand Up @@ -180,3 +180,37 @@ $ curl -s http://localhost:3000/api/inngest | jq
"functionsFound": 1
}
```

## Auto-discovery

The dev server will automatically detect and connect to apps running on common ports and endpoints. You can disable auto-discovery by passing the `--no-discovery` flag to the `dev` command:

```sh
npx inngest-cli@latest dev --no-discovery -u http://localhost:3000/api/inngest
```

<CodeGroup>
```plaintext {{ title: "Common endpoints" }}
/api/inngest
/x/inngest
/.netlify/functions/inngest
/.redwood/functions/inngest
```

```plaintext {{ title: "Common ports" }}
80, 443,
// Rails, Express & Next/Nuxt/Nest routes
3000, 3001, 3002, 3003, 3004, 3005, 3006, 3007, 3008, 3009, 3010,
// Django
5000,
// Vite/SvelteKit
5173,
// Other common ports
8000, 8080, 8081, 8888,
// Redwood
8910, 8911, 8912, 8913, 8914, 8915,
// Cloudflare Workers
8787,
```
</CodeGroup>

13 changes: 12 additions & 1 deletion pages/docs/faq.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
- [Why am I getting a `NON_DETERMINISTIC_FUNCTION`
error?](#why-am-i-getting-a-non-deterministic-function-error)
- [Why am I getting an `Illegal invocation` error?](#why-am-i-getting-an-illegal-invocation-error)

- [Why is the dev server polling endpoints that don't exist?](#why-is-the-dev-server-polling-endpoints-that-don-t-exist)
## How do I run crons only in production?

There are multiple ways to achieve it:
Expand Down Expand Up @@ -96,3 +96,14 @@ new Inngest({
fetch: fetch.bind(globalThis),
});
```

## Why is the dev server polling endpoints that don't exist?
The dev server will automatically detect and connect to apps running on common ports and endpoints. These endpoints include `/api/inngest`, `/x/inngest`, `/.netlify/functions/inngest`, `/.redwood/functions/inngest`.

You can disable auto-discovery by passing the `--no-discovery` flag to the `dev` command:

```sh
npx inngest-cli@latest dev --no-discovery
```

Learn more about this in the [dev server](/docs/dev-server#auto-discovery) docs.

0 comments on commit 24b5ba6

Please sign in to comment.