I just ran into a situation while working on the Session Kit unit tests, where I was reusing the same Action over and over again in multiple tests, and while using the resulting Action in the serializer I started getting this error:
Error: assertion failure with message: datastream attempted to read past the end
When running individual tests in isolation... the bug wouldn't occur, it'd only occur when I was running bulk unit tests that utilized the same Action. So I started debugging and noticed this instance of parameter mutation on Action.from(). By simply tweaking this to not mutate the function parameter, the error message above no longer occurs.
All this change does is renames the input parameter and then creates a new reassignable let that had the previous name, allowing the code to continue on as normal without mutating the input parameter.
I just ran into a situation while working on the Session Kit unit tests, where I was reusing the same
Action
over and over again in multiple tests, and while using the resultingAction
in the serializer I started getting this error:When running individual tests in isolation... the bug wouldn't occur, it'd only occur when I was running bulk unit tests that utilized the same
Action
. So I started debugging and noticed this instance of parameter mutation onAction.from()
. By simply tweaking this to not mutate the function parameter, the error message above no longer occurs.All this change does is renames the input parameter and then creates a new reassignable
let
that had the previous name, allowing the code to continue on as normal without mutating the input parameter.