Propagating Deadlines from VIN Form Submit to NHTSA Proxy Without Orphaned Work
A free VIN form that abandons a slow decode still often leaves a DecodeVinValues call running behind the proxy. The user navigated away, a client timeout fired, or a newer submit superseded the old one -- yet the edge kept waiting on NHTSA and burned quota on a response nobody will display. Per-request budgets (covered elsewhere) decide how long a serverless handler may wait. This post is about…
Orphaned work occurs when deadlines only exist at one layer of the system, leading to wasted quota on unshown data. This post explains how to propagate deadlines from a VIN form submit through a Backend for Frontend (BFF) to avoid such orphans. The goal is a single submit, single deadline, and cancellable fetch chain. The issue arises when Browser AbortController aborts the BFF fetch, but the BFF continues calling DecodeVinValues without ignoring the abort signal.
A hard setTimeout returning a 504 status while the NHTSA promise is pending also contributes to orphaned work. When the user navigates away, a client timeout or a newer submit supersedes the old one, all while the edge keeps waiting on NHTSA and burning quota. To prevent this, mint a deadline at submit time, pass the signal to the BFF, and abort on unmount, navigation, or a superseding submit.
Create a controller when the user submits, attach a wall-clock deadline, pass the signal to fetchProxy, and abort on unmount, navigation, or superseding submit. The DecodeSubmitOpts type includes vin, deadlineMs, and fetchProxy function. The submitDecodeWithDeadline function creates an AbortController, sets a timer, and returns a promise and abort function.
The supersedePrevious function aborts the previous handle before minting a new one. The proxyDecodeVin function merges inbound and budget signals, checks if the signal is aborted, and returns the result of decodeVinValues.
Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.