Skip to content

Feature Request: Make PocketIC Server TTL configurable to support watch mode #143

@jneums

Description

@jneums

Problem:
The PocketIC server currently has a hardcoded idle timeout. While this is great for preventing orphaned processes in single-run CI environments, it makes the library difficult to use in a standard local development workflow with --watch mode (e.g., vitest --watch)

If a developer is using a globalSetup file to start a single server instance for the test run, the server will shut down after a minute of inactivity. When the developer saves a file to trigger a re-run, the tests fail with an ECONNREFUSED error because the server is no longer running.

Steps to Reproduce:

  1. Configure Vitest to use a globalSetup file that calls PocketIcServer.start().
  2. Run vitest --watch. The first run succeeds.
  3. Wait for ~90 seconds without saving any files.
  4. Save a test file to trigger a re-run.
  5. The test run fails because it cannot connect to the server.

Proposed Solution:
Expose a configuration option in the PocketIcServer.start() method to control the idle timeout. For example:

await PocketIcServer.start({
  // Allow setting the TTL in milliseconds.
  // A value of 0 or null could disable the timeout entirely.
  ttl: 3_600_000, // 1 hour
});

This would be a non-breaking change that would significantly improve the developer experience for local testing.

Current Workaround:
Not using watch mode and just triggering test manually.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions