You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: develop-docs/frontend/upgrade-policies.mdx
+24-24Lines changed: 24 additions & 24 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -25,15 +25,15 @@ If you let everything stagnate and upgrade nothing, simply because it all works,
25
25
26
26
This can become a massive amount of work, as the package is maybe many minor versions **or even multiple major versions** out of date. If it becomes difficult enough to upgrade, the engineer may choose to avoid upgrading altogether and implement a hack to work around the need. This of course is doubly bad, as when you do _absolutely need to upgrade_, not only is it difficult to upgrade a very outdated package, you now have to understand and reverse the hack.
27
27
28
-
By being proactive and keeping up with major and minor versions, we will typically need to only consider a small set of changes in the package. This is safer as it is less likely for usages of the package to break since there is simply less to validate. This also helps to keep up with the latest performance updates, bug fixes, security patches. And helps to ensure when a developer is looking for documentation on the usage of a package, they won’t have to hunt for older versions of the documentation.
28
+
By being proactive and keeping up with major and minor versions, we will typically need to only consider a small set of changes in the package. This is safer as it is less likely for usages of the package to break since there is simply less to validate. This also helps to keep up with the latest performance updates, bug fixes, security patches. And helps to ensure when a developer is looking for documentation on the usage of a package, they won't have to hunt for older versions of the documentation.
29
29
30
30
### Consider the benefits and risks
31
31
32
32
On the other hand, choosing to constantly keep packages updated to the absolute most recent versions can have numerous consequences.
33
33
34
34
- Upgrading can in some cases be a non-trivial effort for marginal gains. Validating even small upgrades takes time, often when really nothing has changed. (This is of course a slippery slope, wait too long and packages can become exponentially more work to upgrade)
35
35
36
-
- There is a cost to too much `package.json` churn such as developers having to constantly run `yarn install` on every git pull.
36
+
- There is a cost to too much `package.json` churn such as developers having to constantly run `pnpm install` on every git pull.
37
37
38
38
- A security vulnerability may be introduced in a new version that was not previously present. If we had waited to upgrade until the patch we would not be vulnerable.
39
39
@@ -52,25 +52,25 @@ You may not have to do this manually! See the below section on [Take advantage o
52
52
### Seeing what can be upgraded
53
53
54
54
```bash
55
-
yarn outdated --color | sort
55
+
pnpm outdated --color | sort
56
56
```
57
57
58
58
### Upgrading packages
59
59
60
60
```bash
61
-
yarn upgrade --latest [package-name] [...]
61
+
pnpm upgrade --latest [package-name] [...]
62
62
```
63
63
64
64
<Alert>
65
65
66
-
Don’t forget to upgrade the `@types/[package-name]` package as well if necessary.
66
+
Don't forget to upgrade the `@types/[package-name]` package as well if necessary.
67
67
68
68
</Alert>
69
69
70
70
If you would like to upgrade a group of packages (for example `@babel`) you can use
Depending on what category of package you’ve upgraded there are a number of steps you’ll need to take to validate that the upgrade is safe and that nothing has broken. The first step is to consider what categories the package being upgraded falls into.
86
+
Depending on what category of package you've upgraded there are a number of steps you'll need to take to validate that the upgrade is safe and that nothing has broken. The first step is to consider what categories the package being upgraded falls into.
87
87
88
88
The general category of frontend dependencies we have are
89
89
@@ -119,67 +119,67 @@ For example, some dependencies such as `webpack` fall both into the app build **
119
119
120
120
1.**Read the CHANGELOG of the package**
121
121
122
-
This will give you context into what you need to look out for. If the package has explicit breaking changes it’s important to be aware of those so you can validate that our usages is not affected by those changes. If we are affected changes will have to be made to Sentry’s usage of that dependency to make it compatible.
122
+
This will give you context into what you need to look out for. If the package has explicit breaking changes it's important to be aware of those so you can validate that our usages is not affected by those changes. If we are affected changes will have to be made to Sentry's usage of that dependency to make it compatible.
123
123
124
124
2.**Is CI passing?**
125
125
126
-
This is a really good first indicator of if the change is safe. If CI is failing there’s a good chance the application itself is actually broken. You will need to fix failing tests before you can merge a package upgrade.
126
+
This is a really good first indicator of if the change is safe. If CI is failing there's a good chance the application itself is actually broken. You will need to fix failing tests before you can merge a package upgrade.
127
127
128
128
However, **DO NOT** rely on CI passing to guarantee that the package was successfully upgraded! Our test coverage is good, but it is not perfect.
129
129
130
-
When upgrading Testing dependencies, at this point may also want to check the test logs and make sure there’s no unusual output, ensure the number of tests run has not changed, and even check that the performance of the test runs has not regressed.
130
+
When upgrading Testing dependencies, at this point may also want to check the test logs and make sure there's no unusual output, ensure the number of tests run has not changed, and even check that the performance of the test runs has not regressed.
131
131
132
132
3.**Does the application work?**
133
133
134
-
This is where it begins to become important to understand the category of the dependency. It’s very useful to use the **Vercel Frontend Previews** during this step to see how the application acts with the upgraded package in a production build.
134
+
This is where it begins to become important to understand the category of the dependency. It's very useful to use the **Vercel Frontend Previews** during this step to see how the application acts with the upgraded package in a production build.
135
135
136
136
- For feature-specific dependencies, you can specifically check that the features using the package are correctly working as expected.
137
137
138
-
- For framework dependencies, you’ll want to spot-check as much as you can. You should take into consideration the changes in the new version of the package and validate that whatever was changed behaves as expected. Looking for “odd” usage of APIs can be helpful here (e.g., are we doing manual `ReactDOM` calls anywhere? etc)
138
+
- For framework dependencies, you'll want to spot-check as much as you can. You should take into consideration the changes in the new version of the package and validate that whatever was changed behaves as expected. Looking for "odd" usage of APIs can be helpful here (e.g., are we doing manual `ReactDOM` calls anywhere? etc)
139
139
140
-
- For application build dependencies we should already be feeling pretty good at this step, considering the application built and passed CI. But it’s still worth checking the change log to make sure nothing in the build pipeline may have affected the application. However, problems with the application build here may be hard to spot as they will likely be subtle if CI did not catch them.
140
+
- For application build dependencies we should already be feeling pretty good at this step, considering the application built and passed CI. But it's still worth checking the change log to make sure nothing in the build pipeline may have affected the application. However, problems with the application build here may be hard to spot as they will likely be subtle if CI did not catch them.
141
141
142
-
- For test and development dependencies, it’s highly likely the application should be working fine. The only scenario where the application could be broken is if the dependency DID have some effect on the application code (in which case it should not be categorized as a pure test or dev dependency).
142
+
- For test and development dependencies, it's highly likely the application should be working fine. The only scenario where the application could be broken is if the dependency DID have some effect on the application code (in which case it should not be categorized as a pure test or dev dependency).
143
143
144
-
This may also be a good time to check if the **size-limit report bot** has left a comment indicating a change in bundle size. If the bundle has increased dramatically it’s worth investigating (likewise if it’s decreased in size dramatically)
144
+
This may also be a good time to check if the **size-limit report bot** has left a comment indicating a change in bundle size. If the bundle has increased dramatically it's worth investigating (likewise if it's decreased in size dramatically)
145
145
146
146
4.**Does the development environment work**
147
147
148
-
If you’ve upgraded a build or development dependency, you’ll definitely want to make sure the development environment is still working as expected.
148
+
If you've upgraded a build or development dependency, you'll definitely want to make sure the development environment is still working as expected.
149
149
150
150
- Does `sentry devserver` still correctly run the client-side application?
151
151
152
152
- Does `pnpm dev-ui` still run the client-only version of the application?
153
153
154
-
Depending on what package you’re upgrading, you’ll what to consider what to test. For example, if you upgraded `fork-ts-checker-webpack-plugin` you’ll want to validate that types are still being checked in development.
154
+
Depending on what package you're upgrading, you'll what to consider what to test. For example, if you upgraded `fork-ts-checker-webpack-plugin` you'll want to validate that types are still being checked in development.
155
155
156
156
5.**Upgrade the package in getsentry if applicable**
157
157
158
158
Developer tooling and build packages are currently duplicated in `getsentry`'s `package.json`. For those packages, it is important to remember that you will need to upgrade the package in both places.
159
159
160
-
6.**Read the `yarn.lock` diff**
160
+
6.**Read the `pnpm-lock.yaml` diff**
161
161
162
-
It’s good to understand exactly what has changed with the upgrade. It’s generally a bad thing if upgrading has caused a discrepancy in shared sub dependency versions. For example, if you upgrade `lodash` but another top level package specifies that it needs and older version of `lodash` we will now have **two versions** of `lodash` installed. That means two separate versions of `lodash` will be shipped!
162
+
It's good to understand exactly what has changed with the upgrade. It's generally a bad thing if upgrading has caused a discrepancy in shared sub dependency versions. For example, if you upgrade `lodash` but another top level package specifies that it needs and older version of `lodash` we will now have **two versions** of `lodash` installed. That means two separate versions of `lodash` will be shipped!
163
163
164
-
Generally you will want to make sure nothing has duplicated versions, in that case you may need to use `[yarn-deduplicate](https://www.npmjs.com/package/yarn-deduplicate)` or in the worst case you may need to upgrade the package which is pulling in the offending older versions.
164
+
Generally you will want to make sure nothing has duplicated versions, in that case you may need to use `[pnpm-dedupe](https://www.npmjs.com/package/pnpm-dedupe)` or in the worst case you may need to upgrade the package which is pulling in the offending older versions.
165
165
166
-
See [The Ultimate Guide to yarn.lock Lockfiles](https://www.arahansen.com/the-ultimate-guide-to-yarn-lock-lockfiles/) for an in-depth look on how these work.
166
+
See [The Ultimate Guide to pnpm lockfiles](https://pnpm.io/pnpm-lock.html) for an in-depth look on how these work.
167
167
168
168
7.**Validate in production after the upgrade is merged**
169
169
170
170
Finally, in some cases, it may be worth checking that the application is operating as expected in production. In some rare cases a package may behave differently in production (though this is very rare, as checking the frontend preview is very close to the same production bundle).
171
171
172
172
## Take advantage of tooling
173
173
174
-
We use [GitHub’s Dependabot](https://docs.github.com/en/code-security/dependabot) to automatically open pull requests for package upgrades.
174
+
We use [GitHub's Dependabot](https://docs.github.com/en/code-security/dependabot) to automatically open pull requests for package upgrades.
175
175
176
176
It has two primary modes of operation
177
177
178
178
-**Creating security vulnerability PRs**
179
179
180
180
These package version bumps are critical as they fix known CVE vulnerabilities reported in the [GitHub Advisory Database](https://github.com/advisories). These should be merged ASAP.
181
181
[Learn more about Dependabot alerts on GitHub](https://docs.github.com/en/code-security/dependabot/dependabot-alerts/about-dependabot-alerts).
182
-
Again, keeping dependencies up to date helps to ensure that when a vulnerability is discovered, we’re able to upgrade that package without having to upgrade across multiple minor or even major versions.
182
+
Again, keeping dependencies up to date helps to ensure that when a vulnerability is discovered, we're able to upgrade that package without having to upgrade across multiple minor or even major versions.
183
183
184
184
-**Opening version upgrade PRs**
185
185
@@ -207,7 +207,7 @@ To tackle a dependabot PR there are a few steps to take
207
207
<summary>Why do I have to do this?</summary>
208
208
209
209
The `dependabot` user is considered an outside contributor so the same precautions must be taken with these PRs as would be with an outside contributor.
210
-
It’s important to note that this is an explicit action you’re taking to indicate that the upgrade is **generally considered safe**. Since it is theoretically possible for a package to exfiltrate secrets from the `getsentry/getsentry` GitHub actions run by including malicious code in the new package. This situation however is highly unlikely and would need to be a coordinated supply chain attack by one of our already vetted dependencies.
210
+
It's important to note that this is an explicit action you're taking to indicate that the upgrade is **generally considered safe**. Since it is theoretically possible for a package to exfiltrate secrets from the `getsentry/getsentry` GitHub actions run by including malicious code in the new package. This situation however is highly unlikely and would need to be a coordinated supply chain attack by one of our already vetted dependencies.
0 commit comments