Skip to content

Throws detailed error information - #6116

Merged
valentinfernandez1 merged 3 commits into
polkadot-js:masterfrom
zjb0807:patch-1
May 5, 2025
Merged

valentinfernandez1 merged 3 commits into
polkadot-js:masterfrom
zjb0807:patch-1

Conversation

@zjb0807

@zjb0807 zjb0807 commented Mar 14, 2025

Copy link
Copy Markdown
Contributor

Abnormal exit, which is difficult to debug, so add detailed information logs

/app/node_modules/@polkadot/api/cjs/base/Init.js:152
            throw new Error('Unable to retrieve header and parent from supplied hash');                                                                                                                                                 ^
                                                                                                                                                                                                                      Error: Unable to retrieve header and parent from supplied hash
    at ApiPromise._getBlockRegistryViaHash (/app/node_modules/@polkadot/api/cjs/base/Init.js:152:19)                                                                                                                      at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
                                                                                                                                                                                                                      Node.js v18.20.5

@valentinfernandez1
valentinfernandez1 self-requested a review March 17, 2025 14:51
valentinfernandez1

This comment was marked as outdated.

@valentinfernandez1
valentinfernandez1 self-requested a review March 17, 2025 14:53
@valentinfernandez1
valentinfernandez1 dismissed their stale review March 17, 2025 14:53

checks failing

@valentinfernandez1

Copy link
Copy Markdown
Contributor

Amazing work 🚀 , some checks are failing please resolve them and we should be able to merge. Make sure that yarn build runs successfully and run yarn lint to ensure proper code formatting.

Comment thread packages/api/src/base/Init.ts Outdated

@TarikGul TarikGul left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

In addition to the comment above, you should not add an object to a template literal.

Overall, I think this should be changed to a debug log, therefore not adding to bloat current logs.

something like:

l.debug('foo: ', bar);

@zjb0807

zjb0807 commented Apr 2, 2025

Copy link
Copy Markdown
Contributor Author

@TarikGul, please review again. Thank you

@TarikGul TarikGul left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Just a suggestion but if @valentinfernandez1 is okay with it, then I am.

);

if (header.parentHash.isEmpty) {
l.warn(`Unable to retrieve header ${blockHash.toString()} and parent ${header.parentHash.toString()} from supplied hash`);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
l.warn(`Unable to retrieve header ${blockHash.toString()} and parent ${header.parentHash.toString()} from supplied hash`);
l.debug(`Unable to retrieve header ${blockHash.toString()} and parent ${header.parentHash.toString()} from supplied hash`);

The if you do export DEBUG=api/init it will show up.

@valentinfernandez1
valentinfernandez1 merged commit cb871a5 into polkadot-js:master May 5, 2025
@polkadot-js-bot

Copy link
Copy Markdown

This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@polkadot-js polkadot-js locked as resolved and limited conversation to collaborators May 7, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants