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

Cannot assign to read only property 'writeQueueSize' of object '#<TCP>' #5487

Closed
vineet-suri opened this issue Feb 6, 2020 · 0 comments · Fixed by #7774
Closed

Cannot assign to read only property 'writeQueueSize' of object '#<TCP>' #5487

vineet-suri opened this issue Feb 6, 2020 · 0 comments · Fixed by #7774

Comments

@vineet-suri
Copy link

Issue type:

[x ] question
[x ] bug report
[ ] feature request
[ ] documentation issue

Database system/driver:

[ ] cordova
[ ] mongodb
[ ] mssql
[ ] mysql / mariadb
[ ] oracle
[ x] postgres
[ ] cockroachdb
[ ] sqlite
[ ] sqljs
[ ] react-native
[ ] expo

TypeORM version:

[ x] latest
[ ] @next
[ ] 0.x.x (or put your version here)

Steps to reproduce or a small repository showing the problem:

  1. Create an entity: AuditLog
@Entity('audit_log')
export class AuditLog extends BaseEntity {
    @PrimaryGeneratedColumn()
    id: number;

    @Column()
    ip: string;

    @Column({ type: 'varchar' })
    url: string;

    @Column({ name: 'method_name', type: 'varchar' })
    methodName?: string;

    @Column({ name: 'user_agent', type: 'varchar' })
    userAgent?: string;

    @Column({ name: 'status_code', type: 'varchar', length: 100 })
    statusCode: string;

    @Column({ name: 'err_msg', type: 'varchar', length: 100 })
    errMsg?: string;

    @Column({ name: 'err_trace', type: 'varchar', length: 100 })
    errTrace?: string;

    @Column({ name: 'req_body', type: 'json' })
    reqBody?: JSON;

    @Column({ type: 'json' })
    request: JSON;

    @Column({ type: 'json' })
    response: JSON;

    @Column({ name: 'response_time' })
    responseTime: string;

    @ManyToOne(type => User)
    user?: User;
}
  1. Save entity in database using repository method, like this
async createLog(log: AuditLog): Promise<AuditLog> {
        const result = await this.auditLogRepo.save(log);
        return result;
    }

NestJs Interceptor makes call to this service method.
but the save method errors out with this stack trace:

(node:2037) UnhandledPromiseRejectionWarning: TypeError: Cannot assign to read only property 'writeQueueSize' of object '#<TCP>'
    at Function.assign (<anonymous>)
    at Function.OrmUtils.mergeDeep (/home/vineet/Haskell project/haskell_api/node_modules/typeorm/util/OrmUtils.js:89:28)
    at Function.OrmUtils.mergeDeep (/home/vineet/Haskell project/haskell_api/node_modules/typeorm/util/OrmUtils.js:86:26)
    at Function.OrmUtils.mergeDeep (/home/vineet/Haskell project/haskell_api/node_modules/typeorm/util/OrmUtils.js:86:26)
    at Function.OrmUtils.mergeDeep (/home/vineet/Haskell project/haskell_api/node_modules/typeorm/util/OrmUtils.js:86:26)
    at /home/vineet/Haskell project/haskell_api/node_modules/typeorm/persistence/Subject.js:210:33
    at Array.reduce (<anonymous>)
    at Subject.createValueSetAndPopChangeMap (/home/vineet/Haskell project/haskell_api/node_modules/typeorm/persistence/Subject.js:167:41)
    at /home/vineet/Haskell project/haskell_api/node_modules/typeorm/persistence/SubjectExecutor.js:270:85
    at Array.forEach (<anonymous>)
(node:2037) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 2)
(node:2037) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

Please help about why this is going wrong?

@imnotjames imnotjames self-assigned this Jul 5, 2021
imnotjames added a commit that referenced this issue Jul 5, 2021
The mergeDeep functionality was causing issues where it would
try to merge objects that were not safe to merge.  to correct this
we now only merge plain objects - such as those returned
by createValueMap.

there were three cases where the mongo driver had a split off
code path where it passed in entities, so we've updated to instead
update that to getEntityValueMap as well

adds basic support of array embedded in ColumnMetadata so we can
use getEntityValueMap with mongo

fixes #5096
fixes #5762
fixes #6181
fixes #5487
fixes #5321
MerlinB pushed a commit to MerlinB/typeorm that referenced this issue Jul 20, 2021
…7774)

The mergeDeep functionality was causing issues where it would
try to merge objects that were not safe to merge.  to correct this
we now only merge plain objects - such as those returned
by createValueMap.

there were three cases where the mongo driver had a split off
code path where it passed in entities, so we've updated to instead
update that to getEntityValueMap as well

adds basic support of array embedded in ColumnMetadata so we can
use getEntityValueMap with mongo

fixes typeorm#5096
fixes typeorm#5762
fixes typeorm#6181
fixes typeorm#5487
fixes typeorm#5321
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants