nest: TypeError: domain.enter is not a function
Bug Report
I am experiencing a bug for > 4 days and I can’t get around it.
Current behavior
Any controller returns result, I’d see in the console the following stacktrace with no further details:
domain.js:547
domain.enter();
^
TypeError: domain.enter is not a function
at IncomingMessage.EventEmitter.emit (domain.js:547:10)
at resume_ (_stream_readable.js:972:10)
at processTicksAndRejections (internal/process/task_queues.js:80:21)
I can’t find the root cause or whose reporting this stacktrace. but 2 things I noticed:
- Winston is not seeing that error and it’s not reporting it, because the error is not reported within such line
[NestWinston] Info 12/20/2020, 8:36:04 PM log info, it just simply crash with the error written with no nestjs or anything in it. - API is no longer working after this happens.
I am just starting the application normally using nest start -w
main.ts doesnt’ have anything interesting than what is mentioned in the documentation, this error started happening after migrating from typeorm to mikro-orm, but mikro-orm` team confirmed it’s not related to them see https://github.com/mikro-orm/mikro-orm/issues/1220 . 🤷♂️
I am using nestjs mysql session, please see my package.json dependencies below for details of what packages i’m using.
What is leading to it, no idea. The stack trace is very generic. and click on file domain.js:547:10 is not working as if the file doesn’t exist.
I turned on silly debugging but again no details on what’s happening to lead to this. I checked https://docs.nestjs.com/faq/request-lifecycle#summary where I can understand at which point this is happening:
Incoming request
Globally bound middleware
Module bound middleware << Used
Global guards
Controller guards
Route guards
Global interceptors (pre-controller)
Controller interceptors (pre-controller)
Route interceptors (pre-controller)
Global pipes
Controller pipes
Route pipes
Route parameter pipes
Controller (method handler) << used (returns but no response can be observed from the browser - the error happens after the return)
Service (if exists)
Route interceptor (post-request)
Controller interceptor (post-request)
Global interceptor (post-request)
Exception filters (route, then controller, then global)
Server response
Input Code
No specific code that reproduces it and I don’t know where.
const your = (code) => here;
Expected behavior
The controller should be able to return, I can confirm that the controller must be returning something but something happens wrong in-between the controller and the response.
controller {
someMethod() {
.... some code
console.log('return is going to happen'); // this is how i confirmed
return something;
}
}
Possible Solution
I need help in finding a way to know why is this error happening?
Environment
Here is project dependencies, i tried both node versions 12 and 14:
"dependencies": {
"@angular/animations": "~10.1.4",
"@angular/cdk": "^10.2.3",
"@angular/common": "~10.1.4",
"@angular/compiler": "~10.1.4",
"@angular/core": "~10.1.4",
"@angular/forms": "~10.1.4",
"@angular/localize": "^10.0.4",
"@angular/material": "^10.2.3",
"@angular/platform-browser": "~10.1.4",
"@angular/platform-browser-dynamic": "~10.1.4",
"@angular/router": "~10.1.4",
"@fortawesome/angular-fontawesome": "^0.7.0",
"@fortawesome/fontawesome-svg-core": "^1.2.30",
"@fortawesome/free-brands-svg-icons": "^5.14.0",
"@fortawesome/free-regular-svg-icons": "^5.14.0",
"@fortawesome/free-solid-svg-icons": "^5.14.0",
"@mikro-orm/core": "^4.3.4",
"@mikro-orm/mariadb": "^4.3.4",
"@mikro-orm/mysql": "^4.3.4",
"@mikro-orm/nestjs": "^4.2.0",
"@mikro-orm/reflection": "^4.3.4",
"@mikro-orm/sql-highlighter": "^1.0.1",
"@nestjs/common": "^7.5.1",
"@nestjs/core": "^7.5.1",
"@nestjs/passport": "^7.1.0",
"@nestjs/platform-express": "^7.5.1",
"@nestjs/schedule": "^0.4.1",
"@nestjs/swagger": "^4.6.1",
"@ng-bootstrap/ng-bootstrap": "^7.0.0",
"@tinymce/tinymce-angular": "^4.1.0",
"angular-calendar": "^0.28.16",
"angular-google-charts": "^1.1.4",
"basic-auth": "^2.0.1",
"bootstrap": "^4.5.0",
"class-transformer": "^0.3.1",
"class-validator": "^0.12.2",
"clipboard": "^2.0.6",
"cookie-parser": "^1.4.5",
"core-js": "^3.6.5",
"credit-card-type": "^9.1.0",
"cryptojs": "^2.5.3",
"date-fns": "^2.15.0",
"express": "^4.17.1",
"express-list-routes": "^0.1.4",
"express-mysql-session": "^2.1.4",
"express-session": "^1.17.1",
"font-awesome": "^4.7.0",
"helmet": "^4.1.1",
"imap": "^0.8.19",
"jquery": "^3.5.1",
"locutus": "^2.0.14",
"mermaid": "^8.6.0",
"mikro-orm": "^4.3.4",
"monaco-editor": "^0.20.0",
"mysql": "^2.18.1",
"nest-winston": "^1.4.0",
"nestjs-mikro-orm": "^1.0.3",
"nestjs-session": "^1.0.1",
"ng-pick-datetime": "^7.0.0",
"ngx-avatar": "^4.0.0",
"ngx-bootstrap": "^5.6.1",
"ngx-clipboard": "^13.0.1",
"ngx-cookie-service": "^3.0.4",
"ngx-monaco-editor": "^9.0.0",
"node-cryptojs-aes": "^0.4.0",
"passport": "^0.4.1",
"passport-local": "^1.0.0",
"reflect-metadata": "^0.1.13",
"rimraf": "^3.0.2",
"rxjs": "~6.6.0",
"swagger-ui-express": "^4.1.4",
"tslib": "^2.0.0",
"winston": "^3.3.3",
"xlsx": "^0.16.8",
"zone.js": "~0.10.2"
},
"devDependencies": {
"@angular-devkit/build-angular": "~0.1001.4",
"@angular/cli": "~10.1.4",
"@angular/compiler-cli": "~10.1.4",
"@angular/language-service": "^10.0.4",
"@compodoc/compodoc": "^1.1.11",
"@nestjs/cli": "^7.5.1",
"@nestjs/schematics": "^7.1.3",
"@nestjs/testing": "^7.5.1",
"@types/clipboard": "^2.0.1",
"@types/cryptojs": "^3.1.29",
"@types/express": "^4.17.3",
"@types/express-session": "^1.17.3",
"@types/imap": "^0.8.31",
"@types/jasmine": "~3.5.0",
"@types/jasminewd2": "~2.0.3",
"@types/jest": "26.0.10",
"@types/jquery": "^3.5.4",
"@types/jqueryui": "^1.12.13",
"@types/node": "12.12.41",
"@types/passport-local": "^1.0.33",
"@types/supertest": "^2.0.8",
"@types/webpack-env": "^1.15.3",
"@typescript-eslint/eslint-plugin": "3.9.1",
"@typescript-eslint/parser": "3.9.1",
"codelyzer": "^6.0.0",
"eslint": "7.7.0",
"eslint-config-prettier": "^6.11.0",
"eslint-plugin-import": "^2.20.1",
"eslint-plugin-prettier": "^3.1.3",
"husky": "^4.2.5",
"jasmine-core": "~3.6.0",
"jasmine-spec-reporter": "~5.0.0",
"jest": "26.4.2",
"karma": "~5.0.0",
"karma-chrome-launcher": "~3.1.0",
"karma-coverage-istanbul-reporter": "~3.0.2",
"karma-jasmine": "~4.0.0",
"karma-jasmine-html-reporter": "^1.5.0",
"npm-run-all": "^4.1.5",
"prettier": "^1.19.1",
"pretty-quick": "^2.0.1",
"protractor": "~7.0.0",
"supertest": "^4.0.2",
"ts-jest": "26.2.0",
"ts-loader": "^6.2.1",
"ts-node": "9.0.0",
"tsconfig-paths": "^3.9.0",
"tslint": "~6.1.0",
"typescript": "~4.0.2",
"wait-on": "^5.2.0",
"webpack-env": "^0.8.0"
},
Nest version: X.Y.Z
For Tooling issues:
- Node version: XX
- Platform:
Others:
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 18 (7 by maintainers)
Sure, so I reviewed my middlewares and the changes they do, so apparently, I was overriding
req.domainvariable, all i did is adding a prefix to my variables that i was attaching to thereqto make sure they are isolated from anydefault/built-invariables, and it worked.