Skip to content

Commit

Permalink
logs in Channel.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
ibc committed Jan 5, 2024
1 parent 0a94993 commit 91f452f
Showing 1 changed file with 17 additions and 7 deletions.
24 changes: 17 additions & 7 deletions node/src/Channel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,8 @@ export class Channel extends EnhancedEventEmitter
{
logger.error(
'received invalid message from the worker process: %s',
String(error));
String(error)
);
}
}

Expand Down Expand Up @@ -266,7 +267,9 @@ export class Channel extends EnhancedEventEmitter

if (this.#closed)
{
throw new InvalidStateError('Channel closed');
throw new InvalidStateError(
`Channel closed, cannot send notification [event:${Event[event]}]`
);
}

const handlerIdOffset = this.#bufferBuilder.createString(handlerId);
Expand Down Expand Up @@ -302,7 +305,7 @@ export class Channel extends EnhancedEventEmitter

if (buffer.byteLength > MESSAGE_MAX_LEN)
{
throw new Error('Channel request too big');
throw new Error(`notification too big [event:${Event[event]}]`);
}

try
Expand All @@ -326,9 +329,13 @@ export class Channel extends EnhancedEventEmitter
{
if (this.#closed)
{
throw new InvalidStateError('Channel closed');
throw new InvalidStateError(
`Channel closed, cannot send request [method:${Method[method]}]`
);
}

logger.debug('request() [method:%s]', Method[method]);

this.#nextId < 4294967295 ? ++this.#nextId : (this.#nextId = 1);

const id = this.#nextId;
Expand Down Expand Up @@ -366,7 +373,7 @@ export class Channel extends EnhancedEventEmitter

if (buffer.byteLength > MESSAGE_MAX_LEN)
{
throw new Error('Channel request too big');
throw new Error(`request too big [method:${Method[method]}]`);
}

// This may throw if closed or remote side ended.
Expand Down Expand Up @@ -398,7 +405,9 @@ export class Channel extends EnhancedEventEmitter
},
close : () =>
{
pReject(new InvalidStateError('Channel closed'));
pReject(new InvalidStateError(
`Channel closed, pending request aborted [method:${Method[method]}, id:${id}]`
));
}
};

Expand Down Expand Up @@ -451,7 +460,8 @@ export class Channel extends EnhancedEventEmitter
{
logger.error(
'received response is not accepted nor rejected [method:%s, id:%s]',
sent.method, sent.id);
sent.method, sent.id
);
}
}

Expand Down

0 comments on commit 91f452f

Please sign in to comment.