Skip to content

Commit

Permalink
Fixed bug
Browse files Browse the repository at this point in the history
  • Loading branch information
ncthbrt committed Jan 17, 2018
1 parent f03604d commit 521bffd
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 14 deletions.
4 changes: 2 additions & 2 deletions lib/actor.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class Actor {
constructor (parent, name, system, f, { shutdownAfter, whenChildCrashes } = {}) {
this.parent = parent;
if (!name) {
name = `anonymous-${(Math.random() * Number.MAX_SAFE_INTEGER) | 0}`;
name = `anonymous-${Math.abs(Math.random() * Number.MAX_SAFE_INTEGER) | 0}`;
}
if (name && parent.children.has(name)) {
throw new Error(`child actor of name ${name} already exists`);
Expand Down Expand Up @@ -159,7 +159,7 @@ class Actor {
}

async handleFault (child, msg, sender, error) {
const ctx = child.createSupervisionContext(child, msg, sender, error);
const ctx = this.createSupervisionContext(child, msg, sender, error);
const decision = await Promise.resolve(this.whenChildCrashes(msg, error, ctx));
switch (decision) {
case SupervisionActions.stop:
Expand Down
2 changes: 1 addition & 1 deletion lib/functions.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const query = (actor, msg, timeout, ...args) => {
throw new Error('A timeout is required to be specified');
}

let concreteActor = systemMap.find(actor.system.name, actor);
const concreteActor = systemMap.find(actor.system.name, actor);

return (concreteActor && concreteActor.query)
? concreteActor.query(msg, timeout, ...args)
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "nact",
"version": "4.4.1",
"version": "4.4.2",
"description": "nact ⇒ node.js + actors = your services have never been so µ",
"main": "lib/index.js",
"scripts": {
Expand Down Expand Up @@ -51,4 +51,4 @@
"sinon": "^4.1.4",
"sinon-chai": "^2.14.0"
}
}
}
18 changes: 9 additions & 9 deletions test/actor.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,14 +90,14 @@ describe('Actor', function () {
it('allows stateful behaviour', async function () {
let actor = spawn(
system,
function (state = '', msg) {
if (msg.type === 'query') {
dispatch(this.sender, state, this.self);
return state;
} else if (msg.type === 'append') {
return state + msg.payload;
}
}
function (state = '', msg) {
if (msg.type === 'query') {
dispatch(this.sender, state, this.self);
return state;
} else if (msg.type === 'append') {
return state + msg.payload;
}
}
);

dispatch(actor, { payload: 'Hello ', type: 'append' });
Expand Down Expand Up @@ -212,7 +212,7 @@ describe('Actor', function () {

it('should automatically stop after timeout if timeout is specified', async function () {
console.error = ignore;
let child = spawnStateless(system, (msg) => {}, 'test', { shutdownAfter: 100 * milliseconds });
let child = spawnStateless(system, (msg) => { }, 'test', { shutdownAfter: 100 * milliseconds });
await delay(110);
isStopped(child).should.be.true;
});
Expand Down

0 comments on commit 521bffd

Please sign in to comment.