Error in looping through HSL JSON

Hi all,
I am using HSLJson library to parse a JSON returned from an API call.
My method works when called in singleton, but when I loop over it, it always fails on the 8th iteration (regardless of the number of vials. ie 9 or 10 or 11 vials).
When it fails, the entire Vantage method stops without error handling or cleaning up. The run history status still says ‘running’ but the run control window says ‘completed’. I often need to restart the Vantage to get everything
online again.

I’ve traced out all steps in the procedure below and it reliably stops on the same HSLJson (line 686, GetStringProperty of HSLJson). But this same code works the 7 times before it!

Apologies in advance for the length, but since the looping causes the error, I’d like to include the entire loop:

Part 1


Initialize HSLHttp object. Bring the array with the number of barcodes (tubes) in from main method. Begin the loop over each barcode.

Part 2


Send the request to ELN to get the UUID of the container from Barcode. This loops twice if it does not go through. The UUID is required for editing container details.

Part 3 (where the method stops on the 8th iteration)


Line 677: A new HSLJson object is created
Line 679: JSON response from HSLHttp is parsed into HSLJson object
Line 681: JSON array element is saved to same HSLJson object
Line 683: JSON property is retrieved from array element above
Line 686: “id” value is saved to a string. THIS IS WHERE IT CRASHES (only after 7 successes).
Line 688: JSON object is released each iteration.

Part 4


Error handling and sending a PATCH to shell.
These seem to work fine, but I included them incase I need to be closing the shell or file in a different way that might impact memory…

Part 5


The second PATCH to shell. Same as Part 4 but under a different end point. Seems to work fine but I’m unfamiliar with best memory handling practices.

Any glaring errors? To me it feels like a memory leak because of the way it just exits, this is supported by the loop compiling the leak. I released the JSON and HTTP (thats not shown in my code but I did and tested after reading the post) so I cant see any other place that a leak could be happening. Are they not releasing?

Is there a way I can trace the object contents or view them?

Thank you all for all your incredible support!!!
Kyle

1 Like

If you watch the task manager do you see an increased memory usage by run control as it’s going through the loop?

Edit:

There should be a set trace level function in the HSL JSON library. Do you have that set to debug? IDK if this will give you any additional information though.

1 Like

Thank you!
I turned traces on for both HTTP and JSON libs but it just confirmed that it does start the GetStringProperty but it does not finish it.

Below is a snip from a successful JSON parse:

The 7 in yellow is the loop number. The first 7 JSON parsing are always successful.
The blue is the barcode that was scanned and saved in an array. It is correct.
The black arrow is the release of the HTTP object.
The orange highlight is where the loop 8 stops. In this example it is successful and returns a correct UUID.
The red arrow shows the JSON object was released.
The green is the UUID again.

Now the next iteration:


Always iteration 8 (yellow).
Barcode looks like it was imported correctly.
HTTP object released.
Seems the JSON gets stuck when pulling from the property. I have checked the JSON it is in proper form from the HTTP object. Really just hits a wall and the whole method breaks without aborting or notification or cleanup…

Good call on task manager. I monitored memory but did not see any huge jump. There was a slight blip in the line when this began, I have 16GB of memory and if software sets memory limits locally I still might overflow the app limit without registering much on system (seen this before).

Wanted to update with a work-around…

I am saving the JSON as a string and used StrFind to find the first [“id”:] substring. Then I use StrMid to pull the UUID from there.

image

This takes the HSL JSON library out of the equation. The first test worked through 8 (I’ll test more next).

I never did get to the bottom of the root cause of the error, but wanted to share the (very VBA-like) workaround…

This has piqued my curiosity, and I’d be happy to still troubleshoot with ideas just so we might have a better understanding of the WHY here.

Thanks mnewsom for your help!

1 Like

Interesting! Glad you were able to find a work around.

Guessing you ruled out any possibility of the 7th tube/sample having some unique value that is causing an error already? e.g. ran different tubes, swapped the order, or changed any mock data?

That’s about all I got though!