Skip to content

Conversation

@taras
Copy link
Member

@taras taras commented Oct 19, 2025

Motivation

All extensions were migrated to v3 in #87, but we now want to be able to run tests on v4 which requires using import maps to switch dependencies.

Approach

  1. run deno task generate-importmap to generate v4.importmap.json
  2. run deno test --import-map v4.importmap.json -A to run tests

Tests with `spawn()` followed by `sleep(1)` pattern

  1. https://github.com/thefrontside/effectionx/blob/99132644309867524b27b00191efcb204608bbb6/stream-helpers/batch.test.ts

Test: "creates a batch within maxTime when maxSize is never reached"

  • yield* spawn(() =>
    forEach<readonly number[], void>(function* (batch) {
    const now = performance.now();
    windows.push(now - last);
    last = now;
    batches.push(batch);
    }, stream)
    );
    yield* sleep(1);

Test: "creates a batch within maxSize in maxTime window"

  1. https://github.com/thefrontside/effectionx/blob/99132644309867524b27b00191efcb204608bbb6/stream-helpers/tracker.test.ts

Test: "waits for all items to be processed"

  • yield* spawn(function* () {
    for (const item of yield* each(stream)) {
    yield* sleep(10);
    received.push(item);
    tracker.markOne(item);
    yield* each.next();
    }
    });
    yield* sleep(1);

Test: "tracks batched items"

  1. https://github.com/thefrontside/effectionx/blob/99132644309867524b27b00191efcb204608bbb6/stream-helpers/test-helpers/faucet.test.ts

Test: "creates a faucet that can pour items"

Test: "supports pouring with an operation"

Test: "stops pouring when closed"

  1. https://github.com/thefrontside/effectionx/blob/99132644309867524b27b00191efcb204608bbb6/stream-helpers/for-each.test.ts

Test: "should invoke function for each item in the stream"

Test: "should return the close value of the stream"

  1. https://github.com/thefrontside/effectionx/blob/99132644309867524b27b00191efcb204608bbb6/signals/helpers.test.ts

Test: "waits until the value of the stream matches the predicate"

  1. https://github.com/thefrontside/effectionx/blob/99132644309867524b27b00191efcb204608bbb6/signals/array.test.ts

Test: "does not send a value to the stream when the set value is the same as the current value"

  1. https://github.com/thefrontside/effectionx/blob/99132644309867524b27b00191efcb204608bbb6/stream-helpers/valve.test.ts

Test: "closes and opens the valve"

  1. https://github.com/thefrontside/effectionx/blob/99132644309867524b27b00191efcb204608bbb6/worker/worker.test.ts

Test: "shuts down gracefully"

  • let task = yield* spawn(function* () {
    yield* useWorker(url, {
    type: "module",
    data: {
    startFile,
    endFile,
    endText: "goodbye cruel world!",
    } satisfies ShutdownWorkerParams,
    });
    yield* suspend();
    });
    let started = yield* timebox(10_000, function* () {
    while (true) {
    yield* sleep(1);

Total: 13 instances across 8 test files

@taras taras force-pushed the tm/try-v4 branch 3 times, most recently from 71c04be to 9913264 Compare October 19, 2025 19:40
@cowboyd cowboyd force-pushed the tm/try-v4 branch 2 times, most recently from daf5aec to 6f4feee Compare October 20, 2025 18:46
taras and others added 23 commits October 28, 2025 19:38
- Created tasks/generate-importmap.ts to automatically collect all
  external dependencies from workspace packages
- Added "generate-importmap" task to root deno.json
- Replaced @gordonb/pipe with remeda in watch package
- Updated all remeda versions to ^2
- Added ws dependency to websocket package
- Added v4.importmap.json to .gitignore (generated file)
- Read exports field from each package's deno.json
- Support both string and object export formats
- Map workspace packages to their actual export paths
- Automatically add @std/testing sub-packages (/bdd, /mock, /time)
- Force all packages to use effection v4
- Rewrite batch implementation to use iterator-based approach with timebox
- Remove all console.log debug statements from batch
- Add sleep(1) calls in tests for operation tree setup timing
- Update batch tests to use signal convergence patterns
- Refactor tracker tests to use createArraySignal and is()
- Remove unused imports from test files
- Add @effectionx/timebox dependency to stream-helpers
- Initialize next with done=true to handle stream completion properly
- When lastPull times out, halt it and clear the reference before checking next
- When lastPull resolves, use its result as next instead of pushing to batch
- Move subscription.next() into else block to avoid duplicate calls
- Return next directly at end to propagate done state correctly
- When lastPull exists at the start of next(), wrap it in a timebox to respect maxTime. If the timeout occurs, halt the task instead of waiting indefinitely.

This fixes the hanging test where forEach would wait indefinitely for more items after the source stream was exhausted.
@taras taras force-pushed the tm/try-v4 branch 2 times, most recently from f3ad201 to 0e48239 Compare November 2, 2025 16:08
taras and others added 10 commits November 5, 2025 16:53
Increases batch test timing tolerances and adds automated stress testing with stress-ng.

Run tests:
  dagger call test-v-3-stress --rounds 100 export --path ./v3-summary.log --progress=plain
  dagger call test-v-4-stress --rounds 100 export --path ./v4-summary.log --progress=plain

Results show V4 has resource leaks in watch tests under CPU stress (chokidar cleanup issue).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants