symbol-sdk-typescript-javascript icon indicating copy to clipboard operation
symbol-sdk-typescript-javascript copied to clipboard

UnhandledPromiseRejection errors

Open fboucquez opened this issue 3 years ago • 3 comments

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

fboucquez avatar May 19 '21 15:05 fboucquez

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
  }
}

yilmazbahadir avatar May 21 '21 21:05 yilmazbahadir

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~

zhjjj avatar Jun 08 '21 08:06 zhjjj

Awsome finding @zhjjj , I've created the PR https://github.com/nemtech/symbol-sdk-typescript-javascript/pull/795 @rg911

fboucquez avatar Jun 08 '21 13:06 fboucquez