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

heartbeat undefined #232

Open
ernestang98 opened this issue Feb 24, 2022 · 0 comments
Open

heartbeat undefined #232

ernestang98 opened this issue Feb 24, 2022 · 0 comments

Comments

@ernestang98
Copy link

Use case:

Using Nest.js with RabbitMQ. When attempting to push a message from client to queue, this error is thrown in the logs:

{
  err: TypeError: Cannot read property 'heartbeat' of undefined
      at /path/to/project/node_modules/amqp-connection-manager/dist/cjs/AmqpConnectionManager.js:229:42
      at processTicksAndRejections (internal/process/task_queues.js:95:5),
  url: undefined
}

Package.json file:

{
  "name": "nest2",
  "version": "0.0.1",
  "description": "",
  "author": "",
  "private": true,
  "license": "UNLICENSED",
  "scripts": {
    "prebuild": "rimraf dist",
    "build": "nest build",
    "format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"",
    "start": "nest start",
    "start:dev": "nest start --watch",
    "start:debug": "nest start --debug --watch",
    "start:prod": "node dist/main",
    "lint": "eslint \"{src,apps,libs,test}/**/*.ts\" --fix",
    "test": "jest",
    "test:watch": "jest --watch",
    "test:cov": "jest --coverage",
    "test:debug": "node --inspect-brk -r tsconfig-paths/register -r ts-node/register node_modules/.bin/jest --runInBand",
    "test:e2e": "jest --config ./test/jest-e2e.json"
  },
  "dependencies": {
    "@nestjs/axios": "^0.0.5",
    "@nestjs/common": "^8.0.0",
    "@nestjs/config": "^1.1.6",
    "@nestjs/core": "^8.0.0",
    "@nestjs/microservices": "^8.3.1",
    "@nestjs/mongoose": "^9.0.1",
    "@nestjs/platform-express": "^8.0.0",
    "@nestjs/serve-static": "^2.2.2",
    "@nestjs/swagger": "^5.2.0",
    "@types/multer-gridfs-storage": "^4.0.4",
    "amqp-connection-manager": "^4.1.1",
    "amqplib": "^0.8.0",
    "form-data": "^4.0.0",
    "mongo-gridfs": "^1.1.0",
    "mongoose": "^6.0.13",
    "multer-gridfs-storage": "^5.0.2",
    "reflect-metadata": "^0.1.13",
    "rimraf": "^3.0.2",
    "rxjs": "^7.2.0"
  },
  "devDependencies": {
    "@nestjs/cli": "^8.0.0",
    "@nestjs/schematics": "^8.0.0",
    "@nestjs/testing": "^8.0.0",
    "@types/express": "^4.17.13",
    "@types/jest": "27.0.2",
    "@types/node": "^16.0.0",
    "@types/supertest": "^2.0.11",
    "@typescript-eslint/eslint-plugin": "^5.0.0",
    "@typescript-eslint/parser": "^5.0.0",
    "eslint": "^8.0.1",
    "eslint-config-prettier": "^8.3.0",
    "eslint-plugin-prettier": "^4.0.0",
    "jest": "^27.2.5",
    "prettier": "^2.3.2",
    "source-map-support": "^0.5.20",
    "supertest": "^6.1.3",
    "ts-jest": "^27.0.3",
    "ts-loader": "^9.2.3",
    "ts-node": "^10.0.0",
    "tsconfig-paths": "^3.10.1",
    "typescript": "^4.3.5"
  },
  "jest": {
    "moduleFileExtensions": [
      "js",
      "json",
      "ts"
    ],
    "rootDir": "src",
    "testRegex": ".*\\.spec\\.ts$",
    "transform": {
      "^.+\\.(t|j)s$": "ts-jest"
    },
    "collectCoverageFrom": [
      "**/*.(t|j)s"
    ],
    "coverageDirectory": "../coverage",
    "testEnvironment": "node"
  }
}

url supplied to nest.js project:

amqp://localhost:5672/VIRTUAL_HOST_NAME?heartbeat=30

Line 229 of AmqpConnectionManager.js:

originalUrl = url;
connect = {
    ...url,
    // heartbeat: (_a = url.heartbeat) !== null && _a !== void 0 ? _a : this.heartbeatIntervalInSeconds, -> original code
    heartbeat: 30 -> my edits
};

Is there some way to auto set heartbeat variable directly?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant