Elasticsearch Nodes Crash After Attempt to Create Scripted Filed

Hello Community,
I am trying to create a scripted field.
I want to parse a string into a date format.
I have created the following script

DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
LocalDateTime localDateTime = LocalDateTime.parse(doc['closed_at.keyword'].value, formatter);
return localDateTime;

The above works well in the Painless Lab.

When I am trying to run it in the scripted field module (Under index patterns), I am getting an error

{
 "root_cause": [
  {
   "type": "node_disconnected_exception",
   "reason": "[Node4][IP:9300][indices:data/read/search[phase/query]] disconnected"
  }
 ],
 "type": "search_phase_execution_exception",
 "reason": "all shards failed",
 "phase": "query",
 "grouped": true,
 "failed_shards": [
  {
   "shard": 0,
   "index": "my-index",
   "node": "wKXfVA24TgugQ_bCVs8wVR",
   "reason": {
    "type": "node_disconnected_exception",
    "reason": "[Node4][IP:9300][indices:data/read/search[phase/query]] disconnected"
   }
  }
 ]
}

GET /_cluster/health after first run

{
"cluster_name" : "name",
"status" : "green",
"timed_out" : false,
"number_of_nodes" : 5,
"number_of_data_nodes" : 5,
"active_primary_shards" : 802,
"active_shards" : 1604,
"relocating_shards" : 0,
"initializing_shards" : 0,
"unassigned_shards" : 0,
"delayed_unassigned_shards" : 0,
"number_of_pending_tasks" : 0,
"number_of_in_flight_fetch" : 0,
"task_max_waiting_in_queue_millis" : 0,
"active_shards_percent_as_number" : 100.0
}

When pressing the 'Run Script' in a consecutive second time, 2 nodes out of 5 crash and cluster turns tither to yellow or red.

Cheers!

What do the Elasticsearch logs show?

Haven't seen anything critical there.
I am monitoring it still.
Cheers!

If Elasticsearch is crashing then the logs will contain something useful.