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
Connection Reuse is broken in a Lambda environment: #4804
Connection Reuse is broken in a Lambda environment: #4804
Conversation
phong-innomizetech
commented
Sep 25, 2019
- Fix issue find metadata does not exist with webpack
- Fix issue find metadata does not exist with webpack
src/connection/Connection.ts
Outdated
@@ -480,7 +480,8 @@ export class Connection { | |||
*/ | |||
protected findMetadata(target: Function|EntitySchema<any>|string): EntityMetadata|undefined { | |||
return this.entityMetadatas.find(metadata => { | |||
if (metadata.target === target) | |||
// @ts-ignore |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no
src/connection/Connection.ts
Outdated
@@ -480,7 +480,8 @@ export class Connection { | |||
*/ | |||
protected findMetadata(target: Function|EntitySchema<any>|string): EntityMetadata|undefined { | |||
return this.entityMetadatas.find(metadata => { | |||
if (metadata.target === target) | |||
// @ts-ignore | |||
if (metadata.target.name === target.name) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
target
can be a string
src/connection/Connection.ts
Outdated
@@ -480,7 +480,8 @@ export class Connection { | |||
*/ | |||
protected findMetadata(target: Function|EntitySchema<any>|string): EntityMetadata|undefined { | |||
return this.entityMetadatas.find(metadata => { | |||
if (metadata.target === target) | |||
// @ts-ignore | |||
if (metadata.target.name === target.name) { |
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
…is-broken-in-a-lambda-environment Fix typing and missing bracket
Pushed a couple of fixes to @phong-innomizetech 's original commit. |
Original monkeypatch is here which I used for reference: #3427 (comment) |
@pleerock This PR seems to be responsible for a lot of open issues at the moment. It doesn't fix Webpack support, but instead breaks it. This is trivially verifiable by looking at the line: https://github.com/typeorm/typeorm/pull/4804/files#diff-9ada25e7bb500fdf98eeb214f7c94e9aR483 What this does is compare runtime names of functions, that's almost certainly going to fail in production, as production code is typically minified. Minified names are by no means guaranteed to be unique, so they shouldn't ever be used in a lookup. In my case, I've got two classes that were both minified to The previous functionality on the other hand was correct, in that it compared functions themselves, not their runtime names. The code for this comparison still exists, but is only executed if a match isn't found on the runtime name (which won't occur). |
Actually, even in non-minified code, there's no guarantee class (function) names are unique. They probably shouldn't be involved in the lookup at all. |
…eorm#4804)" This reverts commit 7962036.
…eorm#4804)" This reverts commit 7962036.
in typeorm#4958 we found that the PR typeorm#4804 caused issues in a variety of situations. this adds a test to prevent the issue from recurring where similar classes get mixed up in our metadata resolver
in typeorm#4958 we found that the PR typeorm#4804 caused issues in a variety of situations. this adds a test to prevent the issue from recurring where similar classes get mixed up in our metadata resolver