Skip to content

fix(logger): Change formatter that collides with new libp2p version [fixes DXJ-459] #334

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

Merged
merged 7 commits into from
Aug 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/@tests/smoke/node/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@
"license": "Apache-2.0",
"dependencies": {
"@fluencelabs/js-client": "workspace:*",
"@test/aqua_for_test": "workspace:../../aqua"
"@test/aqua_for_test": "workspace:*"
}
}
12 changes: 8 additions & 4 deletions packages/core/js-client/src/jsPeer/FluencePeer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,10 @@ export abstract class FluencePeer {

item.onStageChange({ stage: 'expired' });
}

private decodeAvmData(data: Uint8Array) {
return new TextDecoder().decode(data.buffer);
}

private _createParticlesProcessingQueue() {
const particlesQueue = new Subject<ParticleQueueItem>();
Expand All @@ -380,7 +384,7 @@ export abstract class FluencePeer {
// Otherwise the race might occur corrupting the prevData

log_particle.debug('id %s. sending particle to interpreter', item.particle.id);
log_particle.trace('id %s. prevData: %a', item.particle.id, prevData);
log_particle.trace('id %s. prevData: %s', item.particle.id, this.decodeAvmData(prevData));

const args = serializeAvmArgs(
{
Expand Down Expand Up @@ -442,16 +446,16 @@ export abstract class FluencePeer {
item.result.retCode,
item.result.errorMessage,
);
log_particle.trace('id %s. avm data: %a', item.particle.id, item.result.data);
log_particle.trace('id %s. avm data: %s', item.particle.id, this.decodeAvmData(item.result.data));
item.onStageChange({ stage: 'interpreterError', errorMessage: item.result.errorMessage });
return;
}

log_particle.trace(
'id %s. interpreter result: retCode: %d, avm data: %a',
'id %s. interpreter result: retCode: %d, avm data: %s',
item.particle.id,
item.result.retCode,
item.result.data,
this.decodeAvmData(item.result.data)
);

setTimeout(() => {
Expand Down
6 changes: 0 additions & 6 deletions packages/core/js-client/src/util/logger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,6 @@
*/

import debug from 'debug';
import { Buffer } from 'buffer';

// Format avm data as a string
debug.formatters.a = (avmData: Uint8Array) => {
return new TextDecoder().decode(Buffer.from(avmData));
};

type Logger = (formatter: any, ...args: any[]) => void;

Expand Down