Add an async context data test for @fedify/express - #985
Conversation
integrateFederation() accepts a contextDataFactory that may return either a plain value or a Promise, but only the synchronous path was covered. Add a test that verifies the middleware waits for an async factory to resolve and passes the resolved value to federation.fetch(). Also wire up the test script/task in package.json and deno.json so mise run test:node and test-each actually run it. Changelog: none Assisted-by: Claude Code:claude-sonnet-5
✅ Deploy Preview for fedify-json-schema canceled.
|
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: ASSERTIVE Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
💤 Files with no reviewable changes (1)
📝 WalkthroughWalkthroughThe Express package adds Deno, Node, and Bun test commands. New middleware tests verify that ChangesExpress async context test
Estimated code review effort: 2 (Simple) | ~10 minutes Possibly related issues
Possibly related PRs
Suggested labels: Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@packages/express/src/index.test.ts`:
- Around line 65-88: Update the async contextDataFactory test to use a deferred
promise and track federation.fetch invocation; assert fetch remains uncalled
before resolving the promise, then resolve it and verify the existing response
and middleware behavior after completion.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: ASSERTIVE
Plan: Pro Plus
Run ID: 67407354-e127-4371-939c-d560137a9e46
📒 Files selected for processing (3)
packages/express/deno.jsonpackages/express/package.jsonpackages/express/src/index.test.ts
The previous test only checked the resolved value, not that federation.fetch() stays uncalled until the async contextDataFactory promise resolves. Use a deferred promise to assert the ordering directly, per CodeRabbit's review on fedify-dev#985. Changelog: none Assisted-by: Claude Code:claude-sonnet-5
sij411
left a comment
There was a problem hiding this comment.
Since integrateFederation() only assigns send, json, and removeHeader and never calls their existing implementations, could these methods be omitted from the initial response mock?
2chanhaeng
left a comment
There was a problem hiding this comment.
Thanks for your contribution! Please check my comment.
| "prepack": "pnpm build", | ||
| "prepublish": "pnpm build" | ||
| "prepublish": "pnpm build", | ||
| "test": "node --experimental-transform-types --test" |
The package had a Node test script but no Bun equivalent, so the suite never ran under Bun. Mirror the elysia package's pattern. Changelog: none Assisted-by: Claude Code:claude-sonnet-5
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@packages/express/package.json`:
- Line 62: Add an engines.node declaration in packages/express/package.json
covering the Node versions that support --experimental-transform-types, or
replace that flag with a test command compatible with the package’s declared
Node support baseline. Keep the test script’s behavior unchanged for supported
runtimes.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: ASSERTIVE
Plan: Pro Plus
Run ID: 06c7d757-01e1-434f-a281-caebe31bfec5
📒 Files selected for processing (1)
packages/express/package.json
| "prepack": "pnpm build", | ||
| "prepublish": "pnpm build" | ||
| "prepublish": "pnpm build", | ||
| "test": "node --experimental-transform-types --test", |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
set -euo pipefail
mapfile -t files < <(
fd -HI -t f \
-g 'package.json' \
-g '.nvmrc' \
-g '.node-version' \
-g '.tool-versions' \
-g '*.yml' \
-g '*.yaml' \
.
)
for file in "${files[@]}"; do
rg -n '"engines"|"node"|node-version|setup-node|NODE_VERSION|experimental-transform-types' "$file" || true
doneRepository: fedify-dev/fedify
Length of output: 486
🏁 Script executed:
#!/bin/bash
set -eu pipefail
printf 'Repository files matching Node/version/test config names:\n'
git ls-files | grep -Ei '(^|/)(package\.json$|\.nvmrc$|\.node-version$|\.tool-versions$|\.node-versionrc$|\.nvvmrc$|\.yml$|\.yaml$|README(\.|$)|deno\.json$|bun\.lock$|pnpm-workspace\.yaml$)' | sort
printf '\nRelevant Node/version/test config references:\n'
git ls-files | grep -Ei '(^|/)(package\.json$|\.nvmrc$|\.node-version$|\.tool-versions$|\.node-versionrc$|\.nvvmrc$|\.yml$|\.yaml$|README(\.|$)|deno\.json$|bun\.lock$|pnpm-workspace\.yaml$)' | while IFS= read -r file; do
if rg -n '"engines"|"node"|"nodejs"|node-version|nodeversion|setup-node|NODE_VERSION|experimental-transform-types|--experimental-transform-types|^test:|^test:' "$file" >/tmp/rgmatch 2>/dev/null; then
printf '\n--- %s ---\n' "$file"
cat /tmp/rgmatch
fi
done
printf '\npackages/express/package.json relevant sections:\n'
python3 - <<'PY'
import json, pathlib
p=pathlib.Path('packages/express/package.json')
data=json.loads(p.read_text())
for key in ['name', 'engines', 'scripts']:
print(f'{key}: {json.dumps(data.get(key, "<missing>"), indent=2)}')
PY
printf '\nRoot package.json engines/scripts context:\n'
python3 - <<'PY'
import json, pathlib
for p in [pathlib.Path('package.json'), pathlib.Path('pnpm-workspace.yaml'), pathlib.Path('.github/workflows')]
pass
PY
# A minimal, focused search for any Node version declarations.
printf '\nFocused search for Node version declarations and transform flag:\n'
rg -n --glob '!**/.git/**' '(^|[^a-zA-Z0-9.])(node(\s*=>|-?[~^>=<][0-9]|@\d+)|NODE_VERSION|node-version|setup-node|engines|experimental-transform-types|--experimental-transform-types)' .Repository: fedify-dev/fedify
Length of output: 9194
🌐 Web query:
Node.js --experimental-transform-types added removed version 22.7.0 26.0.0
💡 Result:
The --experimental-transform-types flag was added to Node.js in version 22.7.0 [1][2][3]. It was subsequently removed in version 26.0.0 [1][4]. The removal was implemented via pull request #61803, which was merged on February 27, 2026 [5][6].
Citations:
- 1: https://nodejs.org/api/typescript.html
- 2: https://nodejs.org/en/blog/release/v22.7.0
- 3: https://nodejs.org/docs/v22.16.0/api/typescript.html
- 4: http://nodejs.org/docs/latest/api/typescript.html
- 5: module: remove --experimental-transform-types nodejs/node#61803
- 6: nodejs/node@89f4b6c
🏁 Script executed:
#!/bin/bash
set -e
printf 'Root package.json and express package metadata:\n'
python3 - <<'PY'
import json, pathlib
for p in ["package.json", "pnpm-workspace.yaml", "packages/express/package.json"]:
path=pathlib.Path(p)
print(f"\n--- {p} ---")
if p.endswith(".json"):
data=json.loads(path.read_text())
for key in ["name", "type", "packageManager", "engines", "scripts"]:
print(f"{key}: {json.dumps(data.get(key, "<missing>"), indent=2)}")
else:
print(path.read_text().strip())
PY
printf '\nGitHub workflow Node version pins:\n'
git ls-files '.github/workflows/*.yml' '.github/workflows/*.yaml' | sort | while IFS= read -r file; do
echo "### $file"
rg -n 'node-version:|setup-node|engines|actions/setup-node|uses: .*setup-node|matrix|nodejs|NODE_VERSION' "$file" || true
done
printf '\nAll Node declaration files excluding generated lock artifacts:\n'
git ls-files | grep -Ei '(^|/)(\.nvmrc$|\.node-version$|\.tool-versions$|package\.json$|pnpm-workspace\.yaml$)' | sort | while IFS= read -r file; do
if rg -n '"engines"|"pnpm"|"volta"|node-version|NODE_VERSION|setup-node|experimental-transform-types' "$file" >/tmp/rgmatch; then
echo "### $file"
cat /tmp/rgmatch
fi
doneRepository: fedify-dev/fedify
Length of output: 385
🌐 Web query:
fedify-dev fedify package.json packageManager package.json engines node pnpm-workspace.yaml fedify
💡 Result:
Fedify is a TypeScript-based framework designed for building federated server applications, supporting multiple runtimes (Node.js, Deno, Bun) and various package managers [1][2][3]. The technical configuration details regarding the requested files are as follows: pnpm-workspace.yaml The Fedify repository is a monorepo that utilizes pnpm workspaces to manage its various packages (e.g., core, web framework integrations, CLI) [1][4][5]. The pnpm-workspace.yaml file defines the packages included in the workspace and employs the pnpm catalog feature to manage dependencies centrally [4][6]. When adding a new package or updating existing ones, dependencies in individual package.json files reference these catalog versions using the catalog: protocol rather than hardcoded version numbers [6]. package.json and packageManager Fedify's CLI includes a fedify init command that scaffolds new projects [2]. This command allows users to specify a package manager (options include deno, pnpm, bun, yarn, or npm) [7][8]. The scaffolder generates a package.json file for Node.js-based projects, which includes essential metadata such as "type": "module" and project-specific npm scripts [9]. While the CLI dynamically manages dependency installation based on the chosen runtime and package manager, it does not mandate a specific packageManager field in the generated package.json [10][9]. Historically, issues regarding the CLI's detection of local package managers (e.g., pnpm) have been addressed in maintenance updates [11]. engines node Fedify-based projects are generally compatible with standard Node.js environments. For example, specific implementations, such as the federated microblog example, require Node.js 20.0.0 or later [3]. While developers may define an engines field in their project-level package.json to enforce Node.js version compatibility, this is standard practice for Node.js projects rather than a specific requirement enforced by the Fedify framework itself. Overall, Fedify is designed to be runtime-agnostic and modular, allowing users to integrate it into their preferred Node.js frameworks (e.g., Express, Fastify, Next.js) using the appropriate integration package [12][2].
Citations:
- 1: https://github.com/fedify-dev/fedify?tab=readme-ov-file
- 2: https://unstable.fedify.dev/
- 3: https://github.com/fedify-dev/microblog
- 4: https://github.com/fedify-dev/fedify/blob/main/pnpm-workspace.yaml
- 5: https://github.com/fedify-dev/fedify/blob/6cc02662/pnpm-workspace.yaml
- 6: https://fedify.dev/contribute
- 7: https://github.com/fedify-dev/fedify/blob/6cc02662/packages/init/src/command.ts
- 8: https://github.com/fedify-dev/fedify/blob/6cc02662/packages/init/src/types.ts
- 9: https://github.com/fedify-dev/fedify/blob/6cc02662/packages/init/src/action/configs.ts
- 10: https://github.com/fedify-dev/fedify/blob/6cc02662/packages/init/src/action/deps.ts
- 11: fedify init <dir> can't find any Node.js package manager #210
- 12: https://fedify.dev/manual/integration
Scope the Node command to a supported runtime.
This package does not declare Node version support, while --experimental-transform-types exists only for Node 22.7.0 through 25. Add engines.node for the supported range or use a Node configuration that is compatible with the declared support baseline.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@packages/express/package.json` at line 62, Add an engines.node declaration in
packages/express/package.json covering the Node versions that support
--experimental-transform-types, or replace that flag with a test command
compatible with the package’s declared Node support baseline. Keep the test
script’s behavior unchanged for supported runtimes.
integrateFederation() only overwrites send, json, and removeHeader with no-ops; it never calls their existing implementations, so the mock response doesn't need them. Changelog: none Assisted-by: Claude Code:claude-sonnet-5
Good catch, removed them — thanks! |
Summary
integrateFederation()'scontextDataFactorymay return a plain value or aPromise, but only the synchronous path had test coverage.This adds a regression test for the async path, verifying the middleware waits for the factory to resolve and passes the resolved value to
federation.fetch().Also adds the missing
testscript (package.json) andtesttask (deno.json) for@fedify/expressso the suite actually runs undermise run test:node/test-each.Fixes #855
Test plan
mise run check-each expressdeno test --allow-all(packages/express)node --experimental-transform-types --test(packages/express)AI disclosure
This change was written with assistance from Claude Code (
claude-sonnet-5), reviewed and verified by me.