Skip to content

Commit

Permalink
Fix setTimeoutCustom in worker thread
Browse files Browse the repository at this point in the history
In worker thread, window doesn't exist so !window will raise a
referenceError. Check "typeof window" to fix this.

BUG tensorflow#6922
  • Loading branch information
gyagp committed Oct 10, 2022
1 parent 7281c8e commit bb65957
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion tfjs-core/src/platforms/platform_browser.ts
Expand Up @@ -62,7 +62,8 @@ export class PlatformBrowser implements Platform {
// Interleaving window.postMessage and setTimeout will trick the browser and
// avoid the clamp.
setTimeoutCustom(functionRef: Function, delay: number): void {
if (!window || !env().getBool('USE_SETTIMEOUTCUSTOM')) {
if (typeof window === 'undefined' ||
!env().getBool('USE_SETTIMEOUTCUSTOM')) {
setTimeout(functionRef, delay);
return;
}
Expand Down

0 comments on commit bb65957

Please sign in to comment.