# Elasticsearch nodejs client 8.2 msearch error

**URL:** <https://discuss.elastic.co/t/elasticsearch-nodejs-client-8-2-msearch-error/304132>\
**Category:** Elasticsearch\
**Tags:** language-clients\
**Created:** [May 6, 2022, 1:29pm UTC](https://discuss.elastic.co/t/elasticsearch-nodejs-client-8-2-msearch-error/304132 "2022-05-06T13:29:07Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Akaren](https://avatars.discourse-cdn.com/v4/letter/a/8dc957/32.png) [@Akaren](https://discuss.elastic.co/u/Akaren)\
**Post date:** [May 6, 2022, 1:29pm UTC](https://discuss.elastic.co/t/elasticsearch-nodejs-client-8-2-msearch-error/304132/1 "2022-05-06T13:29:08Z")

</div>

We have been using elastic node js client version 8.1.0 and updated to @elastic/Elasticsearch@8.2.0.  
Suddently our msearch query stopped working with

```auto
ResponseError: illegal_argument_exception: [illegal_argument_exception] Reason: The msearch request must be terminated by a newline []
 at SniffingTransport.request 
 at processTicksAndRejections (internal/process/task_queues.js:93:5)
at async Client.MsearchApi [as msearch] (xxx/node_modules/@elastic/elasticsearch/lib/api/api/msearch.js:51:12)

```

Our syntax didn't change and I haven't found that ES would change syntax.

I am auto-generating all msearch queries with

```auto
requestList.push(
          {
            index: requests[j].index //index name as string
          },
          requests[j].query //predefine json templates {query: {bool: xxx}}
        );

```

and than putting it into msearch

```auto
const response = await client.msearch({
        searches: requestList
      })

```

I tried to stringify and add \n at the end of body (or after index) but didn't work. Any idea what to do?

---

<div class="post-metadata">

**Author:** ![delvedor](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/delvedor/32/67639_2.png) [@delvedor](https://discuss.elastic.co/u/delvedor)\
**Post date:** [May 6, 2022, 2:02pm UTC](https://discuss.elastic.co/t/elasticsearch-nodejs-client-8-2-msearch-error/304132/2 "2022-05-06T14:02:35Z")

</div>

Hello! This is a bug present in the v8.2.0 release (see [Bulk request broken on 8.2.0, "The bulk request must be terminated by a newline [\\n]" error · Issue #1686 · elastic/elasticsearch-js · GitHub](https://github.com/elastic/elasticsearch-js/issues/1686)). It has been fixed in [Fix ndjson APIs by delvedor · Pull Request #1688 · elastic/elasticsearch-js · GitHub](https://github.com/elastic/elasticsearch-js/pull/1688), and it will be released in v8.2.1 soon.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [June 3, 2022, 2:02pm UTC](https://discuss.elastic.co/t/elasticsearch-nodejs-client-8-2-msearch-error/304132/3 "2022-06-03T14:02:59Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
