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

TypeError: expected i32 #21096

Closed
SoftwareAndOutsourcing opened this issue Nov 6, 2023 · 0 comments · Fixed by #21432
Closed

TypeError: expected i32 #21096

SoftwareAndOutsourcing opened this issue Nov 6, 2023 · 0 comments · Fixed by #21432
Assignees
Labels
bug Something isn't working correctly node compat

Comments

@SoftwareAndOutsourcing
Copy link

SoftwareAndOutsourcing commented Nov 6, 2023

Versions

Deno 1.38.0
Binance connector in Typescript v0.3.3

Node.js code

git clone https://github.com/binance/binance-connector-typescript.git
cd binance-connector-typescript
npm i
npx ts-node examples/websocketAPI/account/account.ts

Output:

Sending Websocket connection to: wss://ws-api.binance.com:443/ws-api/v3
Connected to the Websocket Server: wss://ws-api.binance.com:443/ws-api/v3
Connected with Websocket server
Send message to Binance Websocket API Server: {
  id: '5d36aa1ea1794bd60aab4e095ea56183',
  method: 'account.status',
  params: {
    apiKey: '',
    recvWindow: 5000,
    timestamp: 1699267938214,
    signature: '69747bd04025d929283ecc978fffd664987f7ce6ae3481b19cffe9b8872aa4db'
  }
}
Data:  {
  id: '5d36aa1ea1794bd60aab4e095ea56183',
  status: 400,
  error: { code: -1105, msg: "Parameter 'apiKey' was empty." },
  rateLimits: [
    {
      rateLimitType: 'REQUEST_WEIGHT',
      interval: 'MINUTE',
      intervalNum: 1,
      limit: 6000,
      count: 3
    }
  ]
}
Disconnected with Binance Websocket Server

Deno port

In the same file:

  • Remove the dotenv import.
  • Replace the import path of the second import with npm:@binance/connector-typescript.
  • Replace process.env with Deno.env.
  • Save it as deno-bug.ts:
import { WebsocketAPI, WsAccountTypes } from 'npm:@binance/connector-typescript';

const apiKey = Deno.env.get('BINANCE_API_KEY') || '';
const apiSecret = Deno.env.get('BINANCE_API_SECRET') || '';
const options: WsAccountTypes.accountOptions = {
    recvWindow: 5000
};
const callbacks = {
    open: (client: WebsocketAPI) => {
        console.log('Connected with Websocket server');
        // get account info after connection established
        client.account(options);
    },
    close: () => console.log('Disconnected with Websocket server'),
    message: (data: string) => {
        const parseData = JSON.parse(data);
        console.info('Data: ', parseData);
    }
};

const websocketAPIClient = new WebsocketAPI(apiKey, apiSecret, { callbacks });
  • Run it:
deno run --allow-read --allow-env --allow-net deno-bug.ts 

Output:

Warning: Not implemented: ClientRequest.options.createConnection
Sending Websocket connection to: wss://ws-api.binance.com:443/ws-api/v3
Connected to the Websocket Server: wss://ws-api.binance.com:443/ws-api/v3
Connected with Websocket server
Send message to Binance Websocket API Server: {
  id: "a145b17698dbe8f69d721c9055720219",
  method: "account.status",
  params: {
    apiKey: "",
    recvWindow: 5000,
    timestamp: 1699268000282,
    signature: "deed7c2c8e81d11cb43d0b0c956650094beadd15864584f6e83854f885812c14"
  }
}
error: Uncaught (in promise) TypeError: expected i32
    at Zlib.write (ext:deno_node/_zlib_binding.mjs:120:10)
    at DeflateRaw.Zlib._processChunk (ext:deno_node/_zlib.mjs:548:26)
    at DeflateRaw.Zlib._transform (ext:deno_node/_zlib.mjs:498:8)
    at DeflateRaw.Transform._write (ext:deno_node/_stream.mjs:4990:12)
    at doWrite (ext:deno_node/_stream.mjs:3963:16)
    at clearBuffer (ext:deno_node/_stream.mjs:4101:11)
    at onwrite (ext:deno_node/_stream.mjs:4000:11)
    at ext:deno_node/_stream.mjs:5003:11
    at Zlib.callback (ext:deno_node/_zlib.mjs:623:5)
    at ext:deno_node/_zlib_binding.mjs:132:14

Warning: Not implemented: ClientRequest.options.createConnection is being tracked on #19507.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working correctly node compat
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants