Replicator unable to read from source DB

I’m trying to use replicator tool to move events from ES DB 5.0.9 to ES DB 22.10.2.
I tried to run only replicator in Docker Desktop (Windows) but was having trouble establishing tcp connection to local ES DB 5.0.9, it failed to connect with connection refused error. Tried running docker image with network_mode:host but it did not help. (required TCP ports on local machine 1113,1114 have status listening).
reader connection string is:
ConnectTo=tcp://admin:[email protected]:1113;DefaultUserCredentials=admin:changeit;UseSslConnection=false;HeartBeatTimeout=500;
sink connection string is:
esdb://admin:[email protected]:1114?tls=false&tlsVerifyCert=false

Then I tried running everything, replicator and both versions of ESDB, in Docker, with respective data folders mounted from my local machine, then replicator tool successfully starts but after reading 1024 events it stops with an error
“t”:“2023-06-05T12:47:38.3795015Z”,“m”:“Error occured in the "PrepareContext" pipe: "One or more errors occurred. (Line 1: Unexpected end of input)"”,“i”:“c9acd0a5”,“l”:“Error”,“x”:"System.AggregateException: One or more errors occurred. (Line 1: Unexpected end of input)\n —> Esprima.ParserException: Line 1: Unexpected end of input\n at Jint.Native.Json.JsonParser.ThrowError(Token token, String messageFormat, Object[] arguments)\n at Jint.Native.Json.JsonParser.ThrowUnexpected(Token token)\n at Jint.Native.Json.JsonParser.ParseJsonValue()\n at Jint.Native.Json.JsonParser.Parse(String code, ParserOptions options)\n at Jint.Native.Json.JsonParser.Parse(String code)\n at EventStore.Replicator.JavaScript.JsTransform.Transform(OriginalEvent original, CancellationToken cancellationToken) in /app/src/EventStore.Replicator.JavaScript/JsTransform.cs:line 77\n at EventStore.Replicator.Prepare.TransformFilter.<>c__DisplayClass2_0.<g__Transform|2>d.MoveNext() in /app/src/EventStore.Replicator/Prepare/TransformFilter.cs:line 37

No writes occur on target ESDB.

UPDATE: I have managed to start replicator tool by using “host.docker.internal” instead of in connection strings, and setting http port (2114) in grpc connection instead of tcp port (1114). Now events are replicating, but I have a problem with transform function. It fails on some events and it stops the replication process. I even tried removing everything from transformation function and just returning original event, but no success. All events I have in source DB have JSON as payload.
Error I get is:
“Error occured in the "PrepareContext" pipe: "One or more errors occurred. (Line 1: Unexpected end of input)"”,“i”:“c9acd0a5”,“l”:“Error”,“x”:“System.AggregateException: One or more errors occurred.”

If I exclude transform from replicator.yml replication runs just fine.