Skip to content

refactor: replace destroy promises with AbortSignal#246

Merged
andrevmatos merged 6 commits into
mainfrom
refactor/destroy
May 6, 2026
Merged

refactor: replace destroy promises with AbortSignal#246
andrevmatos merged 6 commits into
mainfrom
refactor/destroy

Conversation

@andrevmatos
Copy link
Copy Markdown
Collaborator

@andrevmatos andrevmatos commented May 5, 2026

  • more explicit, less leak prone
  • fixes a few leaks in dangling Chain instances in the cli providers race
  • gets rid of a bunch of leaky Promise.races
  • GC-friendly
  • destroy method is kept, but now is on Chain class, and connects directly to the new abort signal property, which is then is cascaded to the providers and in-flight requests
  • Should fix cli's Pending handles after main completion: warning and 5s delay on exit after work is done

@andrevmatos andrevmatos self-assigned this May 5, 2026
@vercel
Copy link
Copy Markdown

vercel Bot commented May 5, 2026

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

Project Deployment Actions Updated (UTC)
ccip-tools-ts Ready Ready Preview, Comment May 6, 2026 0:23am

Request Review

more explicit, less leak prone
@andrevmatos andrevmatos marked this pull request as ready for review May 5, 2026 23:58
@andrevmatos andrevmatos requested review from a team, PabloMansanet and aelmanaa as code owners May 5, 2026 23:58
Comment thread ccip-cli/src/providers/index.test.ts Fixed
@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 6, 2026

Coverage Report

ℹ tests 821
ℹ suites 237
ℹ pass 819
ℹ fail 0
ℹ cancelled 0
ℹ skipped 2
ℹ todo 0
ℹ duration_ms 156931.264636

> @chainlink/[email protected] test
> node --test

Verbose mode enabled
▶ getCtx
  ▶ output — always stdout
    ✔ output.write goes to stdout (1.736548ms)
    ✔ output.table goes to stdout (1.090073ms)
  ✔ output — always stdout (4.367915ms)
  ▶ logger — always stderr
    ✔ logger.info goes to stderr (0.661814ms)
    ✔ logger.warn goes to stderr (0.415344ms)
    ✔ logger.error goes to stderr (0.427177ms)
  ✔ logger — always stderr (1.735977ms)
  ▶ verbose mode
    ✔ logger.debug is a no-op when verbose is false (1.203965ms)
    ✔ logger.debug goes to stderr when verbose is true (1.621123ms)
  ✔ verbose mode (3.011736ms)
  ▶ destroy signal
    ✔ returns a working destroy function (15.845615ms)
    ✔ calling destroy twice does not throw (0.773111ms)
  ✔ destroy signal (16.828528ms)
✔ getCtx (26.878075ms)
▶ lane-latency command
  ✔ should output JSON format correctly (6.195592ms)
  ✔ should resolve chain IDs to chain selectors (0.705015ms)
  ✔ should use custom API URL when provided (1.358142ms)
  ✔ should output log format correctly (0.722557ms)
  ✔ should handle chain IDs as input (0.837642ms)
  ✔ should handle chain selectors as input (0.50412ms)
  ✔ should throw CCIPApiClientNotAvailableError when --no-api flag is set (0.9812ms)
  ✔ should work normally when --no-api flag is false (0.551188ms)
  ✔ should forward blockConfirmations to API URL (0.52513ms)
  ✔ should not include numOfBlocks when blockConfirmations is not provided (0.614196ms)
  ▶ CCIP_API environment variable integration
    ✔ should respect CCIP_API=false environment variable (0.482019ms)
  ✔ CCIP_API environment variable integration (0.693823ms)
✔ lane-latency command (15.796483ms)
▶ selectRequest non-interactive behavior
  ✔ returns the single request without prompting (1.403988ms)
  ✔ returns the request matching logIndex (0.228216ms)
  ✔ throws CCIPInteractiveRequiredError for multiple requests without logIndex (2.268619ms)
✔ selectRequest non-interactive behavior (5.784354ms)
▶ CCIPInteractiveRequiredError
  ✔ has correct code and is not transient (0.328563ms)
  ✔ uses default recovery when none provided (0.33254ms)
  ✔ preserves context fields (0.206104ms)
✔ CCIPInteractiveRequiredError (1.225886ms)
▶ preprocessArgv TTY auto-detection
  ✔ --interactive flag is defined in globalOpts (0.969077ms)
