Skip to content

Comments

fix: safely call Faro via window optional chaining#390

Merged
MattIPv4 merged 1 commit intomainfrom
MattIPv4/safe-faro-calls
Feb 9, 2026
Merged

fix: safely call Faro via window optional chaining#390
MattIPv4 merged 1 commit intomainfrom
MattIPv4/safe-faro-calls

Conversation

@MattIPv4
Copy link
Member

@MattIPv4 MattIPv4 commented Feb 6, 2026

If Faro fails to load, or JS logic runs before Faro has finished loading, faro and/or faro.api may be undefined, causing pages to not work as expected. This was seen in grafana/synthetic-monitoring-app#1580, where test scripts were attempting to submit the login form before Faro was loaded, causing the JS to error and fail. I've switched all Faro usages from faro.api. to window.faro?.api?., which should handle both window.faro being undefined (before Faro has loaded) and window.faro.api being defined (before Faro has initialized).

`faro.api.` -> `window.faro?.api?.`
@MattIPv4 MattIPv4 force-pushed the MattIPv4/safe-faro-calls branch from 6396eff to 99cece6 Compare February 6, 2026 19:18
@MattIPv4 MattIPv4 merged commit 4f1c1e2 into main Feb 9, 2026
15 checks passed
@MattIPv4 MattIPv4 deleted the MattIPv4/safe-faro-calls branch February 9, 2026 14:18
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