Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JavaScript error when loading any form #1056

Closed
MrJackWilson opened this issue Jul 31, 2023 · 6 comments
Closed

JavaScript error when loading any form #1056

MrJackWilson opened this issue Jul 31, 2023 · 6 comments
Labels
release/8.13.11 release/10.5.0 release/12.1.0 state/sprint-candidate We're trying to get this in a sprint at HQ in the next few weeks type/bug

Comments

@MrJackWilson
Copy link

MrJackWilson commented Jul 31, 2023

Which Umbraco version are you using? (Please write the exact version, example: 10.1.0)

11.4.2

Bug summary

I'm getting a JavaScript error whenever I try to load a form or it's entries. I only get this error when pushing it to our live server, on my local build it works just fine. It complains of an undefined currentUserId variable. The only place I can find this variable in the forms code is in umbraco.forms.js. It is mentioned twice, lines 1349 and 1823. Both times are an assignment to the variable, although the type of variable, var, let, const, is not specified, which I think would only be an issue if use strict'; is being used, which I don't think it is.

Specifics

ReferenceError: currentUserId is not defined
    at controller.js:2:13
    at umbraco-backoffice-js.js.vc13c1b50dfd976ea4a1d823dc284e637b3dd57e8:159:454
    at m.$digest (umbraco-backoffice-js.js.vc13c1b50dfd976ea4a1d823dc284e637b3dd57e8:171:67)
    at m.$apply (umbraco-backoffice-js.js.vc13c1b50dfd976ea4a1d823dc284e637b3dd57e8:174:484)
    at HTMLAnchorElement.<anonymous> (umbraco-backoffice-js.js.vc13c1b50dfd976ea4a1d823dc284e637b3dd57e8:218:276)
    at HTMLAnchorElement.dispatch (umbraco-backoffice-js.js.vc13c1b50dfd976ea4a1d823dc284e637b3dd57e8:2:39997)
    at v.handle (umbraco-backoffice-js.js.vc13c1b50dfd976ea4a1d823dc284e637b3dd57e8:2:37968) 'Possibly unhandled rejection: {}'```

### Steps to reproduce

Unsure

### Expected result / actual result

_No response_

---
_This item has been added to our backlog [AB#31691](https://dev.azure.com/umbraco/243e7927-03b2-44e2-908f-d4ac7ea5daaa/_workitems/edit/31691)_
@github-actions
Copy link

Hi there @MrJackWilson!

Firstly, a big thank you for raising this issue. Every piece of feedback we receive helps us to make Umbraco better.

We really appreciate your patience while we wait for our team to have a look at this but we wanted to let you know that we see this and share with you the plan for what comes next.

  • We'll assess whether this issue relates to something that has already been fixed in a later version of the release that it has been raised for.
  • If it's a bug, is it related to a release that we are actively supporting or is it related to a release that's in the end-of-life or security-only phase?
  • We'll replicate the issue to ensure that the problem is as described.
  • We'll decide whether the behavior is an issue or if the behavior is intended.

We wish we could work with everyone directly and assess your issue immediately but we're in the fortunate position of having lots of contributions to work with and only a few humans who are able to do it. We are making progress though and in the meantime, we will keep you in the loop and let you know when we have any questions.

Thanks, from your friendly Umbraco GitHub bot 🤖 🙂

@bergmania bergmania transferred this issue from umbraco/Umbraco-CMS Jul 31, 2023
@AndyButland
Copy link

If it's working locally and not in another environment, a couple of things come to mind.

Could be caching - perhaps you had an earlier version installed and have now upgraded. If that's a possibility please make sure you have fully cleared the cache via the configuration setting discussed here.

If you've upgraded from Umbraco 9, could also be some files you need to remove from your upstream environment before deploying.

@MrJackWilson
Copy link
Author

I tried clearing the cache in all the ways. I even created an entirely new site on the server so I could publish a clean copy, the problem persisted. I then tried creating an near enough empty project with forms. I published it to the server and got the same problem.

I ended up getting around the problem by creating a dummy JS file which runs window.currentUserId = -1;. This then allows forms to set the variable as it pleases. I'm fairly certain the problem lies on the two lines that I mentioned above. Changing those to include window. should solve the issue I think.

@AndyButland
Copy link

AndyButland commented Aug 1, 2023

OK, perhaps there's some sort of race condition going on then... that populates this variable happens fast enough locally to not see the problem but it manifests itself in a deployed environment. Will see if I can track it down.

@AndyButland
Copy link

What version of Forms are you running please? I can see you've provided the CMS version, but would be useful to know the Forms version too.

@MrJackWilson
Copy link
Author

MrJackWilson commented Aug 1, 2023

Ah sorry, thought I included that. It's 11.2.0

@AndyButland AndyButland added the state/sprint-candidate We're trying to get this in a sprint at HQ in the next few weeks label Aug 1, 2023
@azure-devops-sync azure-devops-sync bot changed the title Error when loading any form JavaScript error when loading any form Aug 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release/8.13.11 release/10.5.0 release/12.1.0 state/sprint-candidate We're trying to get this in a sprint at HQ in the next few weeks type/bug
Projects
None yet
Development

No branches or pull requests

2 participants