Container.resolve marked an app-scoped binding resolved only after its factory settled, so two resolutions that started before then both ran the factory. The binding now caches the promise as soon as the factory starts.
Retry semantics, kept as they were. Before, a rejecting factory set nothing, so the next resolution retried. Now a rejection clears the cached promise, so the next resolution still retries. Callers already waiting on the failed attempt share its one rejection rather than each starting their own. A synchronous throw takes the same path (the factory runs inside an async wrapper).
Reachability, please check my reading. It reproduces against Container exactly as the issue says (two calls, two values). I could not reach it through the public API. Container is not exported, and createApp's only register call is in bootProvider, which runs the provider's runner once inside the memoized boot (once already caches its promise) and registers the finished value as () => value. So no app opened two pools through createApp today, as far as I can tell, and the CHANGELOG entry says so. The fix makes the container keep its own guarantee instead of depending on that.
Tests in test/container.test.ts: concurrent resolution shares one factory call (failed on develop: expected "vi.fn()" to be called 1 times, but got 2 times); a rejection is shared while in flight and then retried (failed on develop: ['rejected','fulfilled']); a synchronous throw rejects and is retried (passes on both, it pins the existing behaviour).
Fixes GitHub #46.
`Container.resolve` marked an app-scoped binding resolved only after its factory settled, so two resolutions that started before then both ran the factory. The binding now caches the promise as soon as the factory starts.
**Retry semantics, kept as they were.** Before, a rejecting factory set nothing, so the next resolution retried. Now a rejection clears the cached promise, so the next resolution still retries. Callers already waiting on the failed attempt share its one rejection rather than each starting their own. A synchronous throw takes the same path (the factory runs inside an async wrapper).
**Reachability, please check my reading.** It reproduces against `Container` exactly as the issue says (two calls, two values). I could not reach it through the public API. `Container` is not exported, and `createApp`'s only `register` call is in `bootProvider`, which runs the provider's runner once inside the memoized boot (`once` already caches its promise) and registers the finished value as `() => value`. So no app opened two pools through `createApp` today, as far as I can tell, and the CHANGELOG entry says so. The fix makes the container keep its own guarantee instead of depending on that.
Tests in `test/container.test.ts`: concurrent resolution shares one factory call (failed on develop: `expected "vi.fn()" to be called 1 times, but got 2 times`); a rejection is shared while in flight and then retried (failed on develop: `['rejected','fulfilled']`); a synchronous throw rejects and is retried (passes on both, it pins the existing behaviour).
Ran: lint (0 errors), format:check, typecheck, `npm test` (1164 passed), complexity:check, test:deno (63 passed), test:bun (52 passed), test:edge (PASS).
Container.resolve marked an app-scoped binding resolved only after its
factory settled. Two resolutions that started before then both found
nothing cached and both ran the factory, so one token could open two
pools.
The binding now caches the promise as soon as the factory starts, and
every resolution returns that promise. Retry semantics are unchanged:
before, a rejected factory set nothing and the next resolution ran it
again. Now a rejection clears the cached promise, so the next
resolution still retries, and only the callers already waiting on the
failed attempt share its rejection. The factory runs inside an async
wrapper so a synchronous throw takes the same path.
createApp was not exposed to this in practice. bootProvider runs each
provider's runner once, inside the memoized boot, and registers the
finished value as a constant factory, and Container is not exported.
The fix makes the container's own guarantee hold instead of relying on
that.
Refs: GitHub #46
Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Fixes GitHub #46.
Container.resolvemarked an app-scoped binding resolved only after its factory settled, so two resolutions that started before then both ran the factory. The binding now caches the promise as soon as the factory starts.Retry semantics, kept as they were. Before, a rejecting factory set nothing, so the next resolution retried. Now a rejection clears the cached promise, so the next resolution still retries. Callers already waiting on the failed attempt share its one rejection rather than each starting their own. A synchronous throw takes the same path (the factory runs inside an async wrapper).
Reachability, please check my reading. It reproduces against
Containerexactly as the issue says (two calls, two values). I could not reach it through the public API.Containeris not exported, andcreateApp's onlyregistercall is inbootProvider, which runs the provider's runner once inside the memoized boot (oncealready caches its promise) and registers the finished value as() => value. So no app opened two pools throughcreateApptoday, as far as I can tell, and the CHANGELOG entry says so. The fix makes the container keep its own guarantee instead of depending on that.Tests in
test/container.test.ts: concurrent resolution shares one factory call (failed on develop:expected "vi.fn()" to be called 1 times, but got 2 times); a rejection is shared while in flight and then retried (failed on develop:['rejected','fulfilled']); a synchronous throw rejects and is retried (passes on both, it pins the existing behaviour).Ran: lint (0 errors), format:check, typecheck,
npm test(1164 passed), complexity:check, test:deno (63 passed), test:bun (52 passed), test:edge (PASS).0c7b5b25b6to510e9c4863