✔ preprocessArgv TTY auto-detection (1.350338ms)
▶ search messages command
  ✔ should throw CCIPApiClientNotAvailableError when --no-api flag is set (3.56567ms)
  ✔ should output JSON format correctly (16.928853ms)
  ✔ should pass sender filter to API (3.871391ms)
  ✔ should pass receiver filter to API (4.384426ms)
  ✔ should resolve source chain to selector (3.345489ms)
  ✔ should resolve dest chain to selector (3.101224ms)
  ✔ should pass manual-exec-only filter to API (3.847856ms)
  ✔ should treat limit 0 as unlimited (6.349312ms)
  ✔ should respect limit parameter (9.19565ms)
  ✔ should warn when no results found (1.470212ms)
  ✔ should use custom API URL when provided (2.749168ms)
  ✔ should warn on negative limit and fall back to default (2.527634ms)
  ✔ should output log format (2.518548ms)
✔ search messages command (66.262091ms)
▶ e2e command show EVM
  ▶ pretty format (default)
    ✔ should show complete CCIP transaction details EVM to EVM (11268.121066ms)
  ✔ pretty format (default) (11269.180401ms)
  ▶ json format
    ✔ should output a single valid JSON envelope with all expected fields (8031.504525ms)
  ✔ json format (8031.732461ms)
  ▶ log format
    ✔ should output in log format with object assignments (8163.7807ms)
  ✔ log format (8163.997635ms)
  ▶ verbose flag
    ✔ should work with verbose flag enabled (9447.465959ms)
  ✔ verbose flag (9447.714503ms)
  ▶ error handling
    ✔ should handle invalid transaction hash gracefully (8452.413346ms)
    ✔ should require transaction hash argument (1677.15994ms)
  ✔ error handling (10129.869368ms)
  ✔ should show complete CCIP transaction details EVM to Aptos (15656.908972ms)
  ✔ should show complete CCIP transaction details EVM to Solana (6673.549495ms)
✔ e2e command show EVM (69374.22707ms)
▶ e2e command show Solana
  ✔ should show complete CCIP transaction details Solana to EVM (10085.984072ms)
✔ e2e command show Solana (10086.233568ms)
▶ e2e command show Aptos
  ✔ should show complete CCIP transaction details Aptos to EVM (9383.069702ms)
✔ e2e command show Aptos (9383.263614ms)
﹣ e2e command show TON (0.089417ms) # SKIP
▶ formatCCIPError
  ✔ should return null for non-CCIPError instances (1.478608ms)
  ✔ should format CCIPError with code and message (0.655041ms)
  ✔ should include help section with recovery hint (0.275764ms)
  ✔ should include note section for transient errors (0.342439ms)
  ✔ should include retry timing for transient errors with retryAfterMs (0.426686ms)
  ✔ should not include note section for permanent errors (0.24659ms)
  ✔ should format error with structured output (0.2949ms)
  ✔ should include stack trace when verbose is true (0.469826ms)
  ✔ should not include stack trace when verbose is false (0.269242ms)
✔ formatCCIPError (6.720984ms)
▶ yieldResolved
  ✔ throws if a promise rejects while the generator is paused after a yield (15.134216ms)
✔ yieldResolved (15.321174ms)
▶ fetchChainsFromRpcs
  ✔ lets duplicate tx-hash race endpoints query before aborting losers (13.80676ms)
  ✔ chainGetter: returns chain from first winning endpoint and destroys late arrivals (51.588884ms)
  ✔ chainGetter: resolves a pending request once the endpoint connects (Branch 2) (22.05233ms)
  ✔ chainGetter: rejects with CCIPRpcNotFoundError when all endpoints fail to connect (1.622926ms)
  ✔ chainGetter: rejects immediately with CCIPRpcNotFoundError once family is already exhausted (0.904286ms)
  ✔ txHash: rejects with CCIPTransactionNotFoundError when tx not on any chain (1.161877ms)
  ✔ txHash: Branch-4 (txOnlyRacer) is destroyed via catch when it loses the tx race (10.518036ms)
  ✔ txHash: chain connecting after txFoundIn is set is immediately destroyed without calling getTransaction (24.672956ms)
  ✔ txHash: Branch-2 chain given to a pending chainGetter is NOT destroyed when it cannot find the tx (13.745416ms)
  ✔ txFoundIn shared across families: SVM txOnlyRacer is destroyed after EVM wins (35.334389ms)
