Fetch Event

The event type for HTTP requests dispatched to a Worker (i.e theObject passed through as 'fetch' in addEventListener('fetch', event => {…})).


  • type: The type of event. Always = fetch.

  • request: A Request Object that represents the request triggering FetchEvent.


  • passThroughOnException: Cause the script to “fail open” unhandled exceptions. Instead of returning a runtime error response, the runtime proxies the request to its destination. To prevent JavaScript errors from causing entire requests to fail on uncaught exceptions, passThroughOnException causes the worker to act as if the exception wasn’t there. This allows you to yield control to your origin server.
  • respondWith: Intercept the request and send a custom response _ If an event handler does not call respondWith(), the runtime delivers the event to the next registered event handler. _ If no event handler calls respondWith(), the runtime proxies the request to its destination.
  • waitUntil: Extend the lifetime of the event. Use this method to notify the runtime to wait for tasks, such as streaming and caching, that run longer than the usual time it takes to send a response. This is good for handling logging and analytics to third-party services, where you don’t want to block the response.

To learn more about using the FetchEvent, see FetchEvent LifeCycle.