dfinity / dfinity/pic-js

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

Open
#143 0 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
10
Forks
13
Avg merge
4h 41m
Merged PRs (30d)
1

Description

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.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at the TypeScript PocketIcServer.start() entry point and trace where the server's idle timeout is configured. Add the proposed TTL option and cover the configured timeout behavior, including the disabled-timeout case, with tests; done means watch-mode reruns remain connected after inactivity.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
developer-experience, testing
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.