✔ fetchChainsFromRpcs (177.693134ms)
ℹ tests 70
ℹ suites 23
ℹ pass 70
ℹ fail 0
ℹ cancelled 0
ℹ skipped 0
ℹ todo 0
ℹ duration_ms 91267.366074
---------------------------------------|---------|----------|---------|---------|-------------------
File                                   | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s 
---------------------------------------|---------|----------|---------|---------|-------------------
All files                              |   73.08 |    76.78 |   58.79 |   73.08 |                   
 ccip-cli/src                          |   89.59 |    61.53 |      75 |   89.59 |                   
  index.ts                             |   89.59 |    61.53 |      75 |   89.59 | ...58-159,165-170 
 ccip-cli/src/commands                 |   51.21 |    73.09 |   58.18 |   51.21 |                   
  index.ts                             |     100 |      100 |     100 |     100 |                   
  lane-latency.ts                      |   72.56 |     90.9 |   33.33 |   72.56 | ...,63-70,105-111 
  manual-exec.ts                       |   23.02 |      100 |       0 |   23.02 | ...28-138,140-302 
  parse.ts                             |   57.14 |      100 |       0 |   57.14 | 46-50,57-64,66-91 
  search.ts                            |   81.25 |      100 |       0 |   81.25 | 24-29             
  send.ts                              |   14.93 |      100 |       0 |   14.93 | ...89-220,222-462 
  show.ts                              |   76.71 |    61.97 |     100 |   76.71 | ...86-289,317-318 
  supported-tokens.ts                  |   16.95 |      100 |       0 |   16.95 | ...59-333,335-348 
  token.ts                             |   22.72 |      100 |       0 |   22.72 | ...3,60-67,69-132 
  types.ts                             |     100 |      100 |     100 |     100 |                   
  utils.ts                             |   87.72 |    75.47 |   96.42 |   87.72 | ...02-612,620-628 
 ccip-cli/src/commands/search          |   49.19 |    82.85 |    12.5 |   49.19 |                   
  messages.ts                          |   49.19 |    82.85 |    12.5 |   49.19 | ...89-211,213-248 
 ccip-cli/src/providers                |   50.05 |    84.84 |   19.23 |   50.05 |                   
  aptos.ts                             |   51.47 |      100 |       0 |   51.47 | ...,95-96,105-136 
  evm.ts                               |    36.3 |      100 |       0 |    36.3 | ...69-104,116-168 
  index.ts                             |   80.23 |     83.6 |   83.33 |   80.23 | ...40-142,209-253 
  solana.ts                            |   47.44 |      100 |       0 |   47.44 | ...02-103,112-137 
  sui.ts                               |   64.28 |      100 |       0 |   64.28 | 10-14             
  ton.ts                               |   15.03 |      100 |       0 |   15.03 | 24-153            
 ccip-sdk/src                          |   95.25 |    81.34 |   93.33 |   95.25 |                   
  chain.ts                             |   94.21 |    77.27 |   72.72 |   94.21 | ...1758,1791-1792 
  commits.ts                           |     100 |    95.23 |     100 |     100 | 54                
  execution.ts                         |   92.19 |     92.3 |     100 |   92.19 | 130-137,149-156   
  explorer.ts                          |     100 |      100 |     100 |     100 |                   
  extra-args.ts                        |     100 |    89.47 |     100 |     100 | 213,248,285,300   
  gas.ts                               |   89.17 |    38.46 |     100 |   89.17 | ...70-174,189-190 
  http-status.ts                       |     100 |      100 |     100 |     100 |                   
  index.ts                             |     100 |      100 |     100 |     100 |                   
  messages.ts                          |   88.53 |    45.09 |     100 |   88.53 | ...30-231,255-256 
  offchain.ts                          |   94.14 |    79.54 |     100 |   94.14 | ...23-225,234-235 
  requests.ts                          |   94.63 |    82.25 |     100 |   94.63 | ...92-293,359-361 
  supported-chains.ts                  |     100 |      100 |     100 |     100 |                   
  types.ts                             |     100 |      100 |     100 |     100 |                   
  utils.ts                             |   96.47 |    89.88 |     100 |   96.47 | ...87-888,895-903 
 ccip-sdk/src/api                      |   93.75 |       85 |   94.11 |   93.75 |                   
  index.ts                             |   93.75 |       85 |   94.11 |   93.75 | ...55-758,761-764 
 ccip-sdk/src/aptos                    |   56.57 |     67.4 |   56.66 |   56.57 |                   
  exec.ts                              |   29.31 |      100 |       0 |   29.31 | 18-58             
  hasher.ts                            |   76.31 |       80 |   66.66 |   76.31 | 19-38,52-58       
  index.ts                             |   55.84 |    73.23 |   58.13 |   55.84 | ...39-865,869-880 
  logs.ts                              |   88.67 |    55.76 |   85.71 |   88.67 | ...92,197,199-210 
  send.ts                              |    25.2 |      100 |       0 |    25.2 | ...1,62-79,92-123 
  token.ts                             |   23.75 |       75 |     100 |   23.75 | 35-156            
  types.ts                             |   65.62 |      100 |       0 |   65.62 | 25-32,64-88       
 ccip-sdk/src/canton                   |   36.89 |    63.63 |    6.45 |   36.89 |                   
  events.ts                            |   35.67 |      100 |       0 |   35.67 | ...71-383,389-398 
  index.ts                             |    33.7 |    55.55 |    8.16 |    33.7 | ...1492,1503-1507 
  types.ts                             |   83.33 |      100 |       0 |   83.33 | 18-25,104-114     
 ccip-sdk/src/canton/client            |   29.85 |      100 |       0 |   29.85 |                   
  client.ts                            |   25.99 |      100 |       0 |   25.99 | ...22-430,445-454 
  index.ts                             |     100 |      100 |     100 |     100 |                   
 ...dk/src/canton/explicit-disclosures |   75.85 |    62.06 |   48.27 |   75.85 |                   
  acs.ts                               |   79.69 |     61.4 |   77.77 |   79.69 | ...43-465,511-522 
  eds.ts                               |   69.56 |      100 |       0 |   69.56 | ...91-303,314-321 
 ccip-sdk/src/canton/token-metadata    |   62.64 |      100 |       0 |   62.64 |                   
  client.ts                            |   62.64 |      100 |       0 |   62.64 | 104-163,170-174   
 ...dk/src/canton/transfer-instruction |   52.15 |      100 |       0 |   52.15 |                   
  client.ts                            |   52.15 |      100 |       0 |   52.15 | 92-175,182-186    
 ccip-sdk/src/errors                   |   87.51 |    76.03 |    48.8 |   87.51 |                   
  CCIPError.ts                         |     100 |      100 |     100 |     100 |                   
  codes.ts                             |     100 |      100 |     100 |     100 |                   
  index.ts                             |     100 |      100 |     100 |     100 |                   
  recovery.ts                          |     100 |      100 |     100 |     100 |                   
  specialized.ts                       |   84.76 |    71.16 |   46.21 |   84.76 | ...3374,3395-3404 
  utils.ts                             |   94.44 |    81.48 |     100 |   94.44 | 15,17,22,24       
 ccip-sdk/src/evm                      |      87 |    76.43 |   90.36 |      87 |                   
  const.ts                             |     100 |      100 |     100 |     100 |                   
  errors.ts                            |   93.16 |    82.41 |     100 |   93.16 | ...61,170-172,219 
  extra-args.ts                        |   94.47 |    61.01 |     100 |   94.47 | ...11-212,328-340 
  fork.test.data.ts                    |     100 |      100 |     100 |     100 |                   
  gas.ts                               |   97.97 |    53.33 |     100 |   97.97 | 72-73,75          
  hasher.ts                            |     100 |     92.3 |     100 |     100 | 134               
  index.ts                             |   80.12 |     76.5 |   89.06 |   80.12 | ...2121,2147-2155 
  logs.ts                              |   71.17 |    81.81 |      50 |   71.17 | 46-47,81-110      
  messages.ts                          |     100 |      100 |     100 |     100 |                   
  offchain.ts                          |   81.25 |    33.33 |     100 |   81.25 | 11,13-14          
  types.ts                             |     100 |      100 |     100 |     100 |                   
 ccip-sdk/src/evm/viem                 |   79.76 |    90.62 |   69.23 |   79.76 |                   
  client-adapter.ts                    |     100 |       90 |     100 |     100 | 48,74             
  index.ts                             |     100 |      100 |     100 |     100 |                   
  wallet-adapter.ts                    |   63.09 |     90.9 |   55.55 |   63.09 | ...91-124,131-157 
 ccip-sdk/src/hasher                   |   94.29 |    78.94 |     100 |   94.29 |                   
  common.ts                            |     100 |      100 |     100 |     100 |                   
  hasher.ts                            |     100 |    66.66 |     100 |     100 | 19                
  index.ts                             |     100 |      100 |     100 |     100 |                   
  merklemulti.ts                       |   93.43 |       78 |     100 |   93.43 | ...06-307,315-316 
 ccip-sdk/src/shared                   |   88.05 |    69.23 |     100 |   88.05 |                   
  bcs-codecs.ts                        |   87.87 |    66.66 |     100 |   87.87 | 75-87,104-106     
  constants.ts                         |     100 |      100 |     100 |     100 |                   
 ccip-sdk/src/solana                   |   74.63 |    69.88 |   80.21 |   74.63 |                   
  cleanup.ts                           |   26.95 |    66.66 |   33.33 |   26.95 | ...59-101,114-227 
  exec.ts                              |   69.05 |    62.96 |   66.66 |   69.05 | ...68-472,512-513 
  fork.test.data.ts                    |     100 |      100 |     100 |     100 |                   
  gas.ts                               |   92.06 |    72.22 |     100 |   92.06 | ...,81-90,170-171 
  hasher.ts                            |   96.58 |    81.81 |     100 |   96.58 | 67-70             
  index.ts                             |   76.36 |    74.47 |   81.48 |   76.36 | ...1674,1678-1711 
  logs.ts                              |   69.35 |    58.62 |     100 |   69.35 | 51-52,54-55,61-94 
  offchain.ts                          |     100 |      100 |     100 |     100 |                   
  patchBorsh.ts                        |   78.31 |       50 |     100 |   78.31 | ...47,65-66,72-78 
  send.ts                              |   77.55 |    33.33 |      80 |   77.55 | ...51-359,402-441 
  types.ts                             |     100 |      100 |     100 |     100 |                   
  utils.ts                             |   72.91 |    65.62 |   72.72 |   72.91 | ...42-444,476-491 
 ccip-sdk/src/sui                      |   34.92 |    86.66 |   19.29 |   34.92 |                   
  discovery.ts                         |   14.86 |      100 |       0 |   14.86 | ...49-185,188-222 
  events.ts                            |   30.94 |       50 |      25 |   30.94 | ...18-283,305-306 
  exec.ts                              |   31.29 |      100 |       0 |   31.29 | 31-74,86-131      
  hasher.ts                            |   98.16 |    66.66 |     100 |   98.16 | 33,49             
  index.ts                             |   40.04 |    93.18 |   17.94 |   40.04 | ...26-827,831-832 
  objects.ts                           |   18.93 |      100 |       0 |   18.93 | ...33-184,195-338 
 ccip-sdk/src/sui/manuallyExec         |   53.91 |       75 |      50 |   53.91 |                   
  encoder.ts                           |   83.72 |    66.66 |     100 |   83.72 | 50-57,72-76,81    
  index.ts                             |   34.35 |      100 |       0 |   34.35 | 46-131            
 ccip-sdk/src/ton                      |   77.11 |     79.6 |    73.8 |   77.11 |                   
  exec.ts                              |     100 |      100 |     100 |     100 |                   
  extra-args.ts                        |   98.66 |    72.72 |     100 |   98.66 | 156-157,222       
  hasher.ts                            |   77.95 |    77.77 |      75 |   77.95 | 99-107,155-186    
  index.ts                             |   71.33 |    76.85 |   56.52 |   71.33 | ...1233,1240-1241 
  logs.ts                              |     100 |    95.55 |     100 |     100 | 66-71             
  send.ts                              |   95.93 |       70 |     100 |   95.93 | 37-44             
  types.ts                             |   91.17 |    81.25 |     100 |   91.17 | ...60-62,70-73,91 
  utils.ts                             |   63.02 |    78.18 |    90.9 |   63.02 | ...36-394,396-399 
---------------------------------------|---------|----------|---------|---------|-------------------

Comment thread ccip-cli/src/providers/index.test.ts Dismissed
Comment thread ccip-cli/src/providers/index.test.ts Dismissed
Comment thread ccip-cli/src/providers/index.test.ts Dismissed
Comment thread ccip-cli/src/providers/index.test.ts Fixed
Comment thread ccip-cli/src/providers/index.test.ts Fixed
Comment thread ccip-cli/src/providers/index.test.ts Dismissed
Comment thread ccip-cli/src/providers/index.test.ts Dismissed
Comment thread ccip-cli/src/providers/index.test.ts Dismissed
Comment thread ccip-cli/src/providers/index.test.ts Dismissed
Comment thread ccip-cli/src/providers/index.test.ts Dismissed
Comment thread ccip-cli/src/providers/index.test.ts Dismissed
@andrevmatos andrevmatos changed the title refactor: replace destry with AbortSignal refactor: replace destroy promises with AbortSignal May 6, 2026
@andrevmatos andrevmatos merged commit 44ada86 into main May 6, 2026
13 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