polkadot-js / api

Promise and RxJS APIs around Polkadot and Substrate based chains via RPC calls. It is dynamically generated based on what the Substrate runtime provides in terms of metadata.
Apache License 2.0
1.07k stars 352 forks source link

When the storage parsing fails, the promise is not rejected. #1984

Closed ntduan closed 4 years ago

ntduan commented 4 years ago

I think the reason is that storage update did not handle the error.

https://github.com/polkadot-js/api/blob/master/packages/rpc-core/src/index.ts#L250-L257 The error thrown by the formatOutput was not handled properly.

If I change it to this it will work:

const update = (error?: Error | null, result?: any): void => {
  if (error) {
    l.error(createErrorMessage(method, error));
    observer.error(error)
  }
  try {
    observer.next(this.formatOutput(method, params, result));
  } catch(error) {
    observer.error(error)
  }
};
jacogr commented 4 years ago

Yes, good catch, that is unprotected. Your change will work.

polkadot-js-bot commented 3 years ago

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue if you think you have a related problem or query.