Skip to content

getCmp - #3924

Merged
oliverlloyd merged 1 commit into
mainfrom
oliver/getCmp
Feb 4, 2022
Merged

getCmp#3924
oliverlloyd merged 1 commit into
mainfrom
oliver/getCmp

Conversation

@oliverlloyd

Copy link
Copy Markdown
Contributor

What does this change?

This PR adds a small lib called getCmp which returns the version of the cmp object that gets placed on window.guCmpHotFix

Why?

As we move more code over to the Island pattern we are starting to hit issues where the cmp lib is not server safe. If we refactor DCR's access to cmp to use this window object then this allows us to avoid the import, which is where we're getting errors on the server.

This abstraction is a helper utility to make that refactor. The main thing it provides is a check and a call to Sentry in the event that the property is not available. We believe that the property will always be there - we run bootCmp very early - but it might not be and we want to be aware if this happens. If we do see these errors, then it suggests we have a race condition and that we will need to implement some form of queue while the code waits for this value to be set.

@oliverlloyd
oliverlloyd requested review from a team, JamieB-gu and marsavar as code owners February 4, 2022 10:23
@github-actions github-actions Bot added the dotcom label Feb 4, 2022
@oliverlloyd

Copy link
Copy Markdown
Contributor Author

@shtukas @kenoir This is perhaps of interest to you based on our discussions the other day?

@github-actions

github-actions Bot commented Feb 4, 2022

Copy link
Copy Markdown

Size Change: 0 B

Total Size: 1.18 MB

ℹ️ View Unchanged
Filename Size
dotcom-rendering/dist/1376.js 3.63 kB
dotcom-rendering/dist/1376.legacy.js 3.82 kB
dotcom-rendering/dist/1672.js 3.72 kB
dotcom-rendering/dist/1924.js 4.56 kB
dotcom-rendering/dist/1924.legacy.js 4.7 kB
dotcom-rendering/dist/1983.js 13.8 kB
dotcom-rendering/dist/1983.legacy.js 14.4 kB
dotcom-rendering/dist/2666.js 30.6 kB
dotcom-rendering/dist/3213.js 13 kB
dotcom-rendering/dist/3213.legacy.js 13.2 kB
dotcom-rendering/dist/3215.js 4.88 kB
dotcom-rendering/dist/3215.legacy.js 5.05 kB
dotcom-rendering/dist/3321.legacy.js 28.5 kB
dotcom-rendering/dist/3397.js 240 B
dotcom-rendering/dist/3397.legacy.js 251 B
dotcom-rendering/dist/343.js 3.73 kB
dotcom-rendering/dist/343.legacy.js 3.91 kB
dotcom-rendering/dist/3639.js 5.24 kB
dotcom-rendering/dist/3639.legacy.js 5.42 kB
dotcom-rendering/dist/3777.legacy.js 6.41 kB
dotcom-rendering/dist/4415.legacy.js 3.56 kB
dotcom-rendering/dist/45.legacy.js 3.55 kB
dotcom-rendering/dist/4576.js 235 B
dotcom-rendering/dist/4576.legacy.js 247 B
dotcom-rendering/dist/4850.js 235 B
dotcom-rendering/dist/4850.legacy.js 246 B
dotcom-rendering/dist/4999.js 17.9 kB
dotcom-rendering/dist/4999.legacy.js 18.5 kB
dotcom-rendering/dist/5217.js 233 B
dotcom-rendering/dist/5217.legacy.js 245 B
dotcom-rendering/dist/53.js 4.11 kB
dotcom-rendering/dist/53.legacy.js 4.12 kB
dotcom-rendering/dist/5373.legacy.js 3.58 kB
dotcom-rendering/dist/5585.js 5.2 kB
dotcom-rendering/dist/5585.legacy.js 5.36 kB
dotcom-rendering/dist/602.js 8.66 kB
dotcom-rendering/dist/602.legacy.js 8.92 kB
dotcom-rendering/dist/6348.js 4.58 kB
dotcom-rendering/dist/6348.legacy.js 4.75 kB
dotcom-rendering/dist/6372.legacy.js 3.89 kB
dotcom-rendering/dist/6400.js 21.5 kB
dotcom-rendering/dist/6400.legacy.js 21.5 kB
dotcom-rendering/dist/6684.js 241 B
dotcom-rendering/dist/6684.legacy.js 252 B
dotcom-rendering/dist/6916.js 8.25 kB
dotcom-rendering/dist/6916.legacy.js 8.71 kB
dotcom-rendering/dist/6965.js 2.65 kB
dotcom-rendering/dist/6965.legacy.js 2.71 kB
dotcom-rendering/dist/7051.js 7.22 kB
dotcom-rendering/dist/7051.legacy.js 7.37 kB
dotcom-rendering/dist/7317.js 3.4 kB
dotcom-rendering/dist/7489.js 3.4 kB
dotcom-rendering/dist/7754.legacy.js 3.56 kB
dotcom-rendering/dist/8080.js 3.52 kB
dotcom-rendering/dist/8080.legacy.js 3.7 kB
dotcom-rendering/dist/8294.js 232 B
dotcom-rendering/dist/8294.legacy.js 244 B
dotcom-rendering/dist/8330.js 3.21 kB
dotcom-rendering/dist/8497.js 4.01 kB
dotcom-rendering/dist/8748.js 232 B
dotcom-rendering/dist/8748.legacy.js 243 B
dotcom-rendering/dist/9212.js 3.4 kB
dotcom-rendering/dist/9641.js 5.17 kB
dotcom-rendering/dist/9641.legacy.js 5.34 kB
dotcom-rendering/dist/9776.js 5.09 kB
dotcom-rendering/dist/9776.legacy.js 5.26 kB
dotcom-rendering/dist/9884.js 17 kB
dotcom-rendering/dist/9884.legacy.js 17.3 kB
dotcom-rendering/dist/atomIframe.js 1.87 kB
dotcom-rendering/dist/atomIframe.legacy.js 2.14 kB
dotcom-rendering/dist/bootCmp.js 7.39 kB
dotcom-rendering/dist/bootCmp.legacy.js 10.9 kB
dotcom-rendering/dist/braze-web-sdk-core.js 36.1 kB
dotcom-rendering/dist/braze-web-sdk-core.legacy.js 36.1 kB
dotcom-rendering/dist/cmp.js 7.51 kB
dotcom-rendering/dist/coreVitals.js 4.03 kB
dotcom-rendering/dist/coreVitals.legacy.js 4.33 kB
dotcom-rendering/dist/dynamicImport.js 3 kB
dotcom-rendering/dist/dynamicImport.legacy.js 3.29 kB
dotcom-rendering/dist/embedIframe.js 1.88 kB
dotcom-rendering/dist/embedIframe.legacy.js 2.14 kB
dotcom-rendering/dist/frontend.server.js 300 kB
dotcom-rendering/dist/ga.js 3.88 kB
dotcom-rendering/dist/ga.legacy.js 4.14 kB
dotcom-rendering/dist/guardian-braze-components-banner.js 10.6 kB
dotcom-rendering/dist/guardian-braze-components-banner.legacy.js 10.6 kB
dotcom-rendering/dist/guardian-braze-components-end-of-article.js 6.61 kB
dotcom-rendering/dist/guardian-braze-components-end-of-article.legacy.js 6.62 kB
dotcom-rendering/dist/initDiscussion.js 7.46 kB
dotcom-rendering/dist/initDiscussion.legacy.js 7.71 kB
dotcom-rendering/dist/InteractiveBlockComponent.js 2.99 kB
dotcom-rendering/dist/InteractiveBlockComponent.legacy.js 3.12 kB
dotcom-rendering/dist/islands.js 7.61 kB
dotcom-rendering/dist/islands.legacy.js 8.36 kB
dotcom-rendering/dist/MostViewedFooterData.js 6.25 kB
dotcom-rendering/dist/MostViewedFooterData.legacy.js 6.34 kB
dotcom-rendering/dist/newsletterEmbedIframe.js 1.83 kB
dotcom-rendering/dist/newsletterEmbedIframe.legacy.js 2.1 kB
dotcom-rendering/dist/ophan.js 7.18 kB
dotcom-rendering/dist/ophan.legacy.js 7.38 kB
dotcom-rendering/dist/react.js 86.5 kB
dotcom-rendering/dist/react.legacy.js 93.2 kB
dotcom-rendering/dist/readerRevenueDevUtils.js 891 B
dotcom-rendering/dist/readerRevenueDevUtils.legacy.js 952 B
dotcom-rendering/dist/relativeTime.js 2.41 kB
dotcom-rendering/dist/relativeTime.legacy.js 2.68 kB
dotcom-rendering/dist/sentry.js 677 B
dotcom-rendering/dist/sentry.legacy.js 689 B
dotcom-rendering/dist/sentryLoader.js 4.75 kB
dotcom-rendering/dist/sentryLoader.legacy.js 7.71 kB
dotcom-rendering/dist/shimport.js 2.75 kB
dotcom-rendering/dist/shimport.legacy.js 2.76 kB
dotcom-rendering/dist/SignInGateMain.js 1.84 kB
dotcom-rendering/dist/SignInGateMain.legacy.js 1.88 kB
dotcom-rendering/dist/YoutubeBlockComponent.js 2.84 kB
dotcom-rendering/dist/YoutubeBlockComponent.legacy.js 2.97 kB

compressed-size-action

@mxdvl mxdvl left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think erroring on the race condition should be good enough!

Comment thread dotcom-rendering/src/web/lib/getCmp.ts
@oliverlloyd
oliverlloyd merged commit 2b61896 into main Feb 4, 2022
@oliverlloyd
oliverlloyd deleted the oliver/getCmp branch February 4, 2022 11:51
@mxdvl

mxdvl commented Feb 8, 2022

Copy link
Copy Markdown
Contributor

Did we see any errors crop up from this?

@oliverlloyd

Copy link
Copy Markdown
Contributor Author

Did we see any errors crop up from this?

This code doesn't do anything, it's just adding a file. The PR to actually use it is this one, which is blocked on the You Tube works

@mxdvl mxdvl mentioned this pull request Mar 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants