Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 14 additions & 5 deletions debug_toolbar/static/debug_toolbar/js/toolbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -321,16 +321,25 @@ const djdt = {

const origFetch = window.fetch;
window.fetch = function (...args) {
// Heads up! Before modifying this code, please be aware of the
// possible unhandled errors that might arise from changing this.
// For details, see
// https://github.com/django-commons/django-debug-toolbar/pull/2100
const promise = origFetch.apply(this, args);
promise.then((response) => {
return promise.then((response) => {
if (response.headers.get("djdt-store-id") !== null) {
handleAjaxResponse(response.headers.get("djdt-store-id"));
try {
handleAjaxResponse(
response.headers.get("djdt-store-id")
);
} catch (err) {
throw new Error(
`A(n) "${err.name}" happened within ``django-debug-toolbar: ${err.message}`
);
}
}
// Don't resolve the response via .json(). Instead
// continue to return it to allow the caller to consume as needed.
return response;
});
return promise;
};
},
cookie: {
Expand Down
1 change: 1 addition & 0 deletions docs/changes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ Pending
* Added a Makefile target (``make help``) to get a quick overview
of each target.
* Avoided reinitializing the staticfiles storage during instrumentation.
* Fix for exception-unhandled "forked" Promise chain in rebound window.fetch

5.0.1 (2025-01-13)
------------------
Expand Down