Skip to content

feat: report error when failure in creating program#356

Merged
camc314 merged 2 commits intooxc-project:mainfrom
7086cmd:feat/create-report
Nov 4, 2025
Merged

feat: report error when failure in creating program#356
camc314 merged 2 commits intooxc-project:mainfrom
7086cmd:feat/create-report

Conversation

@7086cmd
Copy link
Copy Markdown
Contributor

@7086cmd 7086cmd commented Nov 1, 2025

When tsgo fails to parse the tsconfig, it displays an error and, if fatal, returns nil when creating the program. However, we didn't implement it, leading to a segfault.

(base) ethangoh@ethanwu mobile % ./tsgolint
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x2 addr=0x0 pc=0x104dba570]

goroutine 1 [running]:
github.com/microsoft/typescript-go/internal/compiler.(*Program).Host(0x140001e0300?)
        /Users/ethangoh/Developer/tsgolint/typescript-go/internal/compiler/program.go:292
main.runMain()
        /Users/ethangoh/Developer/tsgolint/cmd/tsgolint/main.go:412 +0x6f8
main.main()
        /Users/ethangoh/Developer/tsgolint/cmd/tsgolint/main.go:525 +0x1c

The tsgo reports:

(base) ethangoh@ethanwu mobile % pnpm tsgo
tsconfig.json:23:5 - error TS5102: Option 'baseUrl' has been removed. Please remove it from your configuration.
  Use '"paths": {"*": ["./*"]}' instead.

23     "baseUrl": ".",
       ~~~~~~~~~


Found 1 error in tsconfig.json:23

I added the logic to handle the TypeScript error, but I'm new to Go and don't have a clear idea of how those modules work. I wanted to implement a diagnostic report similar to the lint result, but I couldn't successfully understand it.

Now it looks like:

(base) ethangoh@ethanwu mobile % ./tsgolint
error creating TS program:
  ***/tsconfig.json: Option 'baseUrl' has been removed. Please remove it from your configuration.

If there are any problems, I'm happy to fix!

@graphite-app
Copy link
Copy Markdown

graphite-app bot commented Nov 1, 2025

How to use the Graphite Merge Queue

Add the label 0-merge to this PR to add it to the merge queue.

You must have a Graphite account in order to use the merge queue. Sign up using this link.

An organization admin has enabled the Graphite Merge Queue in this repository.

Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue.

@camc314
Copy link
Copy Markdown
Contributor

camc314 commented Nov 1, 2025

thanks for looking at this.

Just as a heads up, the non-headless entry points isn't maintained, and isn't recommended to be used.

oxlint-tsgolint should be called via oxlint

@7086cmd
Copy link
Copy Markdown
Contributor Author

7086cmd commented Nov 1, 2025

Yeah, and I understand it. However, when calling the oxlint via --type-aware, It would result to "failed to parse" the "null" value; after removing the wrong field in tsconfig this error disappears, so I assume it's related. Hence, there might be a way to report this (failed to create program) to oxlint side, on the other hamd.

@camc314
Copy link
Copy Markdown
Contributor

camc314 commented Nov 1, 2025

Yeah, and I understand it. However, when calling the oxlint via --type-aware, It would result to "failed to parse" the "null" value; after removing the wrong field in tsconfig this error disappears, so I assume it's related. Hence, there might be a way to report this (failed to create program) to oxlint side, on the other hamd.

can you share your versions of oxlint and tsgolint. it should report a diagnostic if this happens not crash

@7086cmd
Copy link
Copy Markdown
Contributor Author

7086cmd commented Nov 1, 2025

oxlint: ^1.24.0
oxlint-tsgolint: ^0.4.0

It simply failed to parse the tsgolint result (null) — it crashes on the Rust side while serializing.

Its result:

Error running tsgolint: "exit status: exit status: 0, error: Failed to parse tsgolint diagnostic payload: invalid type: null, expected path string at line 1 column 179"%

@7086cmd 7086cmd force-pushed the feat/create-report branch 2 times, most recently from 5dde6b1 to b1cdf57 Compare November 4, 2025 12:58
@camc314
Copy link
Copy Markdown
Contributor

camc314 commented Nov 4, 2025

oxlint: ^1.24.0 oxlint-tsgolint: ^0.4.0

It simply failed to parse the tsgolint result (null) — it crashes on the Rust side while serializing.

Its result:

Error running tsgolint: "exit status: exit status: 0, error: Failed to parse tsgolint diagnostic payload: invalid type: null, expected path string at line 1 column 179"%

Update to 1.25.0, and the issue should be fixed

@7086cmd
Copy link
Copy Markdown
Contributor Author

7086cmd commented Nov 4, 2025

Yeah. In oxlint --type-aware, it reported this. In tsgolint, it got a segfault. If there's no need to fix the bare executing way, closing this is okay. On the other hand, I think it's better to output diagnostic-like items, rather than directly showing an error, because tsgo gives the fix instruction?

@camc314 camc314 force-pushed the feat/create-report branch from 74d1602 to 3927c3f Compare November 4, 2025 13:54
@camc314 camc314 enabled auto-merge (squash) November 4, 2025 13:55
@camc314
Copy link
Copy Markdown
Contributor

camc314 commented Nov 4, 2025

Yeah. In oxlint --type-aware, it reported this. In tsgolint, it got a segfault. If there's no need to fix the bare executing way, closing this is okay. On the other hand, I think it's better to output diagnostic-like items, rather than directly showing an error, because tsgo gives the fix instruction?

The error in the next release is much better. this was just a first pass. https://x.com/Cameron_C2/status/1985342808916455739

@camc314 camc314 merged commit 82b0fee into oxc-project:main Nov 4, 2025
5 checks passed
@7086cmd 7086cmd deleted the feat/create-report branch November 5, 2025 10:08
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