Closed chejazi closed 3 years ago
Can you share more details on unhandled exception and what time request was sent? This endpoint should always be up as we do not have downtime as such.
Thanks for pointing it out, I will wrap this inside try catch
Last times the request was sent:
2021-08-23T15:04:22.894Z 2021-08-23T15:05:12.105Z 2021-08-23T15:07:45.011Z 2021-08-23T15:08:36.075Z 2021-08-23T15:10:05.840Z 2021-08-23T15:13:12.293Z 2021-08-23T15:14:23.888Z 2021-08-23T15:15:22.522Z 2021-08-23T15:16:32.853Z 2021-08-23T15:18:47.782Z 2021-08-23T15:25:52.777Z 2021-08-23T15:27:18.817Z 2021-08-23T15:31:42.588Z 2021-08-23T15:32:53.492Z 2021-08-23T15:35:44.664Z 2021-08-23T15:36:32.908Z 2021-08-23T15:37:08.910Z
Nodejs output
(node:51133) UnhandledPromiseRejectionWarning: FetchError: invalid json response body at https://api.biconomy.io/api/v2/meta-tx/systemInfo?networkId=137 reason: Unexpected token < in JSON at position 0
at /admin/node_modules/node-fetch/lib/index.js:272:32
at processTicksAndRejections (internal/process/task_queues.js:88:5)
(node:51133) 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:51133) [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.
This is occurring when initializing the sdk:
const biconomy = new Biconomy(maticProvider, {
apiKey: "...redacted"
debug: true
});
biconomy.onEvent(biconomy.READY, () => {
resolve(biconomy);
}).onEvent(biconomy.ERROR, (error, message) => {
reject(error);
});
Right now if I use my nodejs repl I am seeing the error.
const fetch = require("node-fetch");
fetch("https://api.biconomy.io/api/v2/meta-tx/systemInfo?networkId=137").then(console.log)
logs:
Response {
size: 0,
timeout: 0,
[Symbol(Body internals)]: {
body: Gunzip {
_writeState: [Uint32Array],
_readableState: [ReadableState],
readable: true,
_events: [Object],
_eventsCount: 7,
_maxListeners: undefined,
_writableState: [WritableState],
writable: true,
allowHalfOpen: true,
_transformState: [Object],
_hadError: false,
bytesWritten: 0,
_handle: [Zlib],
_outBuffer: <Buffer 3c 21 44 4f 43 54 59 50 45 20 68 74 6d 6c 3e 0a 3c 21 2d 2d 5b 69 66 20 6c 74 20 49 45 20 37 5d 3e 20 3c 68 74 6d 6c 20 63 6c 61 73 73 3d 22 6e 6f 2d ... 16334 more bytes>,
_outOffset: 0,
_chunkSize: 16384,
_defaultFlushFlag: 2,
_finishFlushFlag: 2,
_nextFlush: -1,
_defaultFullFlushFlag: 3,
_info: undefined,
_level: -1,
_strategy: 0
},
disturbed: false,
error: null
},
[Symbol(Response internals)]: {
url: 'https://api.biconomy.io/api/v2/meta-tx/systemInfo?networkId=137',
status: 403,
statusText: 'Forbidden',
headers: Headers { [Symbol(map)]: [Object] },
counter: 0
}
}
Hi @chejazi ,kindly retry now, it will work. 👍🏻
The following requests results in an unhandled exception in the event that the endpoint is offline:
https://github.com/bcnmy/mexa-sdk/blob/4dc949c54f474e87b157da5ac821b112eb3e9a77/src/Biconomy.js#L1569-L1571
We should probably perform a catch here like we do later on in the switch block: https://github.com/bcnmy/mexa-sdk/blob/4dc949c54f474e87b157da5ac821b112eb3e9a77/src/Biconomy.js#L1689-L1698