Skip to content

Add a timeout option to the scanner wrapper - #78

Merged
tsapeta merged 1 commit into
mainfrom
tsapeta/scanner-timeout
Oct 12, 2026
Merged

tsapeta merged 1 commit into
mainfrom
tsapeta/scanner-timeout

Conversation

@tsapeta

@tsapeta tsapeta commented Oct 12, 2026

Copy link
Copy Markdown
Collaborator

Why

expo-modules-autolinking runs scanModules on every iOS build to find @ExpoModule classes (expo/expo#49784). The wrapper has no timeout, so a hung scanner blocks the build phase. Its error message also contains the full command line, which in an app lists every package root (about 90 paths in bare-expo).

How

  • scanModules and scanExports take a timeout in milliseconds. When it's exceeded, the scanner is killed and the call rejects with a ScannerError that says so. There is no limit by default.
  • The wrapper closes the scanner's stdin. An executable without the scanner CLI would start the macro plugin server and wait on stdin forever.
  • ScannerError messages name only the binary and the subcommand, for example `ExpoModulesMacros scan-modules` failed: ….

Test Plan

  • npm run typecheck passes.
  • With the compiled wrapper and fake binaries given 50 paths: a binary that sleeps 5 s rejects after 505 ms with timeout: 500; a binary that exits 3 rejects with `fail scan-modules` failed: boom; a binary that reads stdin to the end returns its report in 162 ms without a timeout.
  • The real apple/ExpoModulesMacros with timeout: 30000 reports HapticsModule for expo-haptics.

A hung scanner no longer blocks the caller when it passes a `timeout`. The wrapper also closes the scanner's stdin, and its errors name only the subcommand instead of the full command line, which can list hundreds of package roots.
@tsapeta
tsapeta marked this pull request as ready for review October 12, 2026 14:25
@tsapeta
tsapeta merged commit a32f8b4 into main Oct 12, 2026
3 checks passed
@tsapeta
tsapeta deleted the tsapeta/scanner-timeout branch October 12, 2026 14:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant