Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 18 additions & 11 deletions content/250-postgres/300-database/550-local-development.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -217,17 +217,14 @@ This is a complete runnable example that will print `[{abba: 1}]` when run:

```ts
import { Client } from 'pg'
import { unstable_startServer } from '@prisma/dev'
import { getPort } from 'get-port-please'
import { startPrismaDevServer } from '@prisma/dev'

async function startLocalPrisma(name: string) {
const port = await getPort()

return await unstable_startServer({
return await startPrismaDevServer({
name, // required, use a unique name if running tests in parallel
port, //optional, defaults to 51213
databasePort: port + 1, // optional, defaults to 51214
shadowDatabasePort: port + 2, // optional, defaults to 51215
port: 51213, // optional, defaults to 51213
databasePort: 51214, // optional, defaults to 51214
shadowDatabasePort: 51215, // optional, defaults to 51215
persistenceMode: 'stateless' // optional, defaults to 'stateless'. Use 'stateful' to persist data between runs
})
}
Expand All @@ -249,19 +246,29 @@ try {

### API Arguments

The `unstable_startServer()` function accepts the following options:
The `startPrismaDevServer()` function accepts the following options:

| **Argument** | **Required** | **Description** | **Default** |
| ------------------------ | ------------ | ------------------------------------------------------------------------------------------------------------------------------ | ------------- |
| **`name`** | | Unique identifier for the local Prisma Postgres instance. Use distinct names if running multiple servers in parallel. | |
| **`name`** | | Unique identifier for the local Prisma Postgres instance. Use distinct names if running multiple servers in parallel. | `'default'` |
| **`port`** | ❌ | Port for the Prisma engine server. Throws an error if the port is already in use. | `51213` |
| **`databasePort`** | ❌ | Port for the embedded PostgreSQL database. Used for all Prisma ORM connections. | `51214` |
| **`shadowDatabasePort`** | ❌ | Port for the shadow database used during migrations. | `51215` |
| **`persistenceMode`** | ❌ | Defines how data is persisted:<br />• `'stateless'` — no data is retained between runs<br />• `'stateful'` — data persists locally | `'stateless'` |
| **`debug`** | ❌ | Whether to enable debug logging. | `false` |
| **`dryRun`** | ❌ | Whether to run the server in dry run mode. | `false` |
| **`databaseConnectTimeoutMillis`** | ❌ | Connection timeout in milliseconds for pending database connections. Starts ticking for every new client that attempts to connect. When exceeded, the pending client connection is evicted and closed. Use with caution, as it may lead to unexpected behavior. Best used with a pool client that retries connections. | `60000` (1 minute) |
| **`databaseIdleTimeoutMillis`** | ❌ | Idle timeout in milliseconds for active database connections. Re-starts ticking after each message received on the active connection. When exceeded, the active client connection is closed, and a pending connection is promoted to active. Use with caution, as it may lead to unexpected disconnections. Best used with a pool client that can handle disconnections gracefully. Set it if you suffer from client hanging indefinitely. | Not applied by default |
| **`shadowDatabaseConnectTimeoutMillis`** | ❌ | Connection timeout in milliseconds for pending shadow database connections. | Defaults to `databaseConnectTimeoutMillis` |
| **`shadowDatabaseIdleTimeoutMillis`** | ❌ | Idle timeout in milliseconds for active shadow database connections. | Defaults to `databaseIdleTimeoutMillis` |

:::tip

You can dynamically choose available ports using libraries like [`get-port-please`](https://www.npmjs.com/package/get-port-please) to avoid conflicts when running multiple instances.
You can import the type definition for better TypeScript support:

```ts
import { type ServerOptions } from '@prisma/dev'
```

:::

Expand Down
36 changes: 1 addition & 35 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading