[Solved] What is Unhandled promise rejections, and why it is deprecated?

Who have experienced this error ?
meteor 1.8 + windows 10 //* working with no problem until app crashed
Seems l was having a problem with fixer.io currency API - app hanging…

when l pressed twice on CTRL+C to stop it, l got this:

Your application has errors. Waiting for file change.
(node:91736) UnhandledPromiseRejectionWarning: Error: write EPIPE
at _errnoException (util.js:992:11)
at ChildProcess.target._send (internal/child_process.js:702:20)
at ChildProcess.target.send (internal/child_process.js:586:19)
at Promise (packages/inter-process-messaging.js:164:24)
at new Promise ()
at otherProcess.readyForMessages.then (packages/inter-process-messaging.js:161:16)
at C:\Users\Pc_user\AppData\Local.meteor\packages\meteor-tool\1.8.0\mt-os.windows.x86_64\dev_bundle\lib\node_modules\meteor-promise\fiber_pool.js:43:40
(node:91736) 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: 3)
(node:91736) [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.

The expectation is that every Promise chain will have at least one .catch() action to handle exceptions in the chain.

Similarly, in modern (ES7) JavaScript using async and await, the expectation is that there will be at least one try/catch clause to handle exceptions in the async code.

In the past, the requirement to handle Promise exceptions was relaxed and allowed to fail silently. Now, if you don’t handle exceptions, you will get the warning you’ve seen. In other words “allowing no exception handling” has been deprecated.

If you get that warning, you should refactor the code to include one of the above exception handling methods.

2 Likes

I got it. tnx…

The part of code l suspect is this one:


‘getCurrencies’: function(base) {
check(base, String);

      this.unblock();

      try{
        const key = Meteor.settings.fixer.api;

        const url = `http://data.fixer.io/api/latest?access_key=${key}&base=${base}`;

        const result = HTTP.call('GET', url);
        
        return result.data;

      } catch(err){
        console.log(err);
        throw new Meteor.Error(err);
      }
    }

How would you write it ?
Locally it does not work but online the fixer.io api is connected to the app…

No - there aren’t any Promises in that code.

Thanks. Solved … months ago…:stuck_out_tongue:

@toledoroy, the solution will be highly dependent on the problem.
Can you start a new thread with the exact error and stack trace?

Also if you have some idea what code might be causing it, post a snippet of the suspect code?

So your error only occurs on windows 10 when hitting ctrl-c twice with UnhandledPromiseRejectionWarning: Error: write EPIPE?