Skip to content

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

@vineet-suri

Description

@vineet-suri

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?

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions