Skip to content
Open
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
64 changes: 0 additions & 64 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 8 additions & 7 deletions packages/core/src/controllers/crypto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,21 +143,22 @@ export class Crypto implements ICrypto {
const message = decodeTypeTwoEnvelope(encoded, opts?.encoding);
return safeJsonParse(message);
}
if (isTypeOneEnvelope(params)) {
const selfPublicKey = params.receiverPublicKey;
const peerPublicKey = params.senderPublicKey;
topic = await this.generateSharedKey(selfPublicKey, peerPublicKey);
}
try {
if (isTypeOneEnvelope(params)) {
const selfPublicKey = params.receiverPublicKey;
const peerPublicKey = params.senderPublicKey;
topic = await this.generateSharedKey(selfPublicKey, peerPublicKey);
}
const symKey = this.getSymKey(topic);
const message = decrypt({ symKey, encoded, encoding: opts?.encoding });
const payload = safeJsonParse(message);
return payload;
} catch (error) {
this.logger.error(
this.logger.warn(
`Failed to decode message from topic: '${topic}', clientId: '${await this.getClientId()}'`,
);
this.logger.error(error);
this.logger.warn(error instanceof Error ? error.message : String(error));
return undefined;
}
};

Expand Down
20 changes: 12 additions & 8 deletions packages/core/src/controllers/history.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,14 +97,18 @@ export class JsonRpcHistory extends IJsonRpcHistory {
this.logger.debug(`Updating JSON-RPC response history record`);
this.logger.trace({ type: "method", method: "update", response });
if (!this.records.has(response.id)) return;
const record = await this.getRecord(response.id);
if (typeof record.response !== "undefined") return;
record.response = isJsonRpcError(response)
? { error: response.error }
: { result: response.result };
this.records.set(record.id, record);
this.persist();
this.events.emit(HISTORY_EVENTS.updated, record);
try {
const record = await this.getRecord(response.id);
if (typeof record.response !== "undefined") return;
record.response = isJsonRpcError(response)
? { error: response.error }
: { result: response.result };
this.records.set(record.id, record);
this.persist();
this.events.emit(HISTORY_EVENTS.updated, record);
} catch (error) {
this.logger.warn(`Failed to resolve history record ${response.id}: ${error instanceof Error ? error.message : String(error)}`);
}
};

public get: IJsonRpcHistory["get"] = async (topic, id) => {
Expand Down
9 changes: 8 additions & 1 deletion packages/core/src/controllers/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,14 @@ export class Store<Key, Data extends Record<string, any>> extends IStore<Key, Da
}

const { message } = getInternalError("NO_MATCHING_KEY", `${this.name}: ${key}`);
this.logger.error(message);
// PATCH: Use warn() for proposals and sessions instead of error() to prevent stack traces
// Missing proposals/sessions are expected in race conditions (expired, rejected, cleaned up)
// The error is already handled gracefully in onSessionProposeResponse, onSessionUpdateRequest, onSessionEventRequest
if (this.name === "proposal" || this.name === "session") {
this.logger.warn(message);
} else {
this.logger.error(message);
}
throw new Error(message);
}
return value;
Expand Down
Loading