Code Monkey home page Code Monkey logo

Comments (11)

nanov avatar nanov commented on July 30, 2024 1

Ok, i saw where the problem is. Will submit a fix!

from node-cqrs-domain.

adrai avatar adrai commented on July 30, 2024 1

good catch

from node-cqrs-domain.

adrai avatar adrai commented on July 30, 2024

try like this:

function handleCommand(cmd) {
    return new Promise((resolve, reject) => {
        try {
          domain.handle(cmd, err => {
              if (err) {
                  reject(err);
              }
              resolve();
          });
        } catch (e) { reject(e); }
    });
}

from node-cqrs-domain.

nanov avatar nanov commented on July 30, 2024

Just a small addition so you won't resolve an already rejected promise:

function handleCommand(cmd) {
  return new Promise((resolve, reject) => {
    try {
      domain.handle(cmd, (err) => {
        if (err)
          return reject(err);
        resolve();
      });
     } catch (e) { reject(e) }
  });
}

note the return statement on the first reject.

from node-cqrs-domain.

adrai avatar adrai commented on July 30, 2024

right, didn’t see it

from node-cqrs-domain.

bikerp avatar bikerp commented on July 30, 2024

Hi @adrai,
thanks for the feedback. I tried the try/catch but even this didn't help.

from node-cqrs-domain.

nanov avatar nanov commented on July 30, 2024

@bikerp This is rather strange, could you post the stack trace of the error?

from node-cqrs-domain.

bikerp avatar bikerp commented on July 30, 2024
Error: Please pass a valid aggregate id!

    at DefaultCommandHandler.getNextCommandInQueue (C:\Users\bikerp\projects\test\src\commands\node_modules\cqrs-domain\lib\defaultCommandHandler.js:112:17)
    at _handle (C:\Users\bikerp\projects\test\src\commands\node_modules\cqrs-domain\lib\defaultCommandHandler.js:1133:27)
    at DefaultCommandHandler.handle (C:\Users\bikerp\projects\test\src\commands\node_modules\cqrs-domain\lib\defaultCommandHandler.js:1163:14)
    at CommandDispatcher.dispatch (C:\Users\bikerp\projects\test\src\commands\node_modules\cqrs-domain\lib\commandDispatcher.js:119:29)
    at C:\Users\bikerp\projects\test\src\commands\node_modules\cqrs-domain\lib\domain.js:670:30
    at _combinedTickCallback (internal/process/next_tick.js:131:7)
    at process._tickCallback (internal/process/next_tick.js:180:9)

from node-cqrs-domain.

nanov avatar nanov commented on July 30, 2024

Fixed in v2.14.73.

from node-cqrs-domain.

nanov avatar nanov commented on July 30, 2024

@bikerp Could you confirm that solves your issue? So we could close it on our side?

from node-cqrs-domain.

bikerp avatar bikerp commented on July 30, 2024

@adrai Good job. It works. Even without the try/catch. Thanks for the quick fix

from node-cqrs-domain.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.