Skip to content

http: support FetchEvent API

Rodrigo Muino Tomonari requested to merge github/fork/Qard/server-fetch-event into main

This is an experiment to see if it would be reasonable to support the FetchEvent interface on an http server. My thinking was to start with a named event directly on the server for the moment and then extend that with more ServiceWorker style thread isolation as a layer on top of that later. Could also consider a separate createFetchServer factory or modifying the existing createServer to mode switch by function parameter count. Just wanted to share my little MVP first though to see what people think and discuss direction or if we want to pursue this at all. 🤔

Note that this is still very much an experiment so probably lots of bugs and usability issues. Also no docs yet, you can see the test for an example of how it works. Just want to get feedback before I put more work into it.

I was also thinking of pulling out the Handle Fetch part of the spec to something that could be used both for processing incoming HTTP requests and also put it on http.Agent to allow ServiceWorker style request mocking or caching. Could be a useful tool.

cc @nodejs/http @nodejs/undici @nodejs/whatwg-stream

Merge request reports

Loading