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

fix: fast ssr access to globals should be allowed ouside of a request after adding RequestStorageManager middleware #6318

Merged
merged 6 commits into from
Aug 26, 2022

Conversation

erhuan-msft
Copy link
Contributor

@erhuan-msft erhuan-msft commented Aug 25, 2022

Pull Request

📖 Description

During integration of fast-ssr RequestStorageManager middleware to a SSR server, we discovered access to several globals will throw exceptions if code is not running under storage scope (ie. inside a request). This change will ensure the original global values are assessible outside of a request.

This issue was discovered when running unit test on the test server. Jest will try to access and reset the globals within its framework and thereby causing the exceptions to occur.

Thanks to @EisenbergEffect for the discussion and the code snippet.

📑 Test Plan

Unit tests added for change in installDOMShim behavior

✅ Checklist

General

  • I have included a change request file using $ yarn change
  • I have added tests for my changes.
  • I have tested my changes.
  • I have updated the project documentation to reflect my changes.
  • I have read the CONTRIBUTING documentation and followed the standards for this project.

…nstead of the shimmed version in async local storage if code is not in storage scope.
@erhuan-msft erhuan-msft changed the title Erhuan/dom shim update fix: fast ssr access to globals should be allowed ouside of a request after adding RequestStorageManager middleware Aug 25, 2022
Copy link
Contributor

@EisenbergEffect EisenbergEffect left a comment

Choose a reason for hiding this comment

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

Approved pending the small fix to the change file. Thanks for adding the tests!

@EisenbergEffect EisenbergEffect self-assigned this Aug 25, 2022
Copy link
Contributor

@nicholasrice nicholasrice left a comment

Choose a reason for hiding this comment

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

Thanks @erhuan-msft!

@EisenbergEffect EisenbergEffect merged commit 4fe1bc5 into microsoft:master Aug 26, 2022
@EisenbergEffect EisenbergEffect added this to the SSR 1.0 milestone Aug 26, 2022
janechu pushed a commit that referenced this pull request Jun 10, 2024
… after adding RequestStorageManager middleware (#6318)

* Updated installDOMShim logic so original global values are returned from getter if not in request scope

* Change files

* After install DOM Shim, globals will now return the original global instead of the shimmed version in async local storage if code is not in storage scope.

* Update change/@microsoft-fast-ssr-e107db57-9534-4ac4-bd65-157d5b40a79f.json

Co-authored-by: Rob Eisenberg <EisenbergEffect@users.noreply.github.com>

Co-authored-by: Rob Eisenberg <EisenbergEffect@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

4 participants