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

Special handling for empty Json RPC Diagnostics #125

Merged
merged 2 commits into from
Jul 17, 2024

Conversation

kLabz
Copy link
Contributor

@kLabz kLabz commented Jul 17, 2024

See HaxeFoundation/haxe#11709 (which will be handled, but this will still be necessary for older Haxe nightlies)

@kLabz kLabz marked this pull request as draft July 17, 2024 07:07
@kLabz kLabz closed this Jul 17, 2024
@kLabz kLabz reopened this Jul 17, 2024
@kLabz
Copy link
Contributor Author

kLabz commented Jul 17, 2024

(nvm, I wasn't able to repro anymore with nightlies but that's because it only happens for multi files diagnostics...)

@kLabz kLabz marked this pull request as ready for review July 17, 2024 07:23
case DResult("") if (method == DisplayMethods.Diagnostics):
haxeDisplayProtocol.handleMessage(({
jsonrpc: Protocol.PROTOCOL_VERSION,
id: @:privateAccess haxeDisplayProtocol.nextRequestId - 1, // ew..
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would it make sense to use reflection to read id from message parameter to avoid having to guess what response callback might be waiting for a cleanup?
as far as I can see most writeMessage calls use an id field, except for notifications.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have no idea tbh :/ I just reused the ugly hack from 10 lines below

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah I saw that. when I think of e.g. rename feature it will send out lots of requests to resolve types of identifiers. I believe I only send them one by one, so they don't block other user requests. but I'm not sure if we can't run into a situation where there are two requests out?!
which would mean nextRequestId - 1 could hit the wrong one.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think that's currently possible as request handling is blocking (on Haxe compiler side at least), but yeah that doesn't sound ideal.

Afaiu, writeMessage there can only ever be called with either a RequestMessage or a NotificationMessage.

In the case of this diagnostics patch, we can safely cast message to RequestMessage and get the id. For the original hack, I'm not sure it's safe to assume we got an id, but I guess it'd still be better to try to read message.id and fallback to the hack only if that's null. That part seems a bit out of scope here though.

@AlexHaxe AlexHaxe merged commit 909d4a9 into vshaxe:master Jul 17, 2024
2 checks passed
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