The disconnection process in kafkajs seems to be pretty slow

I rely on kafkajs for running automated tests.

When I execute the command await consumer.disconnect(), it usually takes approximately 5 seconds. Are there any alternative methods for ensuring a safe and quicker disconnect?

    const consumer = this.client.consumer({
        groupId: this.groupId,
        heartbeatInterval: this.heartbeatInterval,
        sessionTimeout: this.sessionTimeout,
    });

    await consumer.connect();
    await consumer.subscribe({ topics: [topic], fromBeginning });
    await consumer.run({...});
    await this.disconnect(consumer);

Answer №1

The server will wait for a maximum duration in milliseconds before responding to the fetch request if there is not enough data available to meet the minBytes requirement

const consumer = this.client.consumer({
    minBytes: 0,
    // alternatively
    maxWaitTimeInMs: 0,
    ...
});

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Embedding content from another website onto my website

I'm in search of a solution to incorporate a part of another website into my own. Is it possible to do this using an iframe? And if so, how can I specify that only a specific section should be displayed? For instance, if the other website contains: ...

At times, Mongoose may return null, while other times it returns data frequently

I have designed a unique mongoose schema for managing contacts, with a custom defined ID. Here is the schema structure: const mongooseSchema = new mongoose.Schema({ _id:{ type:String, unique:true, required:true }, firstN ...

Contrasting Element.value versus Element.getAttribute("value")

Can anyone clarify the distinction between these two options? I've observed that they can sometimes yield varying outcomes. ...

Update Material-ui to include an inclusive Datepicker widget

I have integrated the Material-ui Datepicker into my website to allow users to download timed event information from a database. The issue I am facing is that when users select two bracketing dates, events for the end date are not showing up correctly. F ...

Using TypeScript to deserialize JSON into a Discriminated Union

Consider the following Typescript code snippet: class Excel { Password: string; Sheet: number; } class Csv { Separator: string; Encoding: string; } type FileType = Excel | Csv let input = '{"Separator": ",", "Encoding": "UTF-8"}&ap ...

Replace the DIV tag with an Iframe that automatically refreshes

I do not possess coding knowledge, but I have a code with a div containing some content along with a flash file. I am looking to refresh the contents every 30 seconds. Please help add auto-refresh functionality to the content code. <!-- BEGIN: ...

Preventing the "Stop Script?" Popup in Internet Explorer

My application includes some Javascript code that requires a significant amount of computation. To ensure the UI remains responsive, I have divided the code into smaller chunks and utilized Angular's $timeout function to execute each chunk separately. ...

Is it possible to create two subclasses where the methods return the types of each other?

I am faced with a situation where I have two classes that rely on each other's methods: class City { (...) mayor(): Person { return this.people[0]; } } class Person { (...) birthCity(): City { return this.cities.birth; } } ...

Utilizing jQuery's unobtrusive validation to retrieve server responses and seamlessly showcase them

I'm currently working on a form that looks like this: @using (Html.BeginForm("DoRegister", "User", FormMethod.Post)) { @Html.AntiForgeryToken() <div class="inputBox"> @Html.TextBoxFor(m => m.FirstName, n ...

keep information separate from a react component and generate state based on it

Is it considered acceptable to store data outside of a react component and update it from within the component in order to derive state? This method could be useful for managing complex deep-nested states. import React from "react"; let globalSt ...

Effect triggers the swapping of div elements

Is there a way to prevent these divs from shifting positions following an effect? To see the issue, please visit this fiddle: https://jsfiddle.net/d1gxuLn8/1/ View full screen result here: https://jsfiddle.net/d1gxuLn8/1/embedded/result/ ...

Utilizing ngFor to iterate over items within an Observable array serving as unique identifiers

Just starting out with Angular and I'm really impressed with its power so far. I'm using the angularfire2 library to fetch two separate lists from firebase (*.ts): this.list1= this.db.list("list1").valueChanges(); this.list2= this.db.list("list2 ...

A TypeScript interface creating a type with optional keys of various types while enforcing strict null checks

I am attempting to devise an interface in typescript that resembles the following: type MoveSpeed = "min" | "road" | "full"; interface Interval { min?: number, max?: number } interface CreepPlan { [partName: string] : Interval; move?: MoveSpe ...

Error: Attempting to access the 'HTML' property of an undefined value

Encountering an unusual error while working with Angular 2.0 RC4 Cannot read property 'HTML' of undefined Error in index.html file <!doctype html> <html> <head> <meta charset="utf-8"> <title>My th</title&g ...

Sorting Values in an Array with Various Categories

In my project, I'm faced with the challenge of filtering an array that contains JSON objects retrieved using the SHOPIFY API. These objects represent blog posts and have metafields for location and age range. While I can successfully apply filters sep ...

Guide on concatenating the output values using jQuery

After selecting the matched records from the database, I returned to the previous page. Although I retrieved all the values, I am unsure how to append these return values on this page. What I need is to replace ROOM 2, Room 3... with the value in value.roo ...

What is causing the error "has no properties in common with" in this wrapped styled-component?

When looking at the following code, Typescript is flagging an error on <HeaderInner>: [ts] Type '{ children: Element; }' has no properties in common with type 'IntrinsicAttributes & Pick & Partial>, "className"> & ...

Connect select with an array of objects and showcase information when an item is chosen from the dropdown menu

I have an array $scope.items= [ { name: "Jon Snow", email: "jon@example.com", password: "WinterIsComing" }, { name: "Daenerys Targaryen", email: "daenerys@example.com", password: "FireAndBlood" } ]; Now, I am trying to show the email value in a dropdown ...

What is the best way to delete an added element once a DIV has been toggled with JQuery?

I'm facing an issue where I need to add an element to a DIV that has a toggle function. However, every time I click the toggle again after adding the element, the same element is appended once more, resulting in duplicate elements. Upon observation, ...

Utilizing Jquery to Attach Events to Multiple Instances Across a Webpage

I have successfully created a script that works perfectly, but now I am facing an issue with replicating it on a page. The jQuery script manipulates textarea boxes based on button clicks, however, I require each textarea box to have its own set of buttons. ...