Skip to content

Commit

Permalink
fix: verify that amqp wasnt closed when publishing
Browse files Browse the repository at this point in the history
  • Loading branch information
AVVS committed Nov 28, 2019
1 parent bef268a commit 1b7fb18
Show file tree
Hide file tree
Showing 3 changed files with 215 additions and 171 deletions.
22 changes: 11 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,23 +27,23 @@
},
"homepage": "https://github.com/microfleet/transport-amqp#readme",
"devDependencies": {
"@babel/cli": "^7.7.0",
"@babel/core": "^7.7.2",
"@babel/plugin-proposal-class-properties": "^7.7.0",
"@babel/plugin-transform-strict-mode": "^7.2.0",
"@babel/register": "^7.7.0",
"@makeomatic/deploy": "^9.4.1",
"@babel/cli": "^7.7.4",
"@babel/core": "^7.7.4",
"@babel/plugin-proposal-class-properties": "^7.7.4",
"@babel/plugin-transform-strict-mode": "^7.7.4",
"@babel/register": "^7.7.4",
"@makeomatic/deploy": "^9.5.0",
"babel-plugin-istanbul": "^5.2.0",
"benchmark": "^2.1.4",
"chai": "^4.2.0",
"codecov": "^3.6.1",
"cross-env": "^6.0.3",
"eslint": "^6.6.0",
"eslint": "^6.7.1",
"eslint-config-makeomatic": "^4.0.0",
"eslint-plugin-import": "^2.18.2",
"eslint-plugin-mocha": "^6.2.1",
"eslint-plugin-mocha": "^6.2.2",
"eslint-plugin-promise": "^4.2.1",
"eslint-plugin-unicorn": "^12.1.0",
"eslint-plugin-unicorn": "^13.0.0",
"jaeger-client": "^3.17.1",
"microtime": "^3.0.0",
"mocha": "^6.2.2",
Expand All @@ -56,7 +56,7 @@
"stdout-stream": "~1.x.x"
},
"dependencies": {
"@hapi/joi": "^16.1.7",
"@hapi/joi": "^16.1.8",
"@microfleet/amqp-coffee": "^1.3.1",
"bluebird": "^3.7.1",
"common-errors": "^1.0.5",
Expand All @@ -69,7 +69,7 @@
"lodash": "^4.17.15",
"object-hash": "^2.0.0",
"opentracing": "^0.14.4",
"pino": "^5.13.6",
"pino": "^5.14.0",
"uuid": "^3.3.3"
},
"files": [
Expand Down
10 changes: 9 additions & 1 deletion src/amqp.js
Original file line number Diff line number Diff line change
Expand Up @@ -881,7 +881,15 @@ class AMQPTransport extends EventEmitter {
? _message
: await serialize(_message, publishOptions);

const request = await this._amqp
const { _amqp: amqp } = this;
if (!amqp) {
// NOTE: if this happens - it means somebody
// called (publish|send)* after amqp.close()
// or there is an auto-retry policy that does the same
throw new InvalidOperationError('connection was closed');
}

const request = await amqp
.publishAsync(exchange, queueOrRoute, message, publishOptions);

// emit original message
Expand Down
Loading

0 comments on commit 1b7fb18

Please sign in to comment.