Add fetch host allowlist support#395
Conversation
- Split blocked-host assertions from allowed-host dispatch checks - Use a fetch spy to avoid real network traffic in allowlisted cases - Keep allowlist behavior covered via the e2e script
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughRefactors fetch host tests: blocked-host cases moved to a real-fetch suite that asserts synchronous TypeError containing the blocked hostname; allowed-host cases are converted to a mocked-fetch suite that spies on Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@tests/built-ins/fetch/fetch-allowed-hosts.js`:
- Around line 34-81: The tests currently mock globalThis.fetch for every test,
which prevents exercising the allowlist code path; modify the suite so at least
one test (e.g., "allowed host proceeds to network request") calls the real fetch
against an allowlisted host instead of the mocked spy: keep the spy-based
assertions for dispatch shape in other tests, but in that positive-path test
call spy.mockRestore() (or temporarily avoid mocking) before invoking
globalThis.fetch("http://0.0.0.0:1/") so ValidateHost runs, await the real
response and assert the request completed (and optionally that spy was not
used), then re-establish the mock for the remaining tests. Ensure you reference
and update the existing spy variable and the named test to locate the change.
🪄 Autofix (Beta)
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: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 7cdb1518-8619-44b7-b9fb-aae0c880740c
📒 Files selected for processing (1)
tests/built-ins/fetch/fetch-allowed-hosts.js
Suite Timing
Measured on ubuntu-latest x64. |
Benchmark Results386 benchmarks Interpreted: 🟢 328 improved · 🔴 12 regressed · 46 unchanged · avg +7.5% arraybuffer.js — Interp: 🟢 12, 🔴 1, 1 unch. · avg +8.0% · Bytecode: 🟢 11, 3 unch. · avg +7.0%
arrays.js — Interp: 🟢 18, 1 unch. · avg +8.7% · Bytecode: 🟢 19 · avg +10.1%
async-await.js — Interp: 🟢 5, 1 unch. · avg +7.4% · Bytecode: 🟢 5, 1 unch. · avg +4.2%
base64.js — Interp: 🟢 8, 2 unch. · avg +9.4% · Bytecode: 🟢 9, 1 unch. · avg +11.6%
classes.js — Interp: 🟢 31 · avg +8.1% · Bytecode: 🟢 20, 11 unch. · avg +5.3%
closures.js — Interp: 🟢 11 · avg +11.1% · Bytecode: 🟢 11 · avg +10.8%
collections.js — Interp: 🟢 12 · avg +11.4% · Bytecode: 🟢 12 · avg +12.5%
csv.js — Interp: 🟢 13 · avg +11.1% · Bytecode: 🟢 13 · avg +8.1%
destructuring.js — Interp: 🟢 22 · avg +8.0% · Bytecode: 🟢 21, 1 unch. · avg +8.3%
fibonacci.js — Interp: 🟢 8 · avg +9.1% · Bytecode: 🟢 8 · avg +14.1%
float16array.js — Interp: 🟢 25, 🔴 4, 3 unch. · avg +4.4% · Bytecode: 🟢 27, 🔴 4, 1 unch. · avg +6.3%
for-of.js — Interp: 🟢 7 · avg +13.0% · Bytecode: 🟢 7 · avg +13.3%
helpers/bench-module.js — Interp: 0 · Bytecode: 0
iterators.js — Interp: 🟢 25, 🔴 1, 16 unch. · avg +3.7% · Bytecode: 🟢 25, 🔴 2, 15 unch. · avg +3.5%
json.js — Interp: 🟢 19, 1 unch. · avg +11.7% · Bytecode: 🟢 19, 1 unch. · avg +11.5%
jsx.jsx — Interp: 🟢 21 · avg +11.2% · Bytecode: 🟢 21 · avg +9.0%
modules.js — Interp: 🟢 9 · avg +8.6% · Bytecode: 🟢 9 · avg +16.4%
numbers.js — Interp: 🟢 11 · avg +11.3% · Bytecode: 🟢 8, 🔴 2, 1 unch. · avg +4.5%
objects.js — Interp: 🟢 7 · avg +10.1% · Bytecode: 🟢 7 · avg +10.9%
promises.js — Interp: 🟢 9, 3 unch. · avg +7.0% · Bytecode: 🟢 12 · avg +10.7%
regexp.js — Interp: 🟢 11 · avg +11.3% · Bytecode: 🟢 11 · avg +8.5%
strings.js — Interp: 🟢 13, 6 unch. · avg +4.8% · Bytecode: 🟢 19 · avg +27.6%
tsv.js — Interp: 🟢 9 · avg +11.7% · Bytecode: 🟢 9 · avg +10.4%
typed-arrays.js — Interp: 🟢 15, 🔴 2, 5 unch. · avg +6.9% · Bytecode: 🟢 10, 🔴 7, 5 unch. · avg +1.1%
uint8array-encoding.js — Interp: 🟢 7, 🔴 4, 7 unch. · avg -5.4% · Bytecode: 🟢 7, 🔴 8, 3 unch. · avg -7.9%
Measured on ubuntu-latest x64. Benchmark ranges compare cached main-branch min/max ops/sec with the PR run; overlapping ranges are treated as unchanged noise. Percentage deltas are secondary context. |
Address CodeRabbit review feedback on PR #395: the mocked allowed-host tests verify dispatch shape but bypass ValidateHost, so an allowlist acceptance regression could slip through. Add a single real-fetch test against 0.0.0.0:1 (allowlisted, refuses instantly on loopback) so the positive path of ValidateHost is exercised without reintroducing the network hang. Co-Authored-By: Claude Opus 4 <noreply@anthropic.com>
Fixes fetch on JS test suite to now mock the fetch call as otherwise as dealt with a performance regression