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

Read chunked data from companion server #402

Merged
merged 1 commit into from
Dec 22, 2023

Conversation

ItsNiklas
Copy link
Contributor

Problem Description

While developing a new parser for competitive companion, a strange bug occurred where some problems did not consistently get transferred. Thinking that the problem was with the parser, this was investigated first. However, all problems were successfully sent.

Other companion clients were able to receive the problems, so I investigated cph. When not ignoring the error, the JSON.parse was throwing Error parsing problem from companion "SyntaxError: Incomplete string in JSON at position 64975".

This indicated that the buffer of the read() call was full and only a single chunk of data was being read. This only appeared on problems where the parsed test data was large enough to trigger this.

Solution

Changing the listener to data and parsing chunk now works for all submitted problems and contests.

@agrawal-d
Copy link
Owner

Awesome, thanks! What crazy URL are you parsing? 😝

@agrawal-d agrawal-d merged commit 165345b into agrawal-d:main Dec 22, 2023
4 checks passed
@ItsNiklas ItsNiklas deleted the fix-companion-stream branch December 22, 2023 13:45
@ItsNiklas
Copy link
Contributor Author

Awesome, thanks! What crazy URL are you parsing? 😝

The JSON content came from a zip containing sample test cases where the input can be orders of magnitude larger than what you would probably put on a website to parse. Probably why this was not an issue before.

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