symbol-sdk-typescript-javascript
symbol-sdk-typescript-javascript copied to clipboard
UnhandledPromiseRejection errors
When a fetch call fails, nodejs raises a warning:
UnhandledPromiseRejection: 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(). The promise rejected with the reason "#<Response>".
https://github.com/nemgrouplimited/symbol-node-rewards/issues/253 https://github.com/nemtech/symbol-bootstrap/issues/176
I can catch a promise rejection and manage the exception but still got the warning with "symbol-sdk": "^1.0.0-alpha-202105211327"
. I think the original promise rejection in the SDK hasn't been caught.
2021-05-21T21:43:04.554Z warn: [NodeService.ts] There has been an error talking to known repo http://ec2-44-242-153-48.us-west-2.compute.amazonaws.com:3000/. Error: {"statusCode":404,"statusMessage":"Not}
Unhandled Rejection at: Promise Promise {
<rejected> Response {
size: 0,
timeout: 0,
[Symbol(Body internals)]: { body: [PassThrough], disturbed: false, error: null },
[Symbol(Response internals)]: {
url: 'http://ec2-44-242-153-48.us-west-2.compute.amazonaws.com:3000//node/info',
status: 404,
statusText: 'Not Found',
headers: [Headers],
counter: 0
}
}
} reason: Response {
size: 0,
timeout: 0,
[Symbol(Body internals)]: {
body: PassThrough {
_readableState: [ReadableState],
readable: true,
_events: [Object: null prototype],
_eventsCount: 2,
_maxListeners: undefined,
_writableState: [WritableState],
writable: false,
allowHalfOpen: true,
_transformState: [Object],
[Symbol(kCapture)]: false
},
disturbed: false,
error: null
},
[Symbol(Response internals)]: {
url: 'http://ec2-44-242-153-48.us-west-2.compute.amazonaws.com:3000//node/info',
status: 404,
statusText: 'Not Found',
headers: Headers { [Symbol(map)]: [Object: null prototype] },
counter: 0
}
}
I've got the same problem. When I tried to announce an transaction to the api 'http://ngl-dual-001.symbolblockchain.io:3000', my process crashed. I found an error was throw from here. If I subscribed the announce result in TransactionService.ts, the error can be caught and no crash occurs. The error should have been thrown before the connection established, which is {"statusCode":503,"statusMessage":"Service Unavailable","body":"{"code":"ServiceUnavailable","message":"connection failed"}"}
So please help to fix this issue~
Awsome finding @zhjjj , I've created the PR https://github.com/nemtech/symbol-sdk-typescript-javascript/pull/795 @rg911