Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bulk helper not giving indications on failure when using stream as datasource #2085

Open
CptSchnitz opened this issue Nov 27, 2023 · 2 comments

Comments

@CptSchnitz
Copy link

🐛 Bug Report

When using the bulk helper function, the function doesn't throw, or doesn't notify on failures using any other mechanism i have found (onDrop \ result errors).
I have set the node value for a URL that doesn't have an elastic cluster listening on.
When you use stream datasource nothing happens, but when the datasource is array an exception is thrown.

To Reproduce

Run the following code and swap between the datasources to see the different behaviours.
make sure the client is pointed to an address with no cluster running.

  • When its stream nothing gets printed.
  • When its array a connection refused error gets printed to the console.

Paste your code here:

import stream from "stream";
import { Client } from "@elastic/elasticsearch";

const client = new Client({ node: "http://localhost:9200" });

const readStream = new stream.Readable({
  objectMode: true,
  read() {},
});

readStream.push({ id: 1, title: "foo" });
readStream.push({ id: 2, title: "bar" });

try {
  const result = await client.helpers.bulk({
    // datasource: [{ id: 1, title: "foo" }, { id: 2, title: "bar" }],
    datasource: readStream,
    onDocument(doc) {
      return {
        index: { _index: "my-index3", _id: doc.id },
      };
    },
    timeout: "1s",
    retries: 1,
    onDrop(doc) {
      console.log(doc);
    },
  });

  console.log(result.errors)
} catch (error) {
  console.error(error);
} 

Expected behavior

You have a way to detect such errors, either if they are thrown or by an event handler.

Your Environment

  • node version: v20.9.0 | v18.18.2
  • @elastic/elasticsearch version: =8.10.0
  • os: Ubuntu 20.04.6 LTS
Copy link
Contributor

This issue is stale because it has been open 90 days with no activity. Remove the stale label, or leave a comment, or this will be closed in 14 days.

@github-actions github-actions bot added the stale label Feb 28, 2024
@JoshMock JoshMock removed the stale label Feb 28, 2024
@JoshMock JoshMock self-assigned this Jun 7, 2024
@JoshMock JoshMock removed their assignment Jul 29, 2024
Copy link
Contributor

This issue is stale because it has been open 90 days with no activity. Remove the stale label, or leave a comment, or this will be closed in 14 days.

@github-actions github-actions bot added the stale label Oct 28, 2024
@JoshMock JoshMock removed the stale label Oct 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants