Skip to content
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

Fix TypeError: Cannot read properties of null (reading 'hash') #204

Merged
merged 4 commits into from
Nov 8, 2023

Conversation

bz888
Copy link
Contributor

@bz888 bz888 commented Nov 8, 2023

Description

Fix for

2023-11-07T23:07:43.548Z <Worker Service #1-#1> ERROR Failed to fetch block 5300201 TypeError: Cannot read properties of null (reading 'hash')

According to Tendermint rpc types Block ID of the previous block. This can be null when the currect block is height 1.

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)

Checklist

  • I have tested locally
  • I have performed a self review of my changes
  • Updated any relevant documentation
  • Linked to any relevant issues
  • I have added tests relevant to my changes
  • Any dependent changes have been merged and published in downstream modules
  • My code is up to date with the base branch
  • I have updated relevant changelogs. We suggest using chan

Copy link

github-actions bot commented Nov 8, 2023

Coverage report

St.
Category Percentage Covered / Total
🔴 Statements 34.56% 1663/4812
🟡 Branches 63.12% 89/141
🔴 Functions 17.49% 32/183
🔴 Lines 34.56% 1663/4812

Test suite run success

36 tests passing in 5 suites.

Report generated by 🧪jest coverage report action from 676bd95

Copy link
Contributor

@stwiname stwiname left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please add tests

@@ -59,7 +59,7 @@ export class WorkerService extends BaseWorkerService<

protected toBlockResponse(block: BlockContent): FetchBlockResponse {
return {
parentHash: block.block.header.lastBlockId.hash.toString(),
parentHash: block.block.header.lastBlockId?.hash.toString(),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The optional chaining will set the value to undefined, not null

@stwiname stwiname merged commit 4eea8c0 into main Nov 8, 2023
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants