-
Notifications
You must be signed in to change notification settings - Fork 197
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
Moving CDN PreFetch to kick off prior to initialize call and added timeout logic #2666
Conversation
…ibrary-js into jadahiya/ddl_fix
…g timeout logic in case it takes too long to respond
@@ -27,6 +27,8 @@ import { | |||
import { version } from '../version'; | |||
import * as lifecycle from './lifecycle'; | |||
|
|||
prefetchOriginsFromCDN(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now that this is called in the global namespace this file has a side effect that it didn't used to have (loading the file in memory now automatically makes a call to the CDN). Can you verify with Noah that we don't need to mark this file in any particular way to prevent it from being treeshaken out?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good call, I'll follow up with Noah on this and if there's any issue I'll move this call into a separate funciton.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Followed up with Noah, this will in fact introduce an unintended side effect that would make app.ts
not treeshake-able. I'll be pushing out a change that will mitigate this or lessen the impact of the side effect.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there something we can do so issues like this are apparent to developers who introduce them without requiring @TrevorJoelHarris or @noahdarveau-MSFT to be manually looking for them in code reviews? Certainly I wouldn't have realized this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmmm, that's a good question. I'll think about it (and maybe ask @noahdarveau-MSFT). In general, any function calls in the global namespace are "side effects" if they cause some state somewhere to change because those functions will just get called assuming the entire module doesn't get tree-shaken out and removed. Off the top of my head I'm not sure there's a way to "detect" that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, I am pretty sure that we could make a linter rule to detect global function calls that would show a warning saying something like "This file should probably be added to the sideEffects array in package.json. Once you've done that (or verified that you don't need to) please suppress this warning."
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left a few questions
…should not be treeshaken
If this function gets called a second time while the first
|
change/@microsoft-teams-js-b7743f88-f4a7-4485-a6b8-2a7512bb9d83.json
Outdated
Show resolved
Hide resolved
change/@microsoft-teams-js-ceda76cc-75d3-40de-8b4b-cb392a240254.json
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🕐
…o through the entire flow rather than the cached flow
…o through the entire flow rather than the cached flow
…soft-teams-library-js into jadahiya/ddl_fix
…soft-teams-library-js into jadahiya/ddl_fix
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For more information about how to contribute to this repo, visit this page.
Description
This change was made to address customer feedback that the network call to acquire CDN resources was leading to initialization time outs. We aim to address this concern by decoupling that call.
Main changes in the PR:
prefetch.ts
file to execute a global fetch upon library load. Moved into a separate file since global functions cause side effects that can't be treeshakeable.jest-setup.cjs
filefetch
polyfill romtest\utils.ts
file and moved into a newsetupTest.ts
file that is used during jest setup.Validation
Validation performed:
Unit Tests added:
setupTests.ts
file to tests to enable global fetch polyfill for Jest tests.