perf(browsers): replace execSync with async version detection#493
perf(browsers): replace execSync with async version detection#493
Conversation
Remove execSync from BrowserAvailability. Version detection is now async via execSimple and no longer runs during detectAvailableBrowsers (lazy). getBrowserInfo uses the new getBrowserVersionAsync for on-demand version fetching. Fixes #488
PR Review Update:
|
There was a problem hiding this comment.
Two issues to address before merge: (1) getBrowserInfo becoming async is a public API breaking change - it is re-exported via index.ts and external library consumers will now receive a Promise instead of a value. This needs a semver bump and changelog entry. (2) The JSDoc on detectAvailableBrowsers contains a stale sentence claiming no async/await patterns are used anywhere in the codebase. The core async refactor is correct and the graceful error handling is good.
Address review feedback on PR #493: - Revert getBrowserInfo to sync (no breaking API change) - Remove version from getBrowserInfo (use getBrowserVersionAsync) - Update detectAvailableBrowsers JSDoc to reflect async split
Both issues addressed: getBrowserInfo kept sync (no breaking change), stale JSDoc updated.
There was a problem hiding this comment.
PR Review: perf(browsers): replace execSync with async version detection
Both issues from the previous (dismissed) review have been addressed:
getBrowserInfoAPI — reverted to synchronous, no breaking change.- Stale JSDoc —
detectAvailableBrowsersJSDoc now correctly documents the sync/async split.
Code quality
getVersionCommandextraction is clean and makes the platform logic independently testable.getBrowserVersionAsyncerror handling degrades gracefully with debug-level logging.exactOptionalPropertyTypeshandled correctly —getBrowserInforeturns an inline object with noversionkey rather than setting it toundefined.- Removing
execSynceliminates 200–1000ms of blocking from browser detection — a meaningful improvement.
Minor (non-blocking)
2>/dev/nullin command strings is now redundant sinceexecSimplecaptures stderr and errors are caught in the outer try/catch. Harmless but slightly misleading.getBrowserVersionAsyncandgetVersionCommandhave no dedicated unit tests. Existing 588 tests still pass and errors degrade gracefully, so not blocking.- The
AvailableBrowser.versionfield is now silentlyundefinedfor consumers who calleddetectAvailableBrowsersorgetBrowserInfoexpecting it — worth a changelog note if downstream consumers exist.
Verdict
Approved. No blocking issues; the core change is correct and the review feedback was fully addressed.
Summary
execSyncfromBrowserAvailability.tsentirelygetBrowserVersionAsyncusing the existingexecSimpleutility (async)detectAvailableBrowsers— version is now lazy/on-demandgetBrowserInfoto async, callinggetBrowserVersionAsyncEliminates 200-1000ms of event loop blocking from synchronous child processes.
Closes #488
Test plan