bug(web): apparent race condition when refreshing pages with KeymanWeb can cause an exception
- Dominant language
- Pascal
- Stars
- 534
- Forks
- 143
- Avg merge
- 2d 10h
- Merged PRs (30d)
- 113
Description
The `keymanweb._SetTargDir` function is called from `Lscript.addEventListener('load', function() {` in keymanweb.js:3617. In some situations, `Ptarg.base` is not defined at the time that the script is loaded, and this causes an exception `Uncaught TypeError: Cannot set property 'dir' of undefined` at keymanweb.js:4758.
This doesn't happen every time, because sometimes additional initialization is already complete by the time the script loads (I have not analysed the load order to determine which init is being completed earlier).
This is easiest to reproduce from the Keyman Developer debugger in Chrome. Load a page, press F12 to open the Developer Tools, click back into the page, then press F5. Note that the error does *not* occur if F5 is pressed while the Developer Tools window is focused.
The error can be observed in other places as well, but it's harder to repro consistently.
The offending line of code in `keymanweb._SetTargDir` is:
```
Ptarg.base.dir=Ptarg.dir=elDir;
```
Contributor guide
Assessment
This issue has not been assessed yet.