Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
c0129d3
Add task to generate v4 importmap and update dependencies
taras Oct 18, 2025
2f89e28
convert fx to effection v4
jbolda Apr 21, 2025
0096f66
remove outer spawn, not required
jbolda Apr 22, 2025
1f44ad1
Fix dependency in worker/deno.json
taras Oct 18, 2025
ee0d69b
Include all dependencies in import map
taras Oct 18, 2025
507f714
Fixed eventemitter test by wrapping event in spawn
taras Oct 18, 2025
9eb8cba
Give the operation tree 1 tick to setup a subscription before sending…
taras Oct 18, 2025
5c8ea64
Run timers asyncronously in task-buffer tests
taras Oct 18, 2025
6d62852
Wrap arrary operations in a spawn in array tests
taras Oct 18, 2025
e6b6d3c
Wrapped boolean operations in spawn in boolean tests
taras Oct 18, 2025
6264ccf
Fixed array test by giving the operation tree a tick in array tests
taras Oct 19, 2025
4c64991
Check for boolean.test.ts updates differently
taras Oct 19, 2025
f6a8194
Fixed is helper test by giving it 1 tick to setup the operation tree
taras Oct 19, 2025
355a3e7
Fixed faucet tests by waiting 1 tick for operation tree and convergin…
taras Oct 19, 2025
24e4ee5
Update generate-importmap to use actual package exports
taras Oct 19, 2025
32b6312
Fix stream-helpers for effection v4 and remove debug logging
taras Oct 19, 2025
783d30b
Fix batch stream completion when lastPull times out
taras Oct 19, 2025
ae1d163
Run v3 and v4 tests
taras Oct 19, 2025
8c9cd58
Made generate importmap windows compatible
taras Oct 19, 2025
7353342
remove second loop
cowboyd Oct 20, 2025
770feb3
s/sleep(1)/sleep(0)/
cowboyd Oct 20, 2025
72ed749
Make the sleeps for v3 compat, not v4 compat
cowboyd Oct 20, 2025
b8419eb
Fixed paths in generate importmap script
taras Oct 28, 2025
ad14a45
Fix formatting
taras Oct 29, 2025
2f29b4b
Let's have an assertion in 'ignores files in .gitignore' test
taras Oct 29, 2025
25d8561
Simplify the batch test to remove timing ambiguity
taras Nov 2, 2025
e7af7ce
Make raf test a bit looser
taras Nov 2, 2025
845616f
Removed unnecessary sleep
taras Nov 2, 2025
4aed49e
Fix lint
taras Nov 2, 2025
f1fc2b3
Override effection dependency to v3 & v4
taras Nov 2, 2025
df2ee37
Try commenting out waiting for operation to complete
taras Nov 2, 2025
8100215
Refactor inspector into a resource
taras Nov 3, 2025
994550b
Fix lint
taras Nov 5, 2025
bc5ed01
convert process to resource
cowboyd Nov 5, 2025
1850761
Add dagger setup for reproducing
cowboyd Nov 5, 2025
7284ea4
Generate import map before start
cowboyd Nov 6, 2025
1340067
ignore dagger paths when computing source changes
cowboyd Nov 6, 2025
c41a64d
Added codesandbox config
taras Nov 8, 2025
1e8ec53
Added tasks for test and test:v4
taras Nov 8, 2025
e16ce7e
Added codesandbox dockerfile with deno
taras Nov 11, 2025
195c1dc
Installing ng-stresser
taras Nov 15, 2025
6fffe1b
Add stress testing infrastructure for V3 and V4
taras Nov 16, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .codesandbox/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
RUN apt update && apt install -y curl unzip && curl -fsSL https://deno.land/x/install/install.sh | sh
ENV DENO_INSTALL="/root/.deno"
ENV PATH="$DENO_INSTALL/bin:$PATH"
13 changes: 13 additions & 0 deletions .codesandbox/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
// These tasks will run in order when initializing your CodeSandbox project.
"setupTasks": [
{
"name": "curl -fsSL https://deno.land/install.sh | sh",
"command": "curl -fsSL https://deno.land/install.sh | sh"
}
],

