canjs / can-zone

A context for tracking asynchronous activity in JavaScript applications.
https://v4.canjs.com/doc/can-zone.html
MIT License
92 stars 4 forks source link

Support fetch in zones, and create a fetch zone to capture/replay responses like XHR zone #198

Closed bmomberger-bitovi closed 1 year ago

bmomberger-bitovi commented 1 year ago

Fetch is wrapped in the zone registry because, even though it should be able to take advantage of Promise.prototype.then(), zones do not wait properly unless fetch is wrapped and adds a wait.

In addiition, a fetch zone is added that captures network requests and responses exactly like how the XHR zone does. The caches are kept separate, so the fetch cache is global.FETCH_CACHE to distinguish it from global.XHR_CACHE