MetaMask / MetaMask/core

Dissuade teams from adding side-effects in controller constructors

Open
#6,569 1 comment 0 reactions 0 assignees View on GitHub
category-documentation github-migration-triaged team-core-platform team-wallet-framework wf-documentation
Dominant language
TypeScript
Stars
413
Forks
308
Avg merge
1d 4h
Merged PRs (30d)
253

Description

Some teams have begun adding side effects to controller constructors. The two anti-patterns we've seen recently are:

- [ ] Calling asynchronous methods (and then ignoring the result). This makes tests harder to write, and it makes code run non-deterministically.
- [x] Calling controller actions. This defeats the point of the messaging system as it forces the target controller (or at least its messenger) to be present before the controller in question is initialized.

We should amend the existing controller guidelines to make teams aware of these anti-patterns, and we should inform them of the new guidelines in syncs.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by locating the existing controller guidelines mentioned in the issue and read how they currently describe constructor behavior. Update those guidelines to cover ignored asynchronous calls and calling controller actions, then verify that the guidance is clear enough to share in team syncs.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
documentation
Issue type
Documentation
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.