Skip to content

Conversation

@FelixVaughan
Copy link
Contributor

@FelixVaughan FelixVaughan commented Nov 14, 2025

Rationale

Addresses #4663

Changes/Fixes

  • Check URL exclusions before snapshot lookup in SnapshotAgent.dispatch()
  • Instantiate real HTTP agent in playback mode when excludeUrls is configured
  • Route excluded URLs to real agent instead of returning "No snapshot found" error
  • Expose SnapshotRecorder.isUrlExcluded() for early URL exclusion checks
  • Add test coverage for playback mode with excluded URLs

Status

@codecov-commenter
Copy link

codecov-commenter commented Nov 14, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 92.84%. Comparing base (fdafc2a) to head (f02a363).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4670      +/-   ##
==========================================
- Coverage   92.86%   92.84%   -0.02%     
==========================================
  Files         107      107              
  Lines       33499    33515      +16     
==========================================
+ Hits        31108    31117       +9     
- Misses       2391     2398       +7     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Member

@metcoder95 metcoder95 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tests seems not happy

return this[kRealAgent].dispatch(opts, handler)
}
// If no real agent in playback mode, this is a configuration error
const error = new UndiciError('Cannot pass through excluded URL: no real agent available')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure we should throw, maybe just go with no-op?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, my thought was since this would likely be because of misconfiguration, we would want to fail loudly rather than have the request swallowed. Thoughts?

Yeah I noticed those as well. My thinking was these were unrelated but can we confirm?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For a configuration error, it will be better to throw at the moment the agent is being instantiated, as the configuration mismatch should be identified and advertised early, usually when at runtime is already late to take further action.

If we can fail early, the better, otherwise a warning will be better.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added some constructor logic in an earlier commit ensuring an agent is created if needed so we should be good. Removed the error block

@mcollina
Copy link
Member

tests are still not happy

@FelixVaughan
Copy link
Contributor Author

FelixVaughan commented Nov 24, 2025

@mcollina from what I can see, the remaining tests seem unrelated

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