// These tasks can be run from CodeSandbox. Running one will open a log in the app.
"tasks": {
}
}
1 change: 1 addition & 0 deletions .dagger/.gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/sdk/** linguist-generated
4 changes: 4 additions & 0 deletions .dagger/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/sdk
/**/node_modules/**
/**/.pnpm-store/**
/.env
Binary file added .dagger/.yarn/install-state.gz
Binary file not shown.
25 changes: 25 additions & 0 deletions .dagger/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions .dagger/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "module",
"dependencies": {
"typescript": "5.9.3"
},
"packageManager": "[email protected]+sha512.a6b2f7906b721bba3d67d4aff083df04dad64c399707841b7acf00f6b133b7ac24255f2652fa22ae3534329dc6180534e98d17432037ff6fd140556e2bb3137e"
}
78 changes: 78 additions & 0 deletions .dagger/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
/**
* A generated module for Effectionx functions
*
* This module has been generated via dagger init and serves as a reference to
* basic module structure as you get started with Dagger.
*
* Two functions have been pre-created. You can modify, delete, or add to them,
* as needed. They demonstrate usage of arguments and return types using simple
* echo and grep commands. The functions can be called from the dagger CLI or
* from one of the SDKs.
*
* The first line in this comment block is a short description line and the
* rest is a long description with more detail on the module's purpose or usage,
* if appropriate. All modules should have a short description.
*/
import { dag, Container, Directory, File, object, func, argument } from "@dagger.io/dagger"

@object()
export class Effectionx {
source: Directory

constructor(
@argument({ defaultPath: ".", ignore: ["**/.dagger/**/*"] })
source: Directory,
) {
this.source = source
}

@func()
ubuntu(): Container {
return dag
.container()
.from("ubuntu:latest")
.withExec(["apt-get", "update"])
.withExec(["apt-get", "install", "-y", "software-properties-common"])
.withExec(["add-apt-repository", "-y", "ppa:colin-king/stress-ng"])
.withExec(["apt-get", "update"])
.withExec(["apt-get", "install", "-y", "curl", "unzip", "nodejs", "stress-ng"])
.withExec(["sh", "-c", "curl -fsSL https://deno.land/install.sh | sh"])
.withMountedDirectory("/effectionx", this.source)
.withEnvVariable("PATH", "$PATH:/root/.deno/bin", { expand: true })
.withWorkdir("/effectionx")
.withExec(["deno", "install", "--allow-scripts"])
.withExec(["deno", "task", "generate-importmap"])
}

@func()
async testV3Stress(
@argument({ defaultValue: 100 })
rounds: number
): Promise<File> {
const container = this.ubuntu()
.withExec(["bash", "run-test-v3-stress.sh", rounds.toString()])

// Get the filename
const filename = await container
.withExec(["sh", "-c", "ls /effectionx/test-summary-v3_*.log"])
.stdout()

return container.file(filename.trim())
}

@func()
async testV4Stress(
@argument({ defaultValue: 100 })
rounds: number
): Promise<File> {
const container = this.ubuntu()
.withExec(["bash", "run-test-v4-stress.sh", rounds.toString()])

// Get the filename
const filename = await container
.withExec(["sh", "-c", "ls /effectionx/test-summary-v4_*.log"])
.stdout()

return container.file(filename.trim())
}
}
17 changes: 17 additions & 0 deletions .dagger/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"compilerOptions": {
"target": "ES2022",
"moduleResolution": "Node",
"experimentalDecorators": true,
"strict": true,
"skipLibCheck": true,
"paths": {
"@dagger.io/dagger": [
"./sdk/index.ts"
],
"@dagger.io/dagger/telemetry": [
"./sdk/telemetry.ts"
]
}
}
}
34 changes: 34 additions & 0 deletions .dagger/yarn.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# This file is generated by running "yarn install" inside your project.
# Manual changes might be lost - proceed with caution!

__metadata:
version: 8
cacheKey: 10c0

"root-workspace-0b6124@workspace:.":
version: 0.0.0-use.local
resolution: "root-workspace-0b6124@workspace:."
dependencies:
typescript: "npm:5.9.3"
languageName: unknown
linkType: soft

"typescript@npm:5.9.3":
version: 5.9.3
resolution: "typescript@npm:5.9.3"
bin:
tsc: bin/tsc
tsserver: bin/tsserver
checksum: 10c0/6bd7552ce39f97e711db5aa048f6f9995b53f1c52f7d8667c1abdc1700c68a76a308f579cd309ce6b53646deb4e9a1be7c813a93baaf0a28ccd536a30270e1c5
languageName: node
linkType: hard

"typescript@patch:typescript@npm%3A5.9.3#optional!builtin<compat/typescript>":
version: 5.9.3
resolution: "typescript@patch:typescript@npm%3A5.9.3#optional!builtin<compat/typescript>::version=5.9.3&hash=5786d5"
bin:
tsc: bin/tsc
tsserver: bin/tsserver
checksum: 10c0/ad09fdf7a756814dce65bc60c1657b40d44451346858eea230e10f2e95a289d9183b6e32e5c11e95acc0ccc214b4f36289dcad4bf1886b0adb84d711d336a430
languageName: node
linkType: hard
7 changes: 6 additions & 1 deletion .github/workflows/verify-posix.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,10 @@ jobs:
- run: deno fmt --check

- run: deno lint
- run: deno task generate-importmap

- run: deno test --allow-net --allow-read --allow-write --allow-env --allow-run --allow-ffi
- name: V3 Tests
run: deno test --allow-net --allow-read --allow-write --allow-env --allow-run --allow-ffi

- name: V4 Tests
run: deno test --import-map v4.importmap.json --allow-net --allow-read --allow-write --allow-env --allow-run --allow-ffi --trace-leaks
26 changes: 23 additions & 3 deletions .github/workflows/verify-windows.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,20 +41,40 @@ jobs:

- run: deno lint

- name: "Test (${{matrix.shell}})"
- run: deno task generate-importmap

- name: "Test V3 (${{matrix.shell}})"
if: matrix.shell == 'powershell' || matrix.shell == 'pwsh'
run: |
$env:SHELL = "${{matrix.shell}}"
deno test --allow-net --allow-read --allow-write --allow-env --allow-run --allow-ffi --trace-leaks

- name: "Test (${{matrix.shell}})"
- name: "Test V4 (${{matrix.shell}})"
if: matrix.shell == 'powershell' || matrix.shell == 'pwsh'
run: |
$env:SHELL = "${{matrix.shell}}"
deno test --import-map v4.importmap.json --allow-net --allow-read --allow-write --allow-env --allow-run --allow-ffi --trace-leaks

- name: "Test V3 (${{matrix.shell}})"
if: matrix.shell == 'cmd'
run: |
set SHELL=${{matrix.shell}}
deno test --allow-net --allow-read --allow-write --allow-env --allow-run --allow-ffi --trace-leaks

- name: "Test (${{matrix.shell}})"
- name: "Test V4 (${{matrix.shell}})"
if: matrix.shell == 'cmd'
run: |
set SHELL=${{matrix.shell}}
deno test --import-map v4.importmap.json --allow-net --allow-read --allow-write --allow-env --allow-run --allow-ffi --trace-leaks

- name: "Test V3 (${{matrix.shell}})"
if: matrix.shell == 'bash'
run: |
export SHELL=${{matrix.shell}}
deno test --allow-net --allow-read --allow-write --allow-env --allow-run --allow-ffi --trace-leaks

- name: "Test V4 (${{matrix.shell}})"
if: matrix.shell == 'bash'
run: |
export SHELL=${{matrix.shell}}
deno test --import-map v4.importmap.json --allow-net --allow-read --allow-write --allow-env --allow-run --allow-ffi --trace-leaks
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/deno.lock
/**/build/
/v4.importmap.json

.vscode
8 changes: 8 additions & 0 deletions dagger.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"name": "effectionx",
"engineVersion": "v0.19.4",
"sdk": {
"source": "typescript"
},
"source": ".dagger"
}
15 changes: 12 additions & 3 deletions deno.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
"effection": "npm:effection@^3",
"@deno/dnt": "jsr:@deno/[email protected]",
"@std/path": "jsr:@std/path@^1",
"zod": "npm:[email protected]"
"zod": "npm:[email protected]",
"@std/fs": "jsr:@std/fs@^1"
},
"compilerOptions": {
"lib": [
Expand All @@ -20,7 +21,10 @@
"prefer-const",
"require-yield"
]
}
},
"exclude": [
"tasks"
]
},
"workspace": [
"./context-api",
Expand All @@ -39,5 +43,10 @@
"./stream-helpers",
"./signals",
"./process"
]
],
"tasks": {
"generate-importmap": "deno run --allow-read --allow-write tasks/generate-importmap.ts",
"test": "deno test -A --trace-leaks",
"test:v4": "deno test -A --import-map=v4.importmap.json --trace-leaks"
}
}
10 changes: 7 additions & 3 deletions fx/parallel.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { describe, it } from "@effectionx/bdd";
import { expect } from "@std/expect";
import { each, Err, Ok, sleep, spawn } from "effection";
import { each, Err, Ok, sleep, spawn, until } from "effection";

import { parallel } from "./parallel.ts";

Expand Down Expand Up @@ -101,7 +101,8 @@ describe("parallel()", () => {
yield* sleep(15);
two.resolve(2);
});
const results = yield* parallel([one, () => two.promise]);

const results = yield* parallel([one, () => until(two.promise)]);
expect(yield* results).toEqual([Ok(1), Ok(2)]);
});

Expand All @@ -112,7 +113,10 @@ describe("parallel()", () => {

function* genFn() {
try {
const results = yield* parallel([() => one.promise, () => two.promise]);
const results = yield* parallel([
() => until(one.promise),
() => until(two.promise),
]);
actual = yield* results;
} catch (_) {
actual = [Err(new Error("should not get hit"))];
Expand Down
12 changes: 5 additions & 7 deletions fx/parallel.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import type { Callable, Channel, Operation, Result } from "effection";
import type { Channel, Operation, Result, Task } from "effection";
import { createChannel, resource, spawn } from "effection";

import { safe } from "./safe.ts";

import type { Computation } from "./type.ts";
export interface ParallelRet<T> extends Computation<Result<T>[]> {
export interface ParallelRet<T> extends Operation<Result<T>[]> {
sequence: Channel<Result<T>, void>;
immediate: Channel<Result<T>, void>;
}
Expand Down Expand Up @@ -61,16 +60,16 @@ export interface ParallelRet<T> extends Computation<Result<T>[]> {
* }
* ```
*/
export function parallel<T>(
operations: Callable<T>[],
export function parallel<T, TArgs extends unknown[] = []>(
operations: ((...args: TArgs) => Operation<T>)[],
): Operation<ParallelRet<T>> {
const sequence = createChannel<Result<T>>();
const immediate = createChannel<Result<T>>();
const results: Result<T>[] = [];

return resource<ParallelRet<T>>(function* (provide) {
const task = yield* spawn(function* () {
const tasks = [];
const tasks = [] as Task<Result<T>>[];
for (const op of operations) {
tasks.push(
yield* spawn(function* () {
Expand All @@ -95,7 +94,6 @@ export function parallel<T>(
yield* task;
return results;
}

yield* provide({
sequence,
immediate,
Expand Down
4 changes: 2 additions & 2 deletions fx/race.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ describe("raceMap()", () => {
function* () {
let winner;
const results = yield* raceMap({
first: function* () {
*first() {
yield* sleep(10);
winner = "first";
return "first";
},
second: function* () {
*second() {
yield* sleep(20);
winner = "second";
return "second";
Expand Down
Loading
Loading