Closed Bug 1671332 Opened 4 years ago Closed 4 years ago

async Fetch failing reloads the full page

Categories

(Core :: DOM: Networking, defect)

Firefox 83
Desktop
Linux
defect

Tracking

()

RESOLVED DUPLICATE of bug 1659218
Webcompat Priority ?
Tracking Status
firefox83 --- affected

People

(Reporter: karlcow, Assigned: saschanaz)

References

()

Details

(Keywords: reproducible)

Attachments

(1 file)

  1. Go to https://www.bytenest.it/maia/?page=login#
  2. file a random username and password
  3. 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.

Hardware: Unspecified → Desktop
Version: unspecified → Firefox 83

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?

Component: Networking → DOM: Networking
Flags: needinfo?(mozilla)
Keywords: reproducible

Hi Valentin, unfortunately I don't have any particular DOM knowledge, yet. :( Maybe you intended to ni? another Jens in Mozilla space?

Flags: needinfo?(mozilla) → needinfo?(valentin.gosu)

(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 🙂

Flags: needinfo?(valentin.gosu) → needinfo?(jstutte)

Hi Kagami, can you take a look here? Thank you!

Flags: needinfo?(jstutte) → needinfo?(kagami)

Jens Stutte [:jstutte] I think you linked the wrong guy.

Flags: needinfo?(kagami)
Flags: needinfo?(krosylight)
Assignee: nobody → krosylight
Flags: needinfo?(krosylight)

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.

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...

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.

Status: NEW → RESOLVED
Closed: 4 years ago
Resolution: --- → DUPLICATE

Actually there is a blocker, maybe the specific form submission part can be done here.

Status: RESOLVED → REOPENED
Resolution: DUPLICATE → ---

Actually let's do this there

Status: REOPENED → RESOLVED
Closed: 4 years ago4 years ago
Resolution: --- → DUPLICATE
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: