Comparing version
{ | ||
"name": "kafkajs", | ||
"version": "1.15.0-beta.12", | ||
"version": "1.15.0-beta.13", | ||
"description": "A modern Apache Kafka client for node.js", | ||
@@ -83,5 +83,5 @@ "author": "Tulio Ornelas <ornelas.tulio@gmail.com>", | ||
"kafkajs": { | ||
"sha": "a79fc9e45f6c8cd2695e23cfb7689bb824fb86a0", | ||
"compare": "https://github.com/tulios/kafkajs/compare/v1.14.0...a79fc9e45f6c8cd2695e23cfb7689bb824fb86a0" | ||
"sha": "5b90d16106eb0372d23c6d31ee139958797ec5a2", | ||
"compare": "https://github.com/tulios/kafkajs/compare/v1.14.0...5b90d16106eb0372d23c6d31ee139958797ec5a2" | ||
} | ||
} |
@@ -0,1 +1,3 @@ | ||
const pkgJson = require('../package.json') | ||
class KafkaJSError extends Error { | ||
@@ -181,2 +183,15 @@ constructor(e, { retriable = true } = {}) { | ||
const issueUrl = pkgJson.bugs.url | ||
class KafkaJSInvariantViolation extends KafkaJSNonRetriableError { | ||
constructor(e) { | ||
const message = e.message || e | ||
super(`Invariant violated: ${message}. This is likely a bug and should be reported.`) | ||
this.name = 'KafkaJSInvariantViolation' | ||
const issueTitle = encodeURIComponent(`Invariant violation: ${message}`) | ||
this.helpUrl = `${issueUrl}/new?assignees=&labels=bug&template=bug_report.md&title=${issueTitle}` | ||
} | ||
} | ||
module.exports = { | ||
@@ -205,2 +220,3 @@ KafkaJSError, | ||
KafkaJSUnsupportedMagicByteInMessageSet, | ||
KafkaJSInvariantViolation, | ||
} |
const EventEmitter = require('events') | ||
const SocketRequest = require('./socketRequest') | ||
const events = require('../instrumentationEvents') | ||
const { KafkaJSInvariantViolation } = require('../../errors') | ||
@@ -134,2 +135,5 @@ const PRIVATE = { | ||
send: () => { | ||
if (this.inflight.has(correlationId)) { | ||
throw new KafkaJSInvariantViolation('Correlation id already exists') | ||
} | ||
this.inflight.set(correlationId, socketRequest) | ||
@@ -136,0 +140,0 @@ pushedRequest.sendRequest() |
637220
0.12%18890
0.08%