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

CRITICAL: TypeError: Cannot read property 'type' of undefined #33

Open
gaspard opened this issue Jul 10, 2018 · 5 comments
Open

CRITICAL: TypeError: Cannot read property 'type' of undefined #33

gaspard opened this issue Jul 10, 2018 · 5 comments

Comments

@gaspard
Copy link

gaspard commented Jul 10, 2018

This line is exploding:

https://github.com/vesper-framework/vesper/blob/master/src/index.ts#L115

I tried to understand why sometimes the connection options exist and why it sometimes does not exist.

The bug only appears if the UI triggers many operations at once, sending many async requests to the server. It fails both with postgres and sqlite.

This is a sad bug as it makes vesper unusable because random queries fail.

gaspard added a commit to gaspard/vesper that referenced this issue Jul 10, 2018
@pleerock
Copy link
Contributor

thanks for the PR but its not a fix. I never faced the issue you are describing, can you please elaborate and provide more information, some real reproduction?

@gaspard
Copy link
Author

gaspard commented Jul 11, 2018

Here is a demo of the bug in action:

vesper_bug

The first part of this gif shows the original vesper code.
The second part shows with the fix.

As you can see, batch operations fail with current vesper code but work fine with the fix I propose.

If you want to reproduce this, you can close this repo.

Use origin/vesper branch !!

https://github.com/lucidogen/lucidogen

The server is in packages/apps/todomvc-server, the client app is in packages/apps/todomvc.

You need to run npm i && npm run start in each of these directories.

(at the end of the gif, you can see the error reported in the terminal: due to ts-node, the file is wrong but when using tsc and then the JS file, it is effectively from index.js in vesper).

@AntonPuko
Copy link

AntonPuko commented Aug 29, 2018

@pleerock Hi, I have pretty the same issue, when trying to run many mutations simultaneously.
I get:

TypeError: this.connection.getMetadata is not a function
TypeError: this.connection.getMetadata is not a function
    at EntityManager.<anonymous> (D:\PROG\gm-intelligence\chatbot.gql-server\src\entity-manager\EntityManager.ts:575:42)
    at step (D:\PROG\gm-intelligence\chatbot.gql-server\node_modules\typeorm\entity-manager\EntityManager.js:32:23)
    at Object.next (D:\PROG\gm-intelligence\chatbot.gql-server\node_modules\typeorm\entity-manager\EntityManager.js:13:53)
    at D:\PROG\gm-intelligence\chatbot.gql-server\node_modules\typeorm\entity-manager\EntityManager.js:7:71
    at Promise (<anonymous>)
    at __awaiter (D:\PROG\gm-intelligence\chatbot.gql-server\node_modules\typeorm\entity-manager\EntityManager.js:3:12)
    at EntityManager.findOne (D:\PROG\gm-intelligence\chatbot.gql-server\node_modules\typeorm\entity-manager\EntityManager.js:431:16)
    at EntityManager.<anonymous> (D:\PROG\gm-intelligence\chatbot.gql-server\src\entity-manager\EntityManager.ts:620:21)
    at step (D:\PROG\gm-intelligence\chatbot.gql-server\node_modules\typeorm\entity-manager\EntityManager.js:32:23)
    at Object.next (D:\PROG\gm-intelligence\chatbot.gql-server\node_modules\typeorm\entity-manager\EntityManager.js:13:53)
    at EntityManager.<anonymous> (D:\PROG\gm-intelligence\chatbot.gql-server\src\entity-manager\EntityManager.ts:575:42)
TypeError: Cannot read property 'type' of undefined
    at D:\PROG\gm-intelligence\chatbot.gql-server\src\index.ts:141:60
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:188:7)
    at step (D:\PROG\gm-intelligence\chatbot.gql-server\node_modules\typeorm\entity-manager\EntityManager.js:32:23)
    at Object.next (D:\PROG\gm-intelligence\chatbot.gql-server\node_modules\typeorm\entity-manager\EntityManager.js:13:53)
    at D:\PROG\gm-intelligence\chatbot.gql-server\node_modules\typeorm\entity-manager\EntityManager.js:7:71
    at Promise (<anonymous>)
    at __awaiter (D:\PROG\gm-intelligence\chatbot.gql-server\node_modules\typeorm\entity-manager\EntityManager.js:3:12)
    at EntityManager.findOne (D:\PROG\gm-intelligence\chatbot.gql-server\node_modules\typeorm\entity-manager\EntityManager.js:431:16)
    at EntityManager.<anonymous> (D:\PROG\gm-intelligence\chatbot.gql-server\src\entity-manager\EntityManager.ts:620:21)
    at step (D:\PROG\gm-intelligence\chatbot.gql-server\node_modules\typeorm\entity-manager\EntityManager.js:32:23)
    at Object.next (D:\PROG\gm-intelligence\chatbot.gql-server\node_modules\typeorm\entity-manager\EntityManager.js:13:53)

on random of those requests. @gaspard fix doesn't really help since I just get another undefined errors.
It looks like container from typeDI doesn't inject all deps properly in time of those requests..or something like that.

My tsconfig.json config:

  "compilerOptions": {
    "allowJs": true,
    "baseUrl": ".",
    "experimentalDecorators": true,
    "forceConsistentCasingInFileNames": true,
    "jsx": "react",
    "lib": ["es6", "esnext", "dom"],
    "module": "esnext",
    "moduleResolution": "node",
    "outDir": "build/dist",
    "rootDir": "src",
    "sourceMap": true,
    "target": "es5"
  },

I'm on windows 10, using postgress for DB and folllowing deps versions:

    "pg": "^7.4.3",
    "typeorm": "^0.2.7",
    "typescript": "^2.9.2",
    "vesper": "^0.1.9"

Let me know if you need some more info or anything.

@yubozhao
Copy link

@AntonPuko @gaspard
vesper mutation controller has the transaction params to true as default. Make sure you set it to false and test it again.

@AntonPuko
Copy link

@yubozhao yep, it works with transactions disabled for those queries.

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

4 participants