jito-labs / jito-ts

Jito Typescript SDK
Other
92 stars 50 forks source link

fix: streams cancellation error #18

Closed zhelezkov closed 1 month ago

zhelezkov commented 7 months ago

Currently if you try to cancel stream you would get the following error:

node_modules/@grpc/grpc-js/src/call.ts:115
    this.call?.cancelWithStatus(Status.CANCELLED, 'Cancelled on client');
         ^
TypeError: Cannot read properties of undefined (reading 'call')
    at cancel (node_modules/@grpc/grpc-js/src/call.ts:115:10)
    at Timeout._onTimeout (/src/test.ts:31:3)
    at listOnTimeout (node:internal/timers:573:17)
    at process.processTimers (node:internal/timers:514:7)

Node.js v20.10.0

It happens because stream.cancel is not an arrow function so it loses it's this context. Fix is to wrap it into arrow function to avoid this loosing it's context

ethers-master commented 7 months ago

I meet this problem, this fix need merge

segfaultdoc commented 1 month ago

@zhelezkov ty for the fix