惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

WordPress大学
WordPress大学
T
The Blog of Author Tim Ferriss
F
Fortinet All Blogs
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
阮一峰的网络日志
阮一峰的网络日志
The GitHub Blog
The GitHub Blog
Y
Y Combinator Blog
MyScale Blog
MyScale Blog
雷峰网
雷峰网
博客园 - 叶小钗
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
GbyAI
GbyAI
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
博客园 - 三生石上(FineUI控件)
云风的 BLOG
云风的 BLOG
V
V2EX
宝玉的分享
宝玉的分享
酷 壳 – CoolShell
酷 壳 – CoolShell
N
Netflix TechBlog - Medium
Vercel News
Vercel News
美团技术团队
人人都是产品经理
人人都是产品经理
The Cloudflare Blog

The Practical Developer

The Libuv Thread Pool Trap: Why Node.js Async APIs Stall Under Load Postgres Covering Indexes with INCLUDE: Eliminate Heap Fetches on Read-Heavy Workloads Postgres DISTINCT ON: The Fastest Way to Get the Latest Row Per Group Postgres Transaction Isolation: The Anomalies Your App Actually Faces in Production Linux TCP Tuning for Node.js Microservices: The Kernel Settings That Stop Silent Connection Drops Under Load Postgres HOT Updates and Fillfactor: Why Not All Writes Are Created Equal Database Connection Pool Leaks: Finding the Promise That Never Returns Its Seat Linux OOM Killer in Production: Why Your Node.js Containers Die Without a Stack Trace Postgres Materialized Views: Refresh Strategies That Do Not Lock Your Dashboards API Dependency Health Checks: Why /health Is Not Enough Authorization with Zanzibar Tuples: How Google Manages Permissions and How To Build the Same Check in Node.js Postgres Advisory Locks: The 20-Character Primitive That Replaces Redis for Coordination Dead Letter Queues: The Message Queue Pattern That Saves You at 2 a.m. File Descriptor Exhaustion: The Kernel Limit That Silently Drops Node.js Connections Graceful Degradation: The Pattern That Turns Total Outages into Partial Success PostgreSQL Full-Text Search: Dropping Elasticsearch for 90% of Use Cases S3 Presigned Multipart Uploads: Stop Your API Server from Being a File Upload Bottleneck MessagePack vs JSON: The Binary Serialization Switch That Cut Our Internal RPC Overhead by 40% DNS Caching in Node.js: The Silent Cause of Production Latency Spikes Reliable Cron Jobs: The Pattern That Stops Double Runs, Missed Executions, And The 2 AM Page GraphQL Query Complexity: Stop the OOM Query Before It Reaches Your Resolver Node.js Event Loop Lag: The Hidden Metric Behind Random Latency Spikes API Request Validation with Zod: The Schema That Catches Bad Input Before It Corrupts Your Database Load Shedding in Node.js: How to Reject Traffic Before You Drown Request Hedging: Cut Tail Latency In Half Without Overprovisioning Git Bisect: The Automated Binary Search That Finds Breaking Commits in Minutes Node.js Garbage Collection Tuning: Stop Letting V8 Pause Your Event Loop Node.js Server Timeouts: The Settings That Stop Slow Clients from Holding Sockets Hostage Postgres BRIN Indexes: The Time-Series Secret That Shrinks Indexes by 99% Event Sourcing with PostgreSQL: The Pragmatic 80% Solution
Semantic Versioning In Practice: Why Your Patches Keep Br...
The Practica · 2023-03-31 · via The Practical Developer

Your team’s package gets a 1.4.7 patch release. Twenty minutes later, three downstream apps are broken. The release notes say “fixed a typo in error message.” The “typo” was changing the message string, which one of the consumers was matching against in a test. The PR was approved, the patch was published, and you have done exactly what every unhappy upstream maintainer does: you shipped a breaking change in a patch version.

SemVer is the convention everybody claims to follow and almost nobody actually does. The reason is not laziness; it is that “what counts as breaking” is hard, and the incentive structure rewards under-numbering. This post is the operational version: the four ways a “patch” can break consumers, the rules that hold up in practice, and the deprecation playbook that lets you change anything you want without renaming the package.

What MAJOR.MINOR.PATCH actually means

The simple version everybody knows:

  • MAJOR: breaking changes.
  • MINOR: new features, backwards-compatible.
  • PATCH: bug fixes, no API change.

The more honest version:

  • MAJOR: anything that requires consumers to change any code or configuration to upgrade.
  • MINOR: anything that adds capability without requiring changes.
  • PATCH: anything that only changes implementation, not observable behavior.

The middle row is where most disagreement lives. A new optional method on a class is minor. A new required method is major (subclasses break). A new optional parameter at the end of a function signature is minor in some languages, major in others.

Four “patches” that break consumers

If you have shipped any of these as a patch, you have shipped a breaking change.

1. Changing an error message. Consumers may match on the string. Rare? Less than you think. Every test that asserts an error message will break. Either keep the old message or bump major.

2. Tightening validation. “We were accepting empty strings; we now reject them” sounds like a fix. To consumers passing an empty string, it is a regression. Either keep accepting and add a new strict mode, or bump major.

3. Removing a deprecated feature. Deprecated does not mean removed; the feature still works. Removing it requires a major bump even if you have shouted about deprecation for a year.

4. Performance regression that changes behavior. A “fix” that adds an extra round trip changes timing. Consumers depending on the old timing (test mocks, race-prone code) break. Document timing changes; if they could break consumers, bump minor at least.

The rule of thumb: if a consumer would have to change anything (a string, a config, a test) to upgrade cleanly, it is not a patch.

The categories of breaking change

These all warrant a major bump:

  • Removing or renaming a public API.
  • Changing the type of a parameter or return.
  • Changing the meaning of an existing parameter (e.g., timeoutMs becomes timeoutSec).
  • Removing support for a runtime, OS, or language version.
  • Changing default values for options.
  • Changing observable behavior (timing, ordering, errors thrown).
  • Removing exported types or interfaces.
  • Changing the package’s module shape (CJS → ESM, default vs named export).

That last one is the trap nobody warns about. Switching from CommonJS to ESM is a major break even though no API “changed,” because every consumer’s import statement breaks.

The deprecation playbook

When you need to change something, the path is add-new → deprecate-old → remove-old. Three releases minimum.

Release N (minor): add the new way.

// Old API stays.
export function fetchUser(id: string) { ... }

// New API alongside.
export function getUser(id: string, opts?: { include?: string[] }) { ... }

Both work. Existing code is fine.

Release N+1 (minor): mark the old way deprecated.

/**
 * @deprecated Use getUser instead. Will be removed in v2.0.
 */
export function fetchUser(id: string) {
  if (process.env.NODE_ENV !== 'production') {
    console.warn('fetchUser is deprecated. Use getUser instead.');
  }
  return getUser(id);
}

The TS @deprecated JSDoc tag puts a strikethrough in IDEs. The runtime warning ensures nobody misses it. Crucially, the function still works.

Release N+M (major, after a long enough window): remove the old way.

// fetchUser is gone.

Consumers who paid attention to the deprecation warning have already migrated. Consumers who did not get a clear error: “fetchUser is not a function.” They can read the changelog and migrate.

The window between deprecation and removal depends on your audience. Six to twelve months is typical for libraries with hundreds of consumers. For internal packages with a known set of consumers, a few weeks is enough; coordinate with them.

Communicating breaking changes

A CHANGELOG.md that follows keep-a-changelog format is the minimum. Group changes:

## [2.0.0] - 2023-03-15

### Breaking
- Removed `fetchUser` (deprecated since 1.4). Use `getUser` instead.
- Changed default timeout from 30s to 5s. Pass `{ timeout: 30_000 }` to restore.

### Added
- `getUser` accepts an `include` option for related entities.

### Fixed
- Connection pool not draining on `close()`.

### Migration
- Replace `fetchUser(id)` with `getUser(id)`.
- Audit code that relied on the 30s default; explicitly pass `timeout` if needed.

The Migration section is the one that matters most. Every breaking change should answer “what does the consumer have to do to upgrade?” If you cannot answer that in two sentences per change, the change is too big.

SemVer in package managers

Both npm and pip use semantic version ranges. Defaults:

"^1.4.0"  // npm: >=1.4.0 <2.0.0, accept any 1.x
"~1.4.0"  // npm: >=1.4.0 <1.5.0, accept patches only
">=1.4"   // pip: similar

The default of ^ (“compatible release”) is correct if you trust the upstream’s SemVer discipline. For a library that ships breaking changes in minors regularly (looking at every popular framework), pin tighter: ~1.4.0 or even an exact version.

Lockfiles (package-lock.json, Pipfile.lock) protect you from upstream surprises between installs. Run npm ci (clean install from lockfile) in CI, not npm install, so a maintainer’s bad publish does not silently change your build.

Pre-1.0 has different rules

Versions below 1.0 (0.x.y) are explicitly “anything can change.” The npm convention treats 0.x as MAJOR, so 0.5.1 to 0.6.0 is a breaking-change range.

Push to 1.0 sooner rather than later. Sitting at 0.x forever is mostly an excuse to keep breaking consumers without bumping major. If your library is being used in production, it is 1.0; act like it.

Conventional commits → automatic versioning

If your commit messages follow conventional commits format, you can automate version bumps:

feat: add getUser()              → minor bump
fix: connection pool drain bug   → patch bump
feat!: remove fetchUser           → major bump (the ! marks breaking)
BREAKING CHANGE: ...              → major bump (in body)

Tools like release-please and semantic-release read your commit history, decide the bump, generate the changelog, and publish, all from CI on merge to main. Adopt this once your release cadence is faster than once a quarter.

A side effect: writing feat!: requires you to think about whether the change is breaking before you commit it. That single habit is worth the tooling.

When NOT to follow SemVer

SemVer is a convention, not a religion. Two cases where strict SemVer hurts:

Application versions. Your customer-facing app does not need SemVer; bump as makes sense (year-based, sprint-based, feature-named). SemVer is for libraries with consumers.

Pre-release / dev / nightly. Use the pre-release suffix: 2.0.0-alpha.4, 2.0.0-rc.1. These do not satisfy ^2.0.0 ranges, which is exactly right.

For everything else (public packages, internal libraries with multiple consumers, anything you npm publish) the discipline pays for itself the first time someone successfully runs npm update and nothing breaks.

The takeaway

SemVer is hard because “what is a breaking change” is harder than the spec implies. The default is to bump bigger, not smaller. The cost of a too-small bump (a downstream user pinning to a specific version forever) is worse than a too-big one (a major bump that nobody minds).

Add the deprecation cycle to your process. Write a migration line in the changelog for every breaking change. Use conventional commits to make versioning automatic and to force you to label breakage at commit time. The next time someone asks “should this be a patch or a minor,” the answer is whichever forces you to write the migration note.


A note from Yojji

The kind of release-engineering discipline that turns “we shipped 1.4.7” from a guessing game into a routine (conventional commits, deprecation cycles, automated release notes) is the kind of long-haul engineering Yojji’s teams build into the libraries and platforms they ship for clients.

Yojji is an international custom software development company founded in 2016, with teams in Europe, the US, and the UK. They specialize in the JavaScript ecosystem, cloud platforms (AWS, Azure, GCP), and full-cycle product engineering, including the release process and versioning practices that decide whether downstream consumers can upgrade safely.