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

properties.messageId came as undefined #13746

Closed
3 of 15 tasks
CosmicTiger opened this issue Jul 2, 2024 · 1 comment
Closed
3 of 15 tasks

properties.messageId came as undefined #13746

CosmicTiger opened this issue Jul 2, 2024 · 1 comment
Labels
needs triage This issue has not been looked into

Comments

@CosmicTiger
Copy link

Is there an existing issue for this?

  • I have searched the existing issues

Current behavior

First and foremost. Shout out to you on this framework and course. Has been the best investment I could ever have in my whole developer experience and I'm deeply thankful of what you have built within the community with NestJS. Now, if it's not too much to ask I would like to ask you about an issue I came up with the Inbox Pattern video in which after replicating exactly the same codebase as you (since the Outbox pattern video, even). I'm unable to receive within the rabbitmq channel the definition of the properties.messageId turning always as undefined. I already tried a couple approaches read around the Github Issues board of @nestjs and also most of the documentation regarding it. But unfortunately for some reason after from the Outbox Processor .

image

Error in behaviour raises after the request of creation at /buildings takes place by the following:
image

You are able to see that in that chunk of message. Several properties are undefined (which is kinda expected because they need the extra config). But the one regarding the messageId is set as undefined. I manage to make a bypass over this behaviour by reusing the same buildingId but I don't like that approach because I'm unable to understand what causes this issue. I hope to hear from you soon and thank you beforehand.

If anyone would like to check a little bit more regarding my codebase.

Minimum reproduction code

https://github.com/CosmicTiger/virtual-facility-nestjs-ms-extension/tree/main/apps

Steps to reproduce

With usage of docker:
Go to root directory of the project:

  1. Run docker compose up --build
  2. After run that in a separate terminal to test it run: curl -X POST http://localhost:3000/buildings -H "Content-Type: application/json" -d '{"name": "Yet another building"}'
  3. See possible behavior error

Expected behavior

Expected behavior. As in the microservice course of NestJS receive the message with the properties.messageId set.

Package

  • I don't know. Or some 3rd-party package
  • @nestjs/common
  • @nestjs/core
  • @nestjs/microservices
  • @nestjs/platform-express
  • @nestjs/platform-fastify
  • @nestjs/platform-socket.io
  • @nestjs/platform-ws
  • @nestjs/testing
  • @nestjs/websockets
  • Other (see below)

Other package

amqplib

NestJS version

10.0.0

Packages versions

{
  "name": "virtual-facility-nestjs-ms-extension",
  "version": "0.0.1",
  "description": "",
  "author": "",
  "private": true,
  "license": "UNLICENSED",
  "scripts": {
    "build": "nest build",
    "format": "prettier --write \"apps/**/*.ts\" \"libs/**/*.ts\"",
    "start": "nest start",
    "start:dev": "nest start --watch",
    "start:debug": "nest start --debug --watch",
    "start:prod": "node dist/apps/virtual-facility-nestjs-ms-extension/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 ./apps/virtual-facility-nestjs-ms-extension/test/jest-e2e.json"
  },
  "dependencies": {
    "@nestjs/common": "^10.0.0",
    "@nestjs/core": "^10.0.0",
    "@nestjs/mapped-types": "*",
    "@nestjs/microservices": "^10.3.10",
    "@nestjs/platform-express": "^10.0.0",
    "@nestjs/schedule": "^4.0.2",
    "@nestjs/terminus": "^10.2.3",
    "@nestjs/typeorm": "^10.0.2",
    "amqp-connection-manager": "^4.1.14",
    "amqplib": "^0.10.4",
    "class-transformer": "^0.5.1",
    "class-validator": "^0.14.1",
    "nats": "^2.28.0",
    "pg": "^8.12.0",
    "reflect-metadata": "^0.2.0",
    "rxjs": "^7.8.1",
    "typeorm": "^0.3.20"
  },
  "devDependencies": {
    "@nestjs/cli": "^10.0.0",
    "@nestjs/schematics": "^10.0.0",
    "@nestjs/testing": "^10.0.0",
    "@types/express": "^4.17.17",
    "@types/jest": "^29.5.2",
    "@types/node": "^20.3.1",
    "@types/supertest": "^6.0.0",
    "@typescript-eslint/eslint-plugin": "^6.0.0",
    "@typescript-eslint/parser": "^6.0.0",
    "eslint": "^8.42.0",
    "eslint-config-prettier": "^9.0.0",
    "eslint-plugin-prettier": "^5.0.0",
    "jest": "^29.5.0",
    "prettier": "^3.0.0",
    "source-map-support": "^0.5.21",
    "supertest": "^6.3.3",
    "ts-jest": "^29.1.0",
    "ts-loader": "^9.4.3",
    "ts-node": "^10.9.1",
    "tsconfig-paths": "^4.2.0",
    "typescript": "^5.1.3"
  },
  "jest": {
    "moduleFileExtensions": [
      "js",
      "json",
      "ts"
    ],
    "rootDir": ".",
    "testRegex": ".*\\.spec\\.ts$",
    "transform": {
      "^.+\\.(t|j)s$": "ts-jest"
    },
    "collectCoverageFrom": [
      "**/*.(t|j)s"
    ],
    "coverageDirectory": "./coverage",
    "testEnvironment": "node",
    "roots": [
      "<rootDir>/apps/",
      "<rootDir>/libs/"
    ],
    "moduleNameMapper": {
      "^@app/tracing(|/.*)$": "<rootDir>/libs/tracing/src/$1"
    }
  }
}

Node.js version

v21.6.1

In which operating systems have you tested?

  • macOS
  • Windows
  • Linux

Other

No response

@CosmicTiger CosmicTiger added the needs triage This issue has not been looked into label Jul 2, 2024
@kamilmysliwiec
Copy link
Member

You need to manually set the messageId

image

Code:

async dispatchWorkflowEvent(outbox: Outbox) {
  const rmqRecord = new RmqRecord(outbox.payload, {
    messageId: `${outbox.id}`,
  });
  await lastValueFrom(this.workflowsService.emit(outbox.type, rmqRecord));
}
@nestjs nestjs locked and limited conversation to collaborators Jul 3, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
needs triage This issue has not been looked into
2 participants