-
Notifications
You must be signed in to change notification settings - Fork 123
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: warn on unavailable lazy load not throw #1400
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
Size Change: +168 B (+0.01%) Total Size: 1.18 MB
ℹ️ View Unchanged
|
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.
makes sense, thanks 🙏
logger.warn(LOGGER_PREFIX, 'canActivateRepeatedly is not defined, must init before calling') | ||
return false // TODO does it make sense to have a default here? |
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.
@jurajmajerik @dmarticus i'm unfamiliar with this (and lazy 🤣 )
is it safe to return false here? will we accidentally disable surveys or something?
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.
I think this is fine.
This method is called here: https://github.com/PostHog/posthog-js/blob/fix/warn-not-throw/src/posthog-surveys.ts#L182
If you don't return false early than an error will be thrown on return.
@Phanatic can you double check please? I believe you've added this recently.
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.
This looks good, ship it!
relates to #1344
we're checking the presence of a method on something that could be undefined
but we don't correctly type all the lazy load stuff, so TS doesn't complain
this at least safely checks the presence and will warn instead
we're likely calling the method too early (before it has had a chance to be added to the window) this might even be safe, so we definitely shouldn't throw