Skip to content

Commit

Permalink
improve error handling for block building and verbose log (#890)
Browse files Browse the repository at this point in the history
  • Loading branch information
xlc authored Feb 27, 2025
1 parent 1e9b246 commit f1acd14
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
6 changes: 6 additions & 0 deletions packages/core/src/blockchain/txpool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,12 @@ export class TxPool {
this.#isBuilding = true
try {
await this.#buildBlock()
} catch (error) {
logger.error({ error }, 'build block failed')
for (const { deferred } of this.#pendingBlocks) {
deferred.reject(error)
}
this.#pendingBlocks.length = 0
} finally {
this.#isBuilding = false
}
Expand Down
6 changes: 4 additions & 2 deletions packages/core/src/logger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,13 @@ const innerTruncate =
return '( Too Deep )'
}
switch (typeof val) {
case 'string':
if (val.length > 66 && !verboseLog) {
case 'string': {
const maxLength = verboseLog ? 10 * 1024 : 66
if (val.length > maxLength) {
return `${val.slice(0, 34)}${val.slice(-32)}`
}
return val
}
case 'object':
if (Array.isArray(val)) {
return val.map(innerTruncate(level + 1))
Expand Down

0 comments on commit f1acd14

Please sign in to comment.