Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BUG: Unhandled rejection for async function when Promise.reject is returned #198

Closed
Kurtas opened this issue Sep 16, 2019 · 1 comment
Closed

Comments

@Kurtas
Copy link

Kurtas commented Sep 16, 2019

Hello,

I'm getting Unhandled rejection for the following code with v1.4.0

import Promise from 'bluebird';

const dataloaderFn = cmdList => {
  return Promise.mapSeries(cmdList, ({promise, params}) => {
    if (typeof promise === 'function') return promise(params);
    throw new TypeError(`Promise isn't fucntion`);
  });
};
const d = new DataLoader(dataloaderFn, {
  cacheKeyFn: item => item.key,
});
const job = async () => Promise.reject('fail');
const test = {
  key: 'a',
  promise: job,
  params: {},
};
d.load(test).catch(console.log);

The error is catched but node.js also report it as unhandled rejection, here is ouput

Unhandled rejection fail

fail

If you call job().catch(console.log); then it isn't reported as unhandled rejection.

If you also remove async annotation then it works also with DataLoader

@Kurtas
Copy link
Author

Kurtas commented Sep 16, 2019

The problem was in Bluebird petkaantonov/bluebird#1501

@Kurtas Kurtas closed this as completed Sep 16, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant