Skip to content

Commit

Permalink
Fix cloudflare worker error when using tldraw packages (tldraw#4549)
Browse files Browse the repository at this point in the history
  • Loading branch information
SomeHats authored Sep 17, 2024
1 parent 54d16fe commit 1114977
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions packages/utils/src/lib/version.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,17 @@ export function registerTldrawLibraryVersion(name?: string, version?: string, mo
info.versions.push({ name, version, modules })

if (!info.scheduledNotice) {
// eslint-disable-next-line no-restricted-globals
info.scheduledNotice = setTimeout(() => {
info.scheduledNotice = null
try {
// eslint-disable-next-line no-restricted-globals
info.scheduledNotice = setTimeout(() => {
info.scheduledNotice = null
checkLibraryVersions(info)
}, 100)
} catch {
// some environments (e.g. cloudflare workers) don't support setTimeout immediately, only in a handler.
// in this case, we'll just check immediately.
checkLibraryVersions(info)
}, 100)
}
}
}

Expand Down

0 comments on commit 1114977

Please sign in to comment.