Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[crash] Parsing error when processing a tsconfig file with comments #32

Closed
1 task done
shiftcontrol-dan opened this issue Apr 5, 2024 · 4 comments · Fixed by #33
Closed
1 task done

[crash] Parsing error when processing a tsconfig file with comments #32

shiftcontrol-dan opened this issue Apr 5, 2024 · 4 comments · Fixed by #33
Labels
bug Something isn't working

Comments

@shiftcontrol-dan
Copy link

What is the issue?

I tried using the plugin for the first time and immediately got this error.

What are the steps to reproduce this issue?

  1. Install the plugin
  2. Go to view->tools->shadcn/ui
  3. See WebStorm tell you to submit a bug

What were you expecting to happen?

For the plugin to render.

Paste any relevant logs, error output, etc.

kotlinx.serialization.json.internal.JsonDecodingException: Unexpected JSON token at offset 354: Expected quotation mark '"', but had '/' instead at path: $
JSON input: .....    "skipLibCheck": true,
    /* Bundler mode */
    "module.....
	at kotlinx.serialization.json.internal.JsonExceptionsKt.JsonDecodingException(JsonExceptions.kt:24)
	at kotlinx.serialization.json.internal.JsonExceptionsKt.JsonDecodingException(JsonExceptions.kt:32)
	at kotlinx.serialization.json.internal.AbstractJsonLexer.fail(AbstractJsonLexer.kt:598)
	at kotlinx.serialization.json.internal.AbstractJsonLexer.fail$default(AbstractJsonLexer.kt:596)
	at kotlinx.serialization.json.internal.AbstractJsonLexer.fail$kotlinx_serialization_json(AbstractJsonLexer.kt:233)
	at kotlinx.serialization.json.internal.AbstractJsonLexer.fail$kotlinx_serialization_json$default(AbstractJsonLexer.kt:228)
	at kotlinx.serial

<TRIMMED STACKTRACE>

What OS are you experiencing the problem on?

macOS

Additional platform information

Build version: WebStorm 2023.3.6 Build: #WS-233.15026.13 March 21, 2024
JRE: 17.0.10+1-b1087.23, JetBrains s.r.o.
JVM: 17.0.10+1-b1087.23, OpenJDK 64-Bit Server VM, JetBrains s.r.o.
Operating System: Mac OS X 14.4.1 (aarch64)

=== Plugins ===
Custom plugins: [Space (233.15026.16), .ignore (4.5.2), AI Assistant (233.15026.24), GitHub Copilot (1.5.2.5345), shadcn/ui Components Manager (0.7.7)]
Disabled plugins:[]

Duplicates

  • I have checked that my problem has not already been mentioned recently in an existing issue
@shiftcontrol-dan shiftcontrol-dan added the bug Something isn't working label Apr 5, 2024
@WarningImHack3r
Copy link
Owner

Hi there! I'm using a simple JSON decoder to parse the tsconfig.json, however as you used comments in yours (which is not supported by standard JSON files) it introduces a crash during parsing. I'll see if I can easily add support for JSON with comments, sorry for the issue!

@WarningImHack3r WarningImHack3r changed the title [crash] Unhandled exception in [StandaloneCoroutine{Cancelling}@4a87b7aa, Dispatchers.Default] [crash] Parsing error when processing a tsconfig file with comments Apr 5, 2024
@WarningImHack3r
Copy link
Owner

Update: after some research, the official Kotlinx.serialization I'm using has very recently merged support for JSON comments, which is the last feature they needed to fully support JSON5.

This means that I'm only waiting for a release from them containing this commit to fully support that.

In the meantime, you can bypass the issue by removing any non-standard JSON feature from your tsconfig.json (basically trailing commas, unquoted keys, and comments) to make the plugin work.

Note: I could also use libraries like https://github.com/xn32/json5k but I don't want to add another dependency for a tiny change that will be included within KxS very soon. As your issue is not blocking and doesn't affect everyone, I think it's reasonable.

@shiftcontrol-dan
Copy link
Author

Thanks,
Yes my file has some comments.
Happy to close this or leave it open until the upstream feature is availale.

@WarningImHack3r WarningImHack3r mentioned this issue Jun 7, 2024
1 task
@WarningImHack3r
Copy link
Owner

@shiftcontrol-dan @shimizu-izumi I realized that while this new release isn't out, I can try to manually remove comments of the file in-memory before passing it to the JSON parser, it's not optimal but not that hard to do and would fix the issue; the switch to a cleaner solution would later on be transparent for users

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants