Print diagnostics when a protoplugin fails to emit files#1003
Merged
timostamm merged 3 commits intobufbuild:mainfrom Oct 31, 2024
Merged
Print diagnostics when a protoplugin fails to emit files#1003timostamm merged 3 commits intobufbuild:mainfrom
timostamm merged 3 commits intobufbuild:mainfrom
Conversation
timostamm
approved these changes
Oct 31, 2024
Member
timostamm
left a comment
There was a problem hiding this comment.
In general, I recommend the following approach if transpilation fails:
- Generate the same input with the plugin option
target=tsto local files - Compile the local files with TypeScript v5.4.5 (the version that transpilation uses)
- Inspect errors in an IDE
This will give you all error details, and let's you iterate quickly. Of course it's still helpful to print diagnostics, so thanks for the PR!
I've pushed up 7e17860 to use the TypeScript compiler to format diagnostics (it handles locations and error chains):
A problem occurred during transpilation and files were not generated. Contact the plugin author for support.
test.ts(3,17): error TS4033: Property 'p' of exported interface has or is using private name 'P'.
test.ts(8,17): error TS4033: Property 'p' of exported interface has or is using private name 'P'.
test.ts(13,17): error TS4033: Property 'p' of exported interface has or is using private name 'P'.
2 more diagnostics elided
It also prints at most three diagnostics because the error message can potentially grow to megabytes of text.
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When trying to publish a custom plugin to the BSR, I had some trouble figuring out why it was failing to generate an SDK.
I ended up debugging the problem by implementing a custom transpiler that prints extra diagnostic information when results are skipped, since these errors show up in the npm install log when it fails to generate.
So, this seems like it could be useful for others trying to debug SDK generation failures in the future.
This generates an error like: