Skip to content

feat: add ResolveError::TsconfigLoadFailed for tsconfig read and parse failures#1287

Merged
Boshen merged 1 commit into
oxc-project:mainfrom
shulaoda:07-10-feat_add_resolveerror_tsconfigloadfailed_for_tsconfig_read_and_parse_failures
Jul 10, 2026
Merged

feat: add ResolveError::TsconfigLoadFailed for tsconfig read and parse failures#1287
Boshen merged 1 commit into
oxc-project:mainfrom
shulaoda:07-10-feat_add_resolveerror_tsconfigloadfailed_for_tsconfig_read_and_parse_failures

Conversation

@shulaoda

Copy link
Copy Markdown
Contributor

Tsconfig files are loaded lazily during resolution, and when the load fails with anything other than "not found", the error surfaces as the generic ResolveError::Json or ResolveError::IOError. Both variants are also used for package.json failures, so callers cannot tell which file actually failed to load. Rolldown hit this while trying to report a broken tsconfig as a proper TSCONFIG_ERROR diagnostic instead of an internal error, see the discussion in rolldown/rolldown#10200 (rolldown/rolldown#10200 (comment)).

This PR adds a dedicated variant that wraps the original error instead of replacing it, so the JSON details (path, line, column) stay reachable through source:

/// Failed to read or parse a tsconfig file.
#[error("Failed to load tsconfig {path:?}: {source}")]
TsconfigLoadFailed { path: PathBuf, source: Box<Self> },

The wrapping happens in Cache::get_tsconfig, the single entry point for tsconfig loading, so manual mode, auto discovery, the extends chain and project references are all covered at once. TsconfigNotFound keeps its dedicated variant, and package.json failures keep surfacing as plain Json / IOError. The auto discovery walk used to skip unreadable tsconfig files by matching IOError directly and now matches the wrapped form, keeping the same behavior.

Since ResolveError is #[non_exhaustive], adding the variant is not a breaking change for downstream matches. The existing broken, test_extend_tsconfig_unreadable_file and test_references_unreadable_file tests are updated to assert the new shape.

@codspeed-hq

codspeed-hq Bot commented Jul 10, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

⚠️ Different runtime environments detected

Some benchmarks with significant performance changes were compared across different runtime environments,
which may affect the accuracy of the results.

Open the report in CodSpeed to investigate

⚡ 3 improved benchmarks
❌ 2 regressed benchmarks
✅ 16 untouched benchmarks
⏩ 5 skipped benchmarks1

Warning

Please fix the performance issues or acknowledge them on CodSpeed.

Performance Changes

Benchmark BASE HEAD Efficiency
resolver_memory[multi-thread] 243.1 µs 253.2 µs -4.02%
resolver_real[multi-thread] 247.6 µs 255.5 µs -3.1%
pm/yarn-flat 917.9 µs 843.1 µs +8.87%
pm/pnpm-isolated 1,032.4 µs 976.6 µs +5.72%
pm/bun-isolated 1,028.2 µs 993.4 µs +3.5%

Tip

Investigate this regression by commenting @codspeedbot fix this regression on this PR, or directly use the CodSpeed MCP with your agent.


Comparing shulaoda:07-10-feat_add_resolveerror_tsconfigloadfailed_for_tsconfig_read_and_parse_failures (6eb34df) with main (7135ac4)

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.

@Boshen
Boshen merged commit 3483eb3 into oxc-project:main Jul 10, 2026
15 checks passed
@oxc-guard oxc-guard Bot mentioned this pull request Jul 10, 2026
Boshen pushed a commit that referenced this pull request Jul 12, 2026
## 🤖 New release

* `oxc_resolver`: 11.23.0 -> 11.24.0
* `oxc_resolver_napi`: 11.23.0 -> 11.24.0

<details><summary><i><b>Changelog</b></i></summary><p>

## `oxc_resolver`

<blockquote>

##
[11.24.0](v11.23.0...v11.24.0)
- 2026-07-12

### <!-- 0 -->🚀 Features

- expose tsconfig paths resolve method without file existence check
([#1282](#1282)) (by
@sapphi-red)
- add `ResolveError::TsconfigLoadFailed` for tsconfig read and parse
failures
([#1287](#1287)) (by
@shulaoda)

### <!-- 2 -->🚜 Refactor

- replace cfg-if dependency with std cfg_select! macro
([#1290](#1290)) (by
@Boshen)

### <!-- 3 -->📚 Documentation

- normalize README sponsor section
([#1273](#1273)) (by
@Boshen)

### <!-- 4 -->⚡ Performance

- *(cache)* reuse the child path when its parent canonicalizes to itself
([#1288](#1288)) (by
@Boshen)
- *(napi)* shrink release binaries (path remap + build-std without
backtrace)
([#1283](#1283)) (by
@Boshen)

### Contributors

* @sapphi-red
* @Boshen
* @renovate[bot]
* @shulaoda
</blockquote>



</p></details>

---
This PR was generated with
[release-plz](https://github.com/release-plz/release-plz/).

Co-authored-by: oxc-guard[bot] <276638029+oxc-guard[bot]@users.noreply.github.com>
@oxc-guard oxc-guard Bot mentioned this pull request Jul 12, 2026
Boshen pushed a commit that referenced this pull request Jul 12, 2026
## 🤖 New release

* `oxc_resolver`: 11.24.0 -> 11.24.1
* `oxc_resolver_napi`: 11.24.0 -> 11.24.1

<details><summary><i><b>Changelog</b></i></summary><p>

## `oxc_resolver`

<blockquote>

##
[11.24.0](v11.23.0...v11.24.0)
- 2026-07-12

### <!-- 0 -->🚀 Features

- expose tsconfig paths resolve method without file existence check
([#1282](#1282)) (by
@sapphi-red)
- add `ResolveError::TsconfigLoadFailed` for tsconfig read and parse
failures
([#1287](#1287)) (by
@shulaoda)

### <!-- 2 -->🚜 Refactor

- replace cfg-if dependency with std cfg_select! macro
([#1290](#1290)) (by
@Boshen)

### <!-- 3 -->📚 Documentation

- normalize README sponsor section
([#1273](#1273)) (by
@Boshen)

### <!-- 4 -->⚡ Performance

- *(cache)* reuse the child path when its parent canonicalizes to itself
([#1288](#1288)) (by
@Boshen)
- *(napi)* shrink release binaries (path remap + build-std without
backtrace)
([#1283](#1283)) (by
@Boshen)

### Contributors

* @sapphi-red
* @Boshen
* @renovate[bot]
* @shulaoda
</blockquote>



</p></details>

---
This PR was generated with
[release-plz](https://github.com/release-plz/release-plz/).

Co-authored-by: oxc-guard[bot] <276638029+oxc-guard[bot]@users.noreply.github.com>
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.

2 participants