Skip to content

Conversation

@FrederikBolding
Copy link
Member

@FrederikBolding FrederikBolding commented Jan 14, 2026

Refactor BaseSnapExecutor to expect parameters to always be passed by object. We were already passing the parameters by object in production, but then internally converting them to an array. This made typing harder and generally isn't necessary. We can now more easily validate the parameters and correctly narrow the types, reducing the casting required. The PR also refactors the handling of incoming command requests a bit to become more readable. Theoretically this should also make the executor a bit faster at processing commands.

This PR is breaking as now only passing by object is allowed.


Note

Medium Risk
Medium risk because it changes the internal JSON-RPC command contract for executeSnap/snapRpc (array params no longer accepted) and refactors command dispatch/validation in the snap execution environment, which could break any remaining callers still using positional params.

Overview
Breaking change: executor command RPCs now require named object params (no positional arrays). executeSnap takes { snapId, sourceCode, endowments } and snapRpc takes { snapId, handler, origin, request }; snapRpc also drops the old target field.

BaseSnapExecutor command handling is refactored to a switch-based dispatcher with centralized param validation (assertCommandParams), removing the old param-sorting/command-implementation helpers. Tests and test utilities across browser/iframe/node execution environments are updated accordingly, and coverage expectations are adjusted.

Written by Cursor Bugbot for commit edee29c. This will update automatically on new commits. Configure here.

@FrederikBolding FrederikBolding force-pushed the fb/base-snap-executor-refactor branch from 9c304c9 to 75ef6cf Compare January 30, 2026 13:27
@FrederikBolding FrederikBolding changed the base branch from main to fb/base-executor-refactor-1 February 2, 2026 09:29
@FrederikBolding FrederikBolding force-pushed the fb/base-snap-executor-refactor branch from 75ef6cf to 5d0b9fc Compare February 2, 2026 09:30
github-merge-queue bot pushed a commit that referenced this pull request Feb 2, 2026
This PR refactors `BaseSnapExecutor` to follow our more recent patterns,
notably using hash private for most properties and functions, but also
changing a couple of naming patterns and improving types. This makes
`BaseSnapExecutor` way more compliant with our linter.

Split off #3803 to make this
easier to review.

<!-- CURSOR_SUMMARY -->
---

> [!NOTE]
> **Medium Risk**
> Touches core snap execution/termination and teardown tracking; while
mostly a refactor, it changes how termination promises and teardown
state are managed and could affect edge-case lifecycle behavior.
> 
> **Overview**
> Refactors `BaseSnapExecutor` to use **hash-private** fields/methods
throughout (removing prior lint suppressions) and tightens command
dispatch typing by calling `#methods[method as keyof Methods]` instead
of `any`.
> 
> Updates execution/termination plumbing: snap evaluation cancellation
now uses `createDeferredPromise` and a shared `#teardownRef` object is
passed into `withTeardown` instead of `this`, changing the termination
error string to `The Snap "..." has been terminated during execution.`
(and updating the corresponding browser test expectation).
> 
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
0082a8c. This will update automatically
on new commits. Configure
[here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
Base automatically changed from fb/base-executor-refactor-1 to main February 2, 2026 10:59
@FrederikBolding FrederikBolding force-pushed the fb/base-snap-executor-refactor branch from 108c3e2 to 40406eb Compare February 2, 2026 11:02
@codecov
Copy link

codecov bot commented Feb 2, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.46%. Comparing base (07d1937) to head (edee29c).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3803      +/-   ##
==========================================
+ Coverage   98.39%   98.46%   +0.07%     
==========================================
  Files         430      429       -1     
  Lines       12457    12395      -62     
  Branches     1932     1922      -10     
==========================================
- Hits        12257    12205      -52     
+ Misses        200      190      -10     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@FrederikBolding FrederikBolding changed the title chore: Refactor BaseSnapExecutor refactor!: Pass executor parameters by object Feb 2, 2026
@FrederikBolding FrederikBolding marked this pull request as ready for review February 2, 2026 11:27
@FrederikBolding FrederikBolding requested a review from a team as a code owner February 2, 2026 11:27
Mrtenz
Mrtenz previously approved these changes Feb 2, 2026
Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 2 potential issues.

@FrederikBolding FrederikBolding added this pull request to the merge queue Feb 2, 2026
Merged via the queue into main with commit 471e941 Feb 2, 2026
128 checks passed
@FrederikBolding FrederikBolding deleted the fb/base-snap-executor-refactor branch February 2, 2026 13:06
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