Skip to content

Conversation

@PsicoThePato
Copy link
Contributor

No description provided.

rodrigooler and others added 26 commits November 20, 2025 22:47
Fixes faucet.InvalidWorkBlock error caused by premature unsubscription from
new block updates. Refactors code following best practices including fail-fast
pattern, early returns, immutability, and proper error handling.

Key Changes:
- Fix: Moved unsubscribe from finally block to onFound/onError callbacks
- Fix: Use tryAsync for async operations (queryLastBlock, subscribeNewHeads)
- Feature: Automatic retry (up to 3 attempts) for InvalidWorkBlock errors
- Feature: Custom InvalidWorkBlockError class for recoverable errors
- Refactor: Extract pure functions (handleModuleError, handleDispatchError, etc)
- Refactor: Add readonly properties to MultiWorkerManager
- Refactor: Replace non-null assertions with optional chaining
- Refactor: Add Working/Requesting status messages
- Refactor: Remove emojis from console output
- Refactor: Add BlockData and WorkerMessageData interfaces
- Refactor: Extract constants (MAX_RETRIES, FAUCET_AMOUNT, DEFAULT_WORKER_COUNT)

User Experience:
- Silent retry on InvalidWorkBlock with console.log (no error toast)
- Clear status progression: "Working..." -> "Requesting..."
- Error toast only shown after 3 failed retry attempts
- Improved error messages without emojis

Technical Improvements:
- Early return pattern throughout
- No nested if-else statements
- Fail-fast error handling
- Immutable data structures where possible
- Type-safe error handling with custom error classes
- Proper cleanup of subscriptions and workers

Generated with Claude Code
https://claude.com/claude-code

Co-Authored-By: Claude <noreply@anthropic.com>
…ssues

- Add error message display when all retry attempts fail
- Terminate workers immediately on error to prevent resource leaks
- Change event loop to for...of with break to prevent duplicate handler calls
- Ensure manager.terminateAll() is called during cleanup
- Call unsubscribe() when extrinsic transaction fails

These fixes address all code review comments and prevent resource leaks
in the faucet worker management and subscription systems.
…anager

- Import assert from tsafe following project conventions
- Add assertion to ensure manager is defined in subscription callback
- This guarantees manager safety without non-null assertion operator (!)
…nd error handling

- Add API null check guard in submit function with user-facing error message
- Wrap call.send() with tryAsync to handle send errors properly
- Declare unsubscribe before send call and assign after await
- Add assert guards to ensure unsubscribe is defined in callbacks
- Prevents hanging promises when send() fails and ensures proper cleanup

Addresses CodeRabbit critical issues:
- Double cast masking null-safety issue now has explicit guard
- Unhandled rejection from call.send() now properly caught and rejected
- Change unsubscribe from 'let' to 'const' in tryAsync destructuring
- Simplifies code and follows prefer-const ESLint rule
- unsubscribe is assigned once from tryAsync result
…ply-chain

fix(pred-api): only return reply chain context
fix(torus-wallet): fixes faucet.InvalidWorkBlock error (web-331)
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 5, 2025

Important

Review skipped

Auto reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch dev

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@vercel
Copy link

vercel bot commented Dec 5, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
prediction-swarm Ready Ready Preview Comment Dec 5, 2025 1:11pm

@PsicoThePato PsicoThePato marked this pull request as ready for review December 5, 2025 13:10
@PsicoThePato PsicoThePato requested a review from a team as a code owner December 5, 2025 13:10
@PsicoThePato PsicoThePato merged commit feccf9d into main Dec 5, 2025
28 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.

6 participants