faro-web-sdk
faro-web-sdk copied to clipboard
fix: Check for undefined faro instancein isWebStorageAvailable catch block
Why
If storage throws an exception during the module init calls to isWebStorageAvailable, the global faro instance is not set and this crashes.
What
Optional chain the faro instance itself in this catch block.
Links
Checklist
- [ ] Tests added
- [ ] Changelog updated
- [ ] Documentation updated
The logs we are seeing on our end are TypeError: Cannot read property 'internalLogger' of undefined.
I have not been able to reproduce locally. Scanning through faro, I believe this is the only callsite that could produce that error. The other calls to faro.internalLogger all check some other property of the global faro instance (faro.config) first, which would be the line thrown from instead.
The logs we are seeing on our end are
TypeError: Cannot read property 'internalLogger' of undefined.I have not been able to reproduce locally. Scanning through faro, I believe this is the only callsite that could produce that error. The other calls to faro.internalLogger all check some other property of the global faro instance (faro.config) first, which would be the line thrown from instead.
Hey once again. I was on PTO last week so apologies for catching up with your replies a week later. Do you have any other stack traces that might be helpful? Although I am leaning towards your original change being the solution. I just want to get more context so that we can have precedence and ideally create a test for it
Hi @edkimmel want to follow up on this.
Do you still run into the issue?