next.js
3d72eef0 - [image-optimizer] Add request cancellation support when using nsio (#102405)

Commit
8 days ago
[image-optimizer] Add request cancellation support when using nsio (#102405) One very nice feature of [nsio](https://github.com/vercel-labs/next-safe-image-optimization) (that sharp doesn't have) is that since we can easily and safely SIGKILL the worker processes (or terminate the wasm threads), we can easily support request cancellation. This is a little complicated because the request cache and batching/coalescing need to be aware of the abort signal. ## Security??? IDK. There is a slight tradeoff here: If a request is *nearly* done, then an abort might cause a bunch of work (e.g. a few 100ms of CPU time) to get wasted. Claude thinks this could be used by an attacker to waste CPU (create and then cancel a bunch of requests right before they'd complete), but I don't think it's a new or novel problem, and I don't think this makes that problem significantly worse. In some ways, cancelling work earlier might improve things. If we think cancellation introduces these problems, we could expose it only behind an experimental option.
Author
bgw bgw
Parents
Loading