async Fetch failing reloads the full page
Categories
(Core :: DOM: Networking, defect)
Tracking
()
Webcompat Priority | ? |
Tracking | Status | |
---|---|---|
firefox83 | --- | affected |
People
(Reporter: karlcow, Assigned: saschanaz)
References
()
Details
(Keywords: reproducible)
Attachments
(1 file)
270.12 KB,
image/png
|
Details |
- Go to https://www.bytenest.it/maia/?page=login#
- file a random username and password
- Click on Login
Expected:
An alert window with the message "Credenziali non valide"
Actual:
Page is reloaded.
- Working on Blink and WebKit.
- On Firefox it fails with "Uncaught (in promise) TypeError: NetworkError when attempting to fetch resource."
if (await authenticate(gql_login_info)) {
location.reload();
} else {
alert('Credenziali non valide');
form.find(':input').prop('disabled', false);
}
authenticate
calls fetchData
async function fetchData(request) {
let json;
//let response = await fetch('https://www.bytenest.it/maia-server-test/graphql-server.php', {
let response = await fetch(typeof api === 'undefined' ? 'http://maiaserver.lan/graphql-server.php' : api, {
method: 'POST',
headers,
body: JSON.stringify(request),
});
let contentType = response.headers.get('content-type');
if (contentType && contentType.includes('application/json')) {
json = await response.json();
} else throw new TypeError("Oops, we haven't got JSON!");
//if (loggedUserInfo?.level > 4)
console.log(json);
return json.errors ? null : json.data;
}
And fetchData
fails at
let response = await fetch(typeof api === 'undefined' ? 'http://maiaserver.lan/graphql-server.php' : api, {
method: 'POST',
headers,
body: JSON.stringify(request),
});
which reloads the page.
And so the else part of the if
is not executed.
Reporter | ||
Updated•4 years ago
|
Comment 1•4 years ago
|
||
If I break on all load events on that page, it shows:
handle (https://code.jquery.com/jquery-3.3.1.min.js:formatted#2010)
(a = y.handle) || (a = y.handle = function (t) {
> return 'undefined' != typeof w && w.event.triggered !== t.type ? w.event.dispatch.apply(e, arguments) : void 0
}),
l = (t = (t || '').match(M) || [
I can't actually make sense how this all works, but it seems to me that it's not the actual fetch failing that reloads the page, but some weird interaction in jQuery.
Jens, could you find someone with more DOM knowledge to take a look at this?
Comment 2•4 years ago
|
||
Hi Valentin, unfortunately I don't have any particular DOM knowledge, yet. :( Maybe you intended to ni? another Jens in Mozilla space?
Comment 3•4 years ago
|
||
(In reply to Valentin Gosu [:valentin] (he/him) from comment #1)
Jens, could you find someone with more DOM knowledge to take a look at this?
Oops 🙂
Comment 4•4 years ago
|
||
Hi Kagami, can you take a look here? Thank you!
Jens Stutte [:jstutte] I think you linked the wrong guy.
Updated•4 years ago
|
Assignee | ||
Updated•4 years ago
|
Assignee | ||
Comment 6•4 years ago
|
||
This is very weird, line 4072 alert('Credenziali non valide');
in maia_library_2.1.9.js
does run but the debugger never breaks at that line. Instead I had to add another breakpoint inside jQuery dispatch()
(Line 2089 of https://code.jquery.com/jquery-3.3.1.min.js
when prettified) to see the alert happens.
Assignee | ||
Comment 7•4 years ago
|
||
That said, the actual reload happens via HTMLFormElement::SubmitSubmission()
(which calls nsDocShell::InternalLoad
). The form submission happens on Gecko but not on Chrome. Trying to make a minimal repro...
Assignee | ||
Comment 8•4 years ago
|
||
Oops, form.find(':input').prop('disabled', true);
is the culprit! Disabled form submission button should not activate. I had been working on this, let's do this on bug 1659218.
Assignee | ||
Comment 9•4 years ago
|
||
Actually there is a blocker, maybe the specific form submission part can be done here.
Assignee | ||
Comment 10•4 years ago
|
||
Actually let's do this there
Description
•