I have noticed that in fact it's not related to the PWA application and the error doesn't always occur immediately, sometimes it occurs only the second or third time I click on the back button.
And I get this error in the console.
Uncaught (in Promise)
This error is related to this code in livewire.js on line 574.
async function sendRequestToServer() {
prepareCommitPayloads();
await queueNewRequestAttemptsWhile(async () => {
let [payload, handleSuccess, handleFailure] = compileCommitPayloads();
let options = {
method: "POST",
body: JSON.stringify({
_token: getCsrfToken(),
components: payload
}),
headers: {
"Content-type": "application/json",
"X-Livewire": ""
}
};
let succeedCallbacks = [];
let failCallbacks = [];
let respondCallbacks = [];
let succeed = (fwd) => succeedCallbacks.forEach((i) => i(fwd));
let fail = (fwd) => failCallbacks.forEach((i) => i(fwd));
let respond = (fwd) => respondCallbacks.forEach((i) => i(fwd));
let finishProfile = trigger("request.profile", options);
trigger("request", {
url: updateUri,
options,
payload: options.body,
respond: (i) => respondCallbacks.push(i),
succeed: (i) => succeedCallbacks.push(i),
fail: (i) => failCallbacks.push(i)
});
let response = await fetch(updateUri, options);
let mutableObject = {
status: response.status,
response
};
respond(mutableObject);
response = mutableObject.response;
let content = await response.text();
if (!response.ok) {
finishProfile({ content: "{}", failed: true });
let preventDefault = false;
handleFailure();
fail({
status: response.status,
content,
preventDefault: () => preventDefault = true
});
if (preventDefault)
return;
if (response.status === 419) {
handlePageExpiry();
}
return showFailureModal(content);
}
if (response.redirected) {
window.location.href = response.url;
}
if (contentIsFromDump(content)) {
[dump, content] = splitDumpFromContent(content);
showHtmlModal(dump);
finishProfile({ content: "{}", failed: true });
} else {
finishProfile({ content, failed: false });
}
let { components: components2 } = JSON.parse(content);
handleSuccess(components2);
succeed({ status: response.status, json: JSON.parse(content) });
});
}
I don't know if it's a bug in the new Livewire version or if I only don't do something well.