Closed Bug 1919479 Opened 2 years ago Closed 1 year ago

fedex.com - Sometimes on login will pop a login dialog you can dismiss

Categories

(Web Compatibility :: Site Reports, defect, P1)

Firefox 132
Desktop
Windows 10

Tracking

(Webcompat Priority:P1, Webcompat Score:6, firefox138 affected, firefox143 affected, firefox144 fixed)

RESOLVED WORKSFORME
Webcompat Priority P1
Webcompat Score 6
Tracking Status
firefox138 --- affected
firefox143 --- affected
firefox144 --- fixed

People

(Reporter: ctanase, Unassigned)

References

()

Details

(4 keywords, Whiteboard: [webcompat-source:product][webcompat:sightline])

User Story

platform:windows,mac,linux,android
impact:annoyance
configuration:general
affects:all
branch:release
diagnosis-team:dom
outreach-contact-date:2025-04-22

Attachments

(4 files, 1 obsolete file)

Environment:
Operating system: Windows 11/10
Firefox version: Firefox 130.0 (release)/132

Preconditions:

  • Clean profile
  • Account needed

Steps to reproduce: (updated)

  1. Go to https://www.fedex.com/en-us/home.html
  2. Click "Sign Up or Log in" button.
  3. Click on "SIGN UP /LOG IN".
  4. Enter your credentials and hit "LOG IN".

Expected Behavior:
Remain logged in.

Actual Behavior:
Logs out from the account. (EDIT: login dialog displayed, check attachment)

Notes:

  • Reproducible on the latest Firefox Release and Nightly
  • Reproducible regardless of the ETP setting
  • Works as expected using Chrome

Created from webcompat-user-report:e543ff96-d6a3-4036-83a1-b8f8465c6981

This is working for my account. Hello Calin, wonder if it's still reproducible for you?

Flags: needinfo?(ctanase)
Attached video login.mp4 —

Weird, with the steps to reproduce I can't reproduce the issue (accessing the login page directly). But if I go manually from https://www.fedex.com/en-us/home.html I can reproduce the issue.

Tried also with VPN pointing to US to make sure there's not some weird redirects happening due to my location, same behavior.

Flags: needinfo?(ctanase)
Severity: -- → S2
User Story: (updated)
Priority: -- → P1

I see a 401 error when the page does a GET to https://api.fedex.com/user/v4/login/validate?
The response is:

{
    "error": "invalid_request",
    "error_description": "validation error"
}

I also see Akamai related errors on OPTIONS request:

Access Denied
You don't have permission to access "http://api.fedex.com/user/v4/login/validate?" on this server.

Reference #18.c62b2117.1728311065.55bde000

https://errors.edgesuite.net/18.c62b2117.1728311065.55bde000

I tried Firefox release and I was able to get logged in but it didn't stay that way for long. After a short while I got the following from user/v4/login/validate?

{"transactionId":"a928aa3a-2841-4ead-be48-8db5f2ad35ba",
"errors":[{"code":"LOGIN.REAUTHENTICATE.ERROR","message":"Your session is expired. Please enter your user ID and password to log in again."}]}

I tried to reproduce it again in Firefox release and now it does stay logged in.

I'm now not able to reproduce this in Nightly anymore. Calin can you still reproduce?

Flags: needinfo?(ctanase)
See Also: → akamai-blocks

Works for me as well now, no longer reproduces on Release (131.0.3) and Nightly (133.0a1 - 2024-10-21).

Flags: needinfo?(ctanase)

I can repro now in 133 Nightly 10/9. Login, and it self-refreshes and I'm logged out. (Ditto if I click on Fedex in the upper left)
I have a profile: https://share.firefox.dev/4fgTDm7

Can you repro now?

Flags: needinfo?(jmuizelaar)

No

Flags: needinfo?(jmuizelaar)

Happens with or without ETP enabled. I'll see the personalized screen, then it will refresh and I'm logged out.
Clearing cookies has no impact.

UA switching to Chrome 128/windows doesn't help

Attached file fedex.console.txt —

Console logs for a login and auto-logout

In the profile, the load of https://www.fedex.com/en-us/home.html at 15.520s is where it loads the non-logged-in page.
If I manually load https://www.fedex.com/en-us/logged-in-home.html (which loads as part of this, before it reloads to en-us/home.html), it shows me my logged-in home page and my name (so I'm still logged in), but immediately redirects me to https://www.fedex.com/en-us/home.html

I've sent network logs to @dschubert

User Story: (updated)

(In reply to Jeff Muizelaar [:jrmuizel] from comment #4)

I also see Akamai related errors on OPTIONS request:

Access Denied
You don't have permission to access "http://api.fedex.com/user/v4/login/validate?" on this server.

Reference #18.c62b2117.1728311065.55bde000

https://errors.edgesuite.net/18.c62b2117.1728311065.55bde000

I looked at this some more and it looks like OPTIONS request is still giving a 200 response code and sending the appropriate headers. I think Chrome might actually be getting the same result by it doesn't show the response data in network inspector. Because of this, I think this is unlikely related to the problem.

See Also: akamai-blocks →

I also verified that this also happens in 132 Release

Note: userids are case-sensitive! :-)

We need to delve into the code for the site and see what code is triggering the reload-to-not-logged-in page. This really doesn't appear to be networking. I'm happy to help trying to debug this since I can repro, but I'm not an expert at debugging live pages.

User Story: (updated)

Check my comment 21 please, the analysis in this comment is wrong

So I don't have strong evidences to prove this, however I do think that I get a sensible idea about what's going on there.

When the user is considered not-logged in, it's because the response of this ajax request shows the user is not logged in.

  doAPIisLoggedIn: function () {
    var b = void 0 != FDX.SESSION.sessionTimeout ? FDX.SESSION.sessionTimeout : 30,
    w = 'true' == FDX.DATALAYER.page.pageInfo.useForgeRockCookie ?
    '/user/v4/login/validate' : '/user/v2/login',
    r = JSON.parse(sessionStorage.getItem('loginDataStorage')),
    a = void 0 != r.token ? r.token : r.access_token;
    $.ajax(......,
      success: function (q) {
        FDX.CLIENTLOGIN.isLoggedInResponse = q;
      }

I believe JSON.parse(sessionStorage.getItem('loginDataStorage')) is the token that is used to validate the login status of this user.

Then, how this token is updated is via this method

    tokenUpdate: function() {
        if (sessionStorage.getItem("loginDataStorage")) {
           // bla bla bla
        } else
           // bla bla
    },

According to the debugger, Fedex calls this method via a chain of setTimeout upon page load. These two methods are in the same javascript file.

In Chrome, this tokenUpdate is always called before doAPIisLoggedIn, however it's not the case in Firefox. We usually execute doAPIisLoggedIn first before tokenUpdate. So this difference sound like a plausible cause to me.

I am leaning towards that this is a site-bug. Randell, do you know if there's a way that we can disable the setTimeout optimization we did during page load, so that maybe we can test this hypothesis? If not, I think we can label this as a site-bug for now.

Flags: needinfo?(rjesup)

Looks like that's dom.timeout.defer_during_load, but toggling this pref is still not enough to make tokenUpdate to run first in Firefox. I looked this a bit more and got another hypothesis (more confidences with this one), still relates to the ordering.

The site first have this method

doAPIisLoggedIn = function() {
  xhr = new XHRHttpRequest() 
  xhr.success = function() {
    // stores the user info into session storage
  }
  xhr.error = function() {
    // navigate to home.html
  }
}

It also have two inline scripts for doing user login.

<script src="/etc.clientlibs/clientlibs/fedex/secureCheck.min.61a61c4e87a60f1f9c2d2d94643daf08.js"></script>
<script src="/etc.clientlibs/fedex-core/clientlibs/clientlib-dependencies.min.683b0c4738d93b4ebc646dd3d149b532.js"></script>

In secureCheck.min, it does something like

xhr = new XHRHttpRequest() // get the endpoints to login the user
xhr.success = function() {
     doAPIisLoggedIn() 
}

In clientlib-dependencies.min, it does something like

xhr = new XHRHttpRequest() // et the endpoints to login the user

xhr.success = function() {
     getOAuthToken(); 
}

getOAuthToken = function() {
  xhr = new XHRHttpRequest() 
  xhr.success = function() {
    doAPIisLoggedIn()
  }
}

The site expects getOAuthToken() to finish first, so that it'll get a new token for doAPIisLoggedIn() to use and it'll success (it does happen some time in Firefox).

However, more often the first doAPIisLoggedIn() (triggered by secureCheck.min) finished first with an error (due to incorrect auth token I suspect). And upon error handling, it'll do a navigation to home.html hence we didn't get a chance to execute the getOAuthToken(). So the logging in didn't get completed.

So this still looks like a site bug to me.

Flags: needinfo?(rjesup)
Whiteboard: [webcompat-source:product] → [webcompat-source:product][webcompat:sightline]
Webcompat Priority: --- → P1

So, are there any possible site patches possible? Obviously we can do outreach as well

Webcompat Score: --- → 10

So I can't fully reproduce this anymore, though of course it's a timing/race issue.

Sometimes (not always), after I log in, it refreshes and pops a dialog (yes) that asks for user and password again (but you're still logged in; canceling it leaves you that way). It doesn't appear if defer_during_load is false. However, it doesn't always show up if it's true; sometimes it refreshes and we just get to the normal logged-in state. In a different (test) profile, I don't see the dialog at all.

So the 'bad' case (for me at least) seems to be much less bad. I just have to cancel the dialog, and it doesn't happen reliably.

I have a patch that will allow us to disable defer_during_load for specific sites/urls. I'll put that up.

(In reply to Randell Jesup [:jesup] (needinfo me) from comment #23)

So I can't fully reproduce this anymore, though of course it's a timing/race issue.

Sometimes (not always), after I log in, it refreshes and pops a dialog (yes) that asks for user and password again (but you're still logged in; canceling it leaves you that way). It doesn't appear if defer_during_load is false. However, it doesn't always show up if it's true; sometimes it refreshes and we just get to the normal logged-in state. In a different (test) profile, I don't see the dialog at all.

I can confirm, the pop-up dialog appears.

Notes:

I don't think we need to diagnosis this again? Ideally the site fixes this...

(In reply to Sean Feng [:sefeng] from comment #26)

I don't think we need to diagnosis this again?

Looks like needs-diagnosis was added back in comment 24 which was just a day or two before the patch (referenced in comment 25) landed. If that patch doesn't help here, then further needs-diagnosis investigation might be needed.

Calin, would you mind retesting? This should hopefully be fixed in very-recent nightlies now (as of https://hg.mozilla.org/mozilla-central/rev/53e26900ff5d which landed 2 days ago)

Flags: needinfo?(ctanase)

retested with nightly, fixed (I would always see problems before).

Status: NEW → RESOLVED
Closed: 1 year ago
Resolution: --- → FIXED

Well, it seemed to work the 1st time I've tried. I tested again with 138.0a1 (2025-03-30) on clean and on a new profile and the issue still reproduces, the login dialog still appears. Steps to reproduce:

  1. Go to https://www.fedex.com/en-us/home.html
  2. Click "Sign Up or Log in" button.
  3. Click on "SIGN UP /LOG IN".
  4. Enter your credentials and hit "LOG IN".

I've updated the steps in the description as well.

Flags: needinfo?(ctanase)
Status: RESOLVED → REOPENED
Resolution: FIXED → ---

My comment 21 showed another analysis such that the site depends on the ordering of two independent XHR requests. I guess Randell's fix could impact it in certain conditions, but yeah it's likely that this isn't fully fixed.

In a new profile, I do see some issues still. Sigh. The defer thing does help some people, so I'll keep that for now. And the failure case is no longer totally broken, it pops up a spurious dialog you can close, and you're still logged in.

I doubt there's a lot more we can do without adding site-specific hacks into the code. Perhaps it can be site-patched, maybe. More likely outreach is needed.

Flags: needinfo?(mbalfanz)

Since the failure case is dismissable pop-up, downgrade to annoyance

User Story: (updated)
Summary: fedex.com - Does not remain logged in → fedex.com - Sometimes on login will pop a login dialog you can dismiss
Webcompat Score: 10 → 7

The issue is still reproducible

Tested with:

Browser / Version: Firefox Nightly 139.0a1 (2025-04-21) (64-bit)
Operating System: Windows 10 PRO x64

I made an attempt to contact them, but I think we should move on with our investigation.

User Story: (updated)
Flags: needinfo?(mbalfanz)

So...I was able to reproduce this fairly often until...some point yesterday? now the login behavior works for me repeatedly.

Raul, do you mind giving this a another shot? (Sorry if you are asked too often about this!)

Flags: needinfo?(rbucata)

This reproduces on the latest Nightly (see attachment). I don't know if it is relevant to do it in a clean profile, so that the "Save credentials" pop-up is also triggered?

Tested with:

Browser / Version: Firefox Nightly 140.0a1 (2025-05-08) (64-bit)
Operating System: Windows 10 PRO x64

Flags: needinfo?(rbucata)
Attached image Nightly 140 —

Could we try to figure out why the request ordering is more stable in Chrome?

Flags: needinfo?(sefeng)

I found a few more things.

I am fairly certain that this is a site bug because I was able to reproduce this in Chrome with their devtools open.

I think I've found the root cause of it.

First, they have an Ajax request that fetches the url of their API endpoints.

  getLogin: function () {
      $.when($.ajax(encodeURI(w))).then(
        function (r, a, q) {
          'string' == typeof r &&
          (r = JSON.parse(r));
          FDX.SESSION.apiURL = r.apigURL;
        }
      )
  }

FDX.SESSION.apiURL is really important because it's a empty string by default, and subsequent login related requests will need to use it.

Then there's another Ajax request

  doAPIisLoggedIn: function () {
    $.ajax({
          type: 'GET',
          url: 'https://' + FDX.SESSION.apiURL + w,
      },
      success: function (q) {},
      error: function (q, t, p) {
        FDX.LOGIN.loginFailedMessage = 'Sorry. Something went wrong......';
        FDX.LOGIN.showErrorMessage();
        FDX.CLIENTLOGIN.destroyUserSession();
      }
    })
  },

^ this ajax request needs FDX.SESSION.apiURL to be set, otherwise it'll be an error and FDX.CLIENTLOGIN.destroyUserSession() will be called that triggers the navigation to home.html, hence that dialog.

And doAPIisLoggedIn() is triggered by the success handler of another Ajax request. I am fairly certain these async requests are causing us the trouble here.

I was able to fix this by overriding doAPIisLoggedIn to force it to use api.fedex.com when FDX.SESSION.apiURL is an empty string.

Flags: needinfo?(sefeng)

Speaking of intervention...Maybe we can override that doAPIisLoggedIn() method, to do a hacky fix like

doAPIisLoggedIn: function () {
    const tempURL = !FDX.SESSION.apiURL ? "api.fedex.com" : FDX.SESSION.apiURL;
    $.ajax({
          type: 'GET',
          url: 'https://' + tempURL + w,
      },
      success: function (q) {},
      error: function (q, t, p) {
        FDX.LOGIN.loginFailedMessage = 'Sorry. Something went wrong......';
        FDX.LOGIN.showErrorMessage();
        FDX.CLIENTLOGIN.destroyUserSession();
      }
    })
  }

I mean if they change the endpoint, then the intervention stops to work..so not sure if we want to do it.

Thanks Sean! Great work diagnosing!

Worth trying, perhaps. Tom., WDYT?

Flags: needinfo?(twisniewski)

I don't see a way to access doAPIisLoggedIn from JS, so from what I can see our options would be to re-write the script (which is usually very fragile) or to do something like this to re-write the appropriate Ajax requests:

(function () {
  const { prototype } = XMLHttpRequest;
  const descriptor = Object.getOwnPropertyDescriptor(prototype, "open");
  const { value } = descriptor;

  descriptor.value = function (method, url, async, user, password) {
    if (new Error().stack?.includes("doAPIisLoggedIn")) {
      if (!FDX.SESSION.apiURL && !url) { // note this may not be an empty string, but may of course have whatever is in `w` above..
        url = "https://api.fedex.com/";
      }
    }
    return value.apply(this, method, url, async, user, password);
  };

  Object.defineProperty(proto, "open", descriptor);
})();

Sean, can you check if that's feasible? It might be a safer way to hack it.

Flags: needinfo?(twisniewski)
Flags: needinfo?(sefeng)

hmm..I am not sure...looks like there's no easy way to access that method from JS, I think it lives in a cross-origin object..

I first asked chatgpt to fix that script, here's the fixed version

(function () {
  const prototype = XMLHttpRequest.prototype;
  const descriptor = Object.getOwnPropertyDescriptor(prototype, "open");

  if (!descriptor || typeof descriptor.value !== "function") return;

  const originalOpen = descriptor.value;

  descriptor.value = function (method, url, async, user, password) {
    // You can also use `arguments[1]` to get `url` if needed
    if (new Error().stack?.includes("doAPIisLoggedIn")) {
      if (!FDX.SESSION.apiURL && !url) {
        url = "https://api.fedex.com/";
      }
    }

    return originalOpen.apply(this, arguments);
  };

  Object.defineProperty(prototype, "open", descriptor);
})();

I then tried to attached the fixed script to it, but it didn't trigger that new Error().stack?.includes("doAPIisLoggedIn") branch for me, so er...not sure why (being optimized out or due to the complexity of the library?).

However it looks like just attaching your script solely was enough to change the timing for my machine, and I was no longer reproducing that dialog.

but....yeah, I feel that's too fragile, not sure what the best approach is.

Flags: needinfo?(sefeng)
Webcompat Score: 7 → 6

Frankly, if simply attaching the script is enough to fix it for more users, then maybe we ought to just ship it, even if it doesn't really "do" anything?

Flags: needinfo?(sefeng)

I agree with that, but I don't know how reliable that is, I don't know if it's just my machine...

Flags: needinfo?(sefeng)

Upon closer inspection, I think we might be able to rewrite the script with doAPIisLoggedIn to basically enclose the references to x.FDX.SESSION.apiURL as (x.FDX.SESSION.apiURL || 'api.fedex.com'). I think it's worth a shot, at least. I'll upload a patch here for others to test/critique, and we can decide whether to try shipping it afterward.

This is still an issue

Seems to work now, tried a few times on clean. @Tom is there an intervention in place, should we keep this open?

Flags: needinfo?(wisniewskit)

No, we didn't end up shipping an intervention. So if it's fixed, let's just close this.

Status: REOPENED → RESOLVED
Closed: 1 year ago → 1 year ago
Flags: needinfo?(wisniewskit)
Resolution: --- → WORKSFORME
Attachment #9495847 - Attachment is obsolete: true
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: