Skip to content

Conversation

@rosahbruno
Copy link
Contributor

@rosahbruno rosahbruno commented Sep 29, 2023

I tested this by pushing up a branch with the dist folder checked in and running this version directly inside of the mdn project. The window is not defined error goes away when wrapped in the typeof window !== undefined check.

Pull Request checklist

  • Quality: Make sure this PR builds and runs cleanly.
    • Inside the glean/ folder, run:
      • npm run test Runs all tests
      • npm run lint Runs all linters
  • Tests: This PR includes thorough tests or an explanation of why it does not
  • Changelog: This PR includes a changelog entry to CHANGELOG.md or an explanation of why it does not need one
  • Documentation: This PR includes documentation changes, an explanation of why it does not need that or a follow-up bug has been filed to do that work

@rosahbruno rosahbruno force-pushed the 1855792-gate-window-glean branch from a2a82f5 to d662041 Compare September 29, 2023 19:49
@rosahbruno rosahbruno marked this pull request as ready for review September 29, 2023 20:26
@auto-assign auto-assign bot requested a review from badboy September 29, 2023 20:26
@rosahbruno rosahbruno changed the title Bug 1855792 - only set window.Glean vars in browser Bugs 1855792, 1855795 - window.Glean updates Sep 29, 2023
@Dexterp37 Dexterp37 requested review from Dexterp37 and removed request for badboy October 2, 2023 08:09
@rosahbruno rosahbruno merged commit d7db251 into mozilla:main Oct 3, 2023
@rosahbruno rosahbruno deleted the 1855792-gate-window-glean branch October 3, 2023 18:09
const areGleanWindowVarsSet = await driver.executeScript(() => {
// Verify that all Glean `window` vars are properly set.
if (
window &&
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rosahbruno Might this need to be typeof window !== "undefined"?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are actually our browserstack tests. So for this scenario, we want our tests to fail if for some reason we can't find the window object.

The place where we believe this is coming from is fixed in this PR. For whatever reason, our helper function isUndefined isn't working right and is actually leading to the error being thrown. As a fix, we just check directly against window instead.

I tested this by pulling down MDN and running yarn dev with v2.0.4 and reproducing the error. When I retested and did the same thing with the code I pushed to that new branch, I was able to successfully run yarn dev and run the app locally.

Hopefully this should resolve the errors you are seeing whenever we cut a new release!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome, thank you! 🙌

Copy link
Contributor

@caugner caugner Oct 13, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PS: My gut feeling says that passing an undefined variable to isUndefined() just throws an error before you get into the function, because it uses an undefined variable, whereas an explicit typeof varname !== "undefined" never throws.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants