File tree Expand file tree Collapse file tree 1 file changed +16
-0
lines changed Expand file tree Collapse file tree 1 file changed +16
-0
lines changed Original file line number Diff line number Diff line change @@ -561,11 +561,27 @@ export function getDefaultStorageContextConfig(overrides: any = {}) {
561561 */
562562export async function cleanupProvider ( provider : any ) : Promise < void > {
563563 if ( provider && typeof provider . destroy === 'function' ) {
564+ // Suppress all errors during cleanup
565+ // WebSocket providers can throw async errors from scheduled operations
566+ // (like eth_unsubscribe) after destroy() is called
567+ const errorHandler = ( ) => {
568+ // Silently ignore all cleanup errors
569+ }
570+
571+ // Add error listener to suppress errors from async operations
572+ if ( typeof provider . on === 'function' ) {
573+ provider . on ( 'error' , errorHandler )
574+ }
575+
564576 try {
565577 await provider . destroy ( )
566578 } catch {
567579 // Ignore cleanup errors
568580 }
581+
582+ // Small delay to allow any pending async operations to complete
583+ // This prevents errors from scheduled operations that trigger after destroy()
584+ await new Promise ( ( resolve ) => setTimeout ( resolve , 100 ) )
569585 }
570586}
571587
You can’t perform that action at this time.
0 commit comments