Skip to content

Fix SharedNodeStore test suite unhandled promise rejections #258

Closed

Description

@malibio

Problem

The SharedNodeStore test suite has 966 unhandled promise rejections from PersistenceCoordinator.cancelPending():

Error: Cancelled
 ❯ PersistenceCoordinator.cancelPending src/lib/services/persistence-coordinator.svelte.ts:396:10

This indicates a systemic problem with error handling in the coordinator's cancellation flow. These errors appear to be pre-existing and were not introduced by recent fixes.

Impact

  • Test suite produces misleading error output
  • Makes it difficult to identify real test failures
  • Indicates potential issues with promise cancellation patterns in production code

Root Cause

When PersistenceCoordinator.cancelPending() is called (e.g., in test cleanup), it rejects pending promises with an error. However, these rejections are not being caught by the test code.

Solution

  1. Add proper catch handlers for cancelled operations in tests
  2. Investigate if cancellation errors should be thrown or silently handled
  3. Consider using a custom error type (OperationCancelledError) that tests can filter
  4. Review all test cleanup code that calls cancelPending()

Testing

  • Run the SharedNodeStore test suite and verify 0 unhandled rejections
  • Ensure tests still properly detect real errors (not just masking them)

Priority

Medium - Test quality issue that doesn't affect functionality but reduces confidence in test suite

References

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions