Skip to content

fix: skip unreadable tsconfig files during auto-discovery#1033

Merged
Boshen merged 3 commits intooxc-project:mainfrom
longlho:fix/tsconfig-auto-discovery-io-error
Feb 26, 2026
Merged

fix: skip unreadable tsconfig files during auto-discovery#1033
Boshen merged 3 commits intooxc-project:mainfrom
longlho:fix/tsconfig-auto-discovery-io-error

Conversation

@longlho
Copy link
Copy Markdown
Contributor

@longlho longlho commented Feb 25, 2026

Summary

  • When TsconfigDiscovery::Auto walks parent directories and finds a tsconfig.json that exists but cannot be read (e.g. permission denied in sandboxed environments like Bazel/Docker), treat it as if no tsconfig exists at that level and continue walking parent directories.
  • Previously, read_to_string I/O failures were mapped to TsconfigNotFound, conflating "file not found" with "file not readable." Now I/O errors are properly mapped to IOError, and find_tsconfig_auto catches IOError to skip unreadable files while still propagating real config errors (bad JSON, broken extends, circular references).

Context: vitejs/vite#21705 (comment)

Test plan

  • Added tsconfig_discovery_skips_unreadable_file test (unix-only) that creates a tsconfig.json with chmod 000 and verifies find_tsconfig returns Ok(None)
  • All existing tsconfig discovery tests continue to pass

🤖 Generated with Claude Code

When `TsconfigDiscovery::Auto` walks parent directories and finds a
tsconfig.json that exists but cannot be read (e.g. permission denied),
treat it as if no tsconfig exists at that level and continue walking.

Previously, `read_to_string` failures were mapped to
`TsconfigNotFound`, which is also used for missing `extends` targets.
Now I/O errors are properly mapped to `IOError`, and `find_tsconfig_auto`
catches `IOError` to skip unreadable files while still propagating real
config errors (bad JSON, broken extends, circular references).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@longlho
Copy link
Copy Markdown
Contributor Author

longlho commented Feb 25, 2026

@Boshen CC captures most of the context there, but there's some nuances with Linux sandbox vs Darwin where Darwin is generally more lax.

@Boshen Boshen self-assigned this Feb 26, 2026
@sapphi-red
Copy link
Copy Markdown
Member

I think it's worth adding a test that ensures the NotFound error is correctly emitted when the tsconfig.json specified in extends or references are not readable.

@codspeed-hq
Copy link
Copy Markdown

codspeed-hq Bot commented Feb 26, 2026

Merging this PR will degrade performance by 4.64%

❌ 2 regressed benchmarks
✅ 11 untouched benchmarks
⏩ 5 skipped benchmarks1

⚠️ Please fix the performance issues or acknowledge them on CodSpeed.

Performance Changes

Benchmark BASE HEAD Efficiency
complex_real 21.8 µs 22.8 µs -4.64%
resolver_real[multi-thread] 446.5 µs 464.6 µs -3.88%

Comparing longlho:fix/tsconfig-auto-discovery-io-error (05d6338) with main (bda0919)

Open in CodSpeed

Footnotes

  1. 5 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

Ensure that missing or unreadable tsconfig files in `extends` and
`references` emit the correct error variants (TsconfigNotFound vs IOError).
Uses a custom UnreadableFs to simulate permission denied without
platform-specific code.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@Boshen Boshen merged commit a6163d0 into oxc-project:main Feb 26, 2026
14 checks passed
@Boshen Boshen mentioned this pull request Feb 26, 2026
@longlho
Copy link
Copy Markdown
Contributor Author

longlho commented Feb 26, 2026

thanks guys!

@longlho longlho deleted the fix/tsconfig-auto-discovery-io-error branch February 26, 2026 12:05
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.

3 participants