Test: the detectProject "cf package" test fails under `pnpm test` because pnpm's `vp` shim sets NODE_PATH
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 79/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- node.js, typescript, vite
Research direction
Start with the detectProject tests in tests/deploy.test.ts and the isPackageResolvable lookup described in the issue. Run the focused test through pnpm test, then compare it with the same test using the global vp or with NODE_PATH removed. Done means both Wrangler presence tests give consistent results based only on the test project's dependencies.
Written by the indexing model from the issue text.
Description
What happens
The detectProject test "does not mistake the separate cf package for Wrangler" fails when the suite runs through pnpm test, the command AGENTS.md documents:
FAIL tests/deploy.test.ts > detectProject > does not mistake the separate cf package for Wrangler
AssertionError: expected true to be false // Object.is equality
pnpm's bin shim for vp sets NODE_PATH, and the last entry is the workspace's node_modules/.pnpm/node_modules. Wrangler is installed there. detectProject finds Wrangler with createRequire(root).resolve("wrangler/package.json") (isPackageResolvable), and Node's resolver also searches NODE_PATH, so the lookup finds the workspace's Wrangler instead of the test project's. CI runs a global vp with no NODE_PATH, so it never sees the failure.
Repro
On current main, after pnpm install:
pnpm test tests/deploy.test.ts -t "does not mistake the separate cf package"
# Tests 1 failed
# same binary, NODE_PATH removed
env -u NODE_PATH node node_modules/.pnpm/vite-plus@*/node_modules/vite-plus/bin/vp \
test run tests/deploy.test.ts -t "does not mistake the separate cf package"
# Tests 1 passed
The mechanism without vinext:
// resolve.mjs
import { createRequire } from "node:module";
import path from "node:path";
const req = createRequire(path.join(process.argv[2], "package.json"));
try {
console.log(req.resolve("wrangler/package.json"));
} catch {
console.log("not resolvable");
}
mkdir -p global/wrangler project
echo '{"name":"wrangler"}' > global/wrangler/package.json
echo '{}' > project/package.json
node resolve.mjs project # not resolvable
NODE_PATH=$PWD/global node resolve.mjs project # …/global/wrangler/package.json
Expected
The Wrangler presence tests give the same result under pnpm test and a global vp, checking only the test project's own node_modules.
The positive companion test, "detects Wrangler independently of its executable shim", passes under the pnpm shim even without its fixture package, for the same reason.
- Dominant language
- TypeScript
- Stars
- 9.3k
- Forks
- 463
- Avg merge
- 22h 22m
- Merged PRs (30d)
- 502
Getting set up
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from cloudflare/vinext
-
Difficulty 2/5 1-3 hours Newbie friendliness 67/100
cloudflare/vinext#4592 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 83/100
cloudflare/vinext#4591 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 66/100
cloudflare/vinext#4589 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
cloudflare/vinext#4588 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
cloudflare/vinext#4586 ·
Maintainers usually reply within 1 day
All issues in cloudflare/vinext
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day
-
binding:python bug
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
Maintainers usually reply within 1 day
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
coollabsio/orbit#72 ·
Maintainers usually reply within 1 day
-
Bug
Difficulty 2/5 1-3 hours Newbie friendliness 67/100
Maintainers usually reply within 1 day
-
bug needs-triage potential-regression
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
aws/aws-sdk-js-v3#8408 ·
Maintainers usually reply within 1 day