Fetch Upload Progress Demo - Online Track XHR & Fetch
See how to implement file upload progress using both fetch and XHR. Realβtime bar and code snippets for your project.
UD5 Toolkit
Explore how to cancel fetch requests, handle timeouts, and manage event listeners with the AbortController API.
Start a slow network request and cancel it before it completes.
Set a timeout using AbortSignal.timeout() β the request auto-cancels when the deadline passes.
Launch 3 concurrent requests sharing one AbortController. Cancel them all at once.
Use { signal: controller.signal } in addEventListener to cleanly remove listeners.
fetch() requests, event listeners, streams, or custom async tasks. It provides an AbortSignal object that you pass to abortable APIs. When you call controller.abort(), all operations linked to that signal are immediately cancelled. This is far cleaner than older patterns like manually tracking and rejecting promises.
Pass the signal property into the fetch options:
const controller = new AbortController();
fetch('https://api.example.com/data', { signal: controller.signal })
.then(res => res.json())
.catch(err => {
if (err.name === 'AbortError') {
console.log('Request was cancelled');
}
});
// Later, cancel the request:
controller.abort();
The fetch promise rejects with an AbortError DOMException when aborted.
AbortSignal.timeout(ms) is a static method (added in 2022) that creates a signal which automatically aborts after a specified number of milliseconds. This eliminates the need to manually create a controller and set up a setTimeout to call .abort(). Example:
// Auto-cancel after 3 seconds
fetch(url, { signal: AbortSignal.timeout(3000) });
Supported in Chrome 103+, Firefox 100+, Safari 16+.
signal to multiple fetch() calls (or other abortable operations). A single controller.abort() will cancel all of them at once. This is incredibly useful for cleanup in SPA frameworks β for example, aborting all in-flight requests when a component unmounts or a user navigates away. See Scene 3 above for a live demo.
signal option to addEventListener:
const controller = new AbortController();
element.addEventListener('click', handleClick, { signal: controller.signal });
// Later β removes ALL listeners linked to this signal:
controller.abort();
This is cleaner than removeEventListener because you don't need to keep a reference to the handler function. One abort() call can remove dozens of listeners at once. See Scene 4 above for a live demo.
DOMException whose name property is 'AbortError'. You should always check for this in your catch blocks to distinguish intentional cancellations from actual network failures:
fetch(url, { signal })
.catch(err => {
if (err.name === 'AbortError') {
// Intentional β do nothing or clean up
} else {
// Real error β show user a message
}
});
AbortError is not a real error β it indicates deliberate cancellation, not a problem.
AbortSignal.timeout().AbortSignal.timeout() static method is supported in Chrome 103+, Firefox 100+, and Safari 16+. The signal option in addEventListener has the same broad support as AbortController itself. For legacy browsers, a polyfill is available. In 2025, you can confidently use AbortController in production without transpilation for 98%+ of users.
signal.aborted (a boolean property) to check whether the signal has already been aborted:
if (controller.signal.aborted) {
console.log('Already aborted, skipping operation.');
} else {
fetch(url, { signal: controller.signal });
}
You can also listen for the abort event: signal.addEventListener('abort', callback).
controller.abort() is called, the signal is permanently aborted and cannot be reset. If you need to start a new batch of abortable operations, you must create a new AbortController instance. This is by design β it prevents accidentally reusing a stale signal. Each logical "group" of cancellable operations should get its own AbortController.
See how to implement file upload progress using both fetch and XHR. Realβtime bar and code snippets for your project.
Load an image and see the exact events fired (load, error, abort). Monitor progress. Dev helper.
Paste your email subject and body. The tool highlights common spam trigger words and gives a risk score. Improve inbox placement.
Enter a URL and see its favicon at all standard sizes. Check if it's properly defined. SEO basic check.
Drop files onto a zone and see a preview with name, size, and type. Copy the JavaScript pattern for your site.
See how your browser renders emojis from different Unicode versions. Detect gaps in your system's emoji font support.
Paste HTML code and extract all comments or remove them completely. See a list of comments found. Clean your markup.
Enter a URL and get a list of all images that fail to load (404, CORS). A simple asset audit tool. Runs in your browser.
Convert between emoji characters and their shortcode representations (e.g., :tada: to π). Supports Slack and GitHub styles.
Enter an emoji or browse to see which Unicode version introduced it and whether older OS versions might fail.
Pick a color palette and the tool shows sample images that match it. Great for moodboard and brand inspiration. Static dataset.
View every standard emoji in a searchable grid. Hover to see a larger preview. Click to copy. Updated with Unicode 16.
Generate a printable pace band for ultra distances with mile/km splits and cumulative time. Adjust for terrain.
Select a heading font and get recommended body font pairings. Live preview with sample text. Copy the CSS import links.
Paste a list of words or lines and convert all to UPPERCASE or lowercase at once. Also supports title case.
Transform regular text into the mocking SpongeBobβstyle alternating case. Copy and paste for hilarious effect.
Convert running shoe sizes between US (men/women), UK, EU, and centimeters. Also includes brand-specific fit notes (general guide).
Quiz yourself on element symbols, names, and atomic numbers. Multiple modes: element to symbol, symbol to element. Score tracking. Great for chemistry students.
Enter a URL and see its CORS headers. Understand why a fetch fails. Check preflight responses. Clientβside debugger.
Paste a cURL command and convert it to a fetch() call in JavaScript, Python requests, or Go net/http. Save time.
Translate text into semaphore flag positions and decode semaphore back to letters. Interactive animated flags. For scouts and maritime fans.