InjectiveLabs / injective-ts

Collection of TypeScript packages that consume and interact with the Injective Chain
Apache License 2.0
130 stars 195 forks source link

TypeError: Cannot redefine property: stack #259

Open SuficioAC opened 1 year ago

SuficioAC commented 1 year ago

Running a simple gRPC call using the TS SDK which errors results in the following error:

/home/services/injective/node_modules/@injectivelabs/exceptions/dist/cjs/exception.js:68
        super.stack = stack;
                    ^

TypeError: Cannot redefine property: stack
    at GrpcUnaryRequestException.setStack (/home/services/injective/node_modules/@injectivelabs/exceptions/dist/cjs/exception.js:68:21)
    at GrpcUnaryRequestException.parseError (/home/services/injective/node_modules/@injectivelabs/exceptions/dist/cjs/exception.js:39:14)
    at new ConcreteException (/home/services/injective/node_modules/@injectivelabs/exceptions/dist/cjs/exception.js:30:14)
    at new GrpcUnaryRequestException (/home/services/injective/node_modules/@injectivelabs/exceptions/dist/cjs/exceptions/GrpcUnaryRequestException.js:8:9)
    at IndexerGrpcDerivativesApi.<anonymous> (/home/services/injective/node_modules/@injectivelabs/sdk-ts/dist/cjs/client/indexer/grpc/IndexerGrpcDerivativesApi.js:200:23)
    at Generator.throw (<anonymous>)
    at rejected (/home/services/injective/node_modules/@injectivelabs/sdk-ts/dist/cjs/client/indexer/grpc/IndexerGrpcDerivativesApi.js:6:65)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)

Occurs due to Error.stack not being overwritable.

Makes the TS SDK unusable without modifying the source.

Node v21.2.0

zlace commented 10 months ago

Facing this issue as well.

bangjelkoski commented 10 months ago

How can I reproduce?

zlace commented 10 months ago

Seems like it happens on node >20, resolved by fixing node version to 18.

One quick way to reproduce is trying to send some funds off an empty wallet (to trigger rpc error).

SuficioAC commented 10 months ago

Yes, using a recent Node version, any error emitted by the library will cause this error.