From 2b04d34d89b87d10bb00aad4c3192937199a71b4 Mon Sep 17 00:00:00 2001 From: konard Date: Thu, 25 Dec 2025 11:19:00 +0100 Subject: [PATCH 1/3] Initial commit with task details Adding CLAUDE.md with task information for AI processing. This file will be removed when the task is complete. Issue: https://github.com/wevm/prool/issues/43 --- CLAUDE.md | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 CLAUDE.md diff --git a/CLAUDE.md b/CLAUDE.md new file mode 100644 index 0000000..a9c5b84 --- /dev/null +++ b/CLAUDE.md @@ -0,0 +1,7 @@ +Issue to solve: https://github.com/wevm/prool/issues/43 +Your prepared branch: issue-43-85604e29d13b +Your prepared working directory: /tmp/gh-issue-solver-1766657931378 +Your forked repository: konard/wevm-prool +Original repository (upstream): wevm/prool + +Proceed. \ No newline at end of file From 1947cf8dbbd02a993f51e62ba5c5500a71ab7903 Mon Sep 17 00:00:00 2001 From: konard Date: Thu, 25 Dec 2025 11:25:32 +0100 Subject: [PATCH 2/3] feat: make Instance.create optional to fix type compatibility MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This change addresses issue #43 by making the `create` method optional on the Instance type. Previously, the Pool used an internal `Instance_` type (defined as `Omit`) which was incompatible with the public `Instance` type, causing type errors when users tried to type pool-returned instances as `Instance`. Changes: - Make `create` property optional in Instance type (`create?` instead of `create`) - Remove the internal `Instance_` type alias from Pool.ts - Update Pool to use `Instance` type directly - Add runtime check for create method in Pool.start() - Update create method return type to return full Instance 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- src/Instance.ts | 9 ++++++--- src/Pool.ts | 22 ++++++++++++---------- 2 files changed, 18 insertions(+), 13 deletions(-) diff --git a/src/Instance.ts b/src/Instance.ts index e473e57..be4f684 100644 --- a/src/Instance.ts +++ b/src/Instance.ts @@ -26,10 +26,13 @@ export type Instance< _internal: _internal /** * Creates an instance. + * + * Note: This method is only available on instances created directly (not from a pool). + * When an instance is obtained from a pool via `pool.start()`, this method is not present. */ - create( + create?( parameters?: { port?: number | undefined } | undefined, - ): Omit, 'create'> + ): Instance<_internal> /** * Host the instance is running on. */ @@ -116,7 +119,7 @@ export function define< fn: define.DefineFn, ): define.ReturnType<_internal, parameters> { return (...[parametersOrOptions, options_]) => { - function create(createParameters: Parameters[0] = {}) { + function create(createParameters: { port?: number | undefined } = {}) { const parameters = parametersOrOptions as parameters const options = options_ || parametersOrOptions || {} diff --git a/src/Pool.ts b/src/Pool.ts index 82a449a..b4d35bb 100644 --- a/src/Pool.ts +++ b/src/Pool.ts @@ -2,14 +2,12 @@ import getPort from 'get-port' import type { Instance } from './Instance.js' -type Instance_ = Omit - export type Pool = Pick< - Map, + Map, 'entries' | 'keys' | 'forEach' | 'get' | 'has' | 'size' | 'values' > & { _internal: { - instance: Instance_ | ((key: key) => Instance_) + instance: Instance | ((key: key) => Instance) } destroy(key: key): Promise destroyAll(): Promise @@ -17,7 +15,7 @@ export type Pool = Pick< start( key: key, options?: { port?: number | undefined } | undefined, - ): Promise + ): Promise stop(key: key): Promise stopAll(): Promise } @@ -41,8 +39,7 @@ export function define( ): define.ReturnType { const { limit } = parameters - type Instance_ = Omit - const instances = new Map() + const instances = new Map() // Define promise instances for mutators to avoid race conditions, and return // identical instances of the promises (instead of duplicating them). @@ -52,7 +49,7 @@ export function define( destroy: new Map>(), destroyAll: undefined as Promise | undefined, restart: new Map>(), - start: new Map>(), + start: new Map>(), stop: new Map>(), stopAll: undefined as Promise | undefined, } @@ -117,7 +114,7 @@ export function define( const startPromise = promises.start.get(key) if (startPromise) return startPromise - const resolver = Promise.withResolvers() + const resolver = Promise.withResolvers() if (limit && instances.size >= limit) throw new Error(`Instance limit of ${limit} reached.`) @@ -130,7 +127,12 @@ export function define( : parameters.instance const { port = await getPort() } = options - const instance_ = instances.get(key) || instance.create({ port }) + const existingInstance = instances.get(key) + const instance_ = existingInstance || instance.create?.({ port }) + if (!instance_) + throw new Error( + `Instance "${instance.name}" does not have a create method.`, + ) instance_ .start() .then(() => { From 9457ed00333de7830aef33b1496dfeb85e2f1730 Mon Sep 17 00:00:00 2001 From: konard Date: Thu, 25 Dec 2025 11:27:00 +0100 Subject: [PATCH 3/3] Revert "Initial commit with task details" This reverts commit 2b04d34d89b87d10bb00aad4c3192937199a71b4. --- CLAUDE.md | 7 ------- 1 file changed, 7 deletions(-) delete mode 100644 CLAUDE.md diff --git a/CLAUDE.md b/CLAUDE.md deleted file mode 100644 index a9c5b84..0000000 --- a/CLAUDE.md +++ /dev/null @@ -1,7 +0,0 @@ -Issue to solve: https://github.com/wevm/prool/issues/43 -Your prepared branch: issue-43-85604e29d13b -Your prepared working directory: /tmp/gh-issue-solver-1766657931378 -Your forked repository: konard/wevm-prool -Original repository (upstream): wevm/prool - -Proceed. \ No newline at end of file