Vue Community · Six rules for error handling in Vue that I settled on

2.4K
Vr/vue·posted by bob_chen·3 hours agoExperienceLocked

Six rules for error handling in Vue that I settled on

Some background first. Our setup is Vue plus three downstream services, seven figures of daily requests, peaking around nine in the evening.

On trade-offs, my view is this: if nobody on the team owns this area long-term, do not introduce a second mechanism. With two coexistence you first have to work out which one is even in play when things break, and that costs far more than the performance you saved.

The first thing was to collapse the variables. We were changing config and upgrading the version at the same time, and afterwards nobody could say which change caused what. We rolled back to moving one variable at a time, re-ran three times, and only then did the curve settle. Tedious, but not skippable.

What genuinely surprised me was the tail. The average looked great while P99 jumped by an order of magnitude past some threshold. The cause was not Vue itself but our upstream connection reuse — the load test traffic was too clean and hid the long-tail requests.

We also fixed monitoring along the way: replaced average-based alerts with percentiles and split them per endpoint. False alerts dropped by about seventy percent and the on-call rotation visibly cheered up.

285 comments

285 comments

· first 120 loaded
M
Hhuang_keOP·2 days agoedited

I just read the Vue source — the author actually explains the reasoning in a comment, roughly "so that it degrades into predictable behaviour in extreme cases".

450
Rran_boOP·2 days agoedited

One counter-example: below Vue 7.4 the semantics of that code are different, so do not copy it verbatim. We got burned in staging and rolled back once.

436
WwinterMod·2 days ago

Worth learning from this debugging approach. We went straight at the logs and took a much longer route.

475
Rran_bo·2 days agoedited

I see point 3 differently. The trade-off depends on your read/write ratio: read-heavy with little writing means caching actually widens the inconsistency window.

444
RraseOP·2 days ago

This matches what we see in production. We only hit it past 3k QPS; the earlier load tests showed nothing — the test traffic was too clean, with no long-tail requests.

8
Ttang_hao·2 days ago

Has anyone run a controlled experiment? I did, reducing it to a single variable, and the difference was 4% — within noise. So I suspect the main cause is something else.

53
Bbob_chen·5 hours agoedited

We have run this in production for two years without hitting it. That said, we never reached this scale, so our experience is not really evidence here.

10
Zzhou_yi·2 hours agoedited

Agreeing with the above. One addition: with this option enabled the GC count in your metrics doubles, so adjust the alert threshold at the same time or it will keep firing.

394
Bbob_chen·2 days ago

We have run this in production for two years without hitting it. That said, we never reached this scale, so our experience is not really evidence here.

205
Cchen_devOP·12 minutes ago

Agreeing with the above. One addition: with this option enabled the GC count in your metrics doubles, so adjust the alert threshold at the same time or it will keep firing.

332
Oops_wang·2 days ago

I see point 3 differently. The trade-off depends on your read/write ratio: read-heavy with little writing means caching actually widens the inconsistency window.

310
Aalice_devOP·2 days ago

Agreeing with the above. One addition: with this option enabled the GC count in your metrics doubles, so adjust the alert threshold at the same time or it will keep firing.

496
Hhuang_ke·yesterday

There is actually a simpler fix that needs no architecture change: move this check up to the gateway and the problem disappears. The cost is one extra lookup at the gateway.

129
Sswoole_lee·2 days ago

Can you give a minimal reproduction? I ran it locally for ten minutes and could not reproduce on macOS with the latest version.

305
Sslow_query·2 days ago

I see point 3 differently. The trade-off depends on your read/write ratio: read-heavy with little writing means caching actually widens the inconsistency window.

58
Mmike_xu·just now

Saved. I am reworking this area this week — this saves a lot of wrong turns.

301
Lli_ming·2 days ago

Can you give a minimal reproduction? I ran it locally for ten minutes and could not reproduce on macOS with the latest version.

250
Ttang_hao·2 days agoedited

Saved. I am reworking this area this week — this saves a lot of wrong turns.

223
Aalice_dev·2 days ago

This matches what we see in production. We only hit it past 3k QPS; the earlier load tests showed nothing — the test traffic was too clean, with no long-tail requests.

222
Ddev_zhou·2 days ago

One counter-example: below Vue 7.4 the semantics of that code are different, so do not copy it verbatim. We got burned in staging and rolled back once.

1
Lli_mingOP·2 days ago

Worth learning from this debugging approach. We went straight at the logs and took a much longer route.

475
Lli_mingOP·2 days ago

This is not a Vue problem, it is a usage problem. The docs say this API is not thread-safe and you must lock around it yourself.

443
NnikicOP·5 hours ago

Has anyone run a controlled experiment? I did, reducing it to a single variable, and the difference was 4% — within noise. So I suspect the main cause is something else.

127
Nnikic·2 days ago

I see point 3 differently. The trade-off depends on your read/write ratio: read-heavy with little writing means caching actually widens the inconsistency window.

148
Kkernel_panic·2 days ago

Thanks for sharing real numbers — far more useful than the articles that only cover concepts.

139
Rrase·2 days ago

Agreeing with the above. One addition: with this option enabled the GC count in your metrics doubles, so adjust the alert threshold at the same time or it will keep firing.

115
Sswoole_leeOP·2 days ago

There is actually a simpler fix that needs no architecture change: move this check up to the gateway and the problem disappears. The cost is one extra lookup at the gateway.

46
Mmike_xu·12 minutes ago

I just read the Vue source — the author actually explains the reasoning in a comment, roughly "so that it degrades into predictable behaviour in extreme cases".

459
Rrase·2 days ago

This is not a Vue problem, it is a usage problem. The docs say this API is not thread-safe and you must lock around it yourself.

24
Mmike_xu·3 minutes ago

Has anyone run a controlled experiment? I did, reducing it to a single variable, and the difference was 4% — within noise. So I suspect the main cause is something else.

6
NnikicOP·5 hours ago

Thanks for sharing real numbers — far more useful than the articles that only cover concepts.

88
Ttang_hao·2 days ago

There is actually a simpler fix that needs no architecture change: move this check up to the gateway and the problem disappears. The cost is one extra lookup at the gateway.

72
Llinlin·3 minutes agoeditedLevel 6

Saved. I am reworking this area this week — this saves a lot of wrong turns.

171
Nnikic·3 minutes ago

One counter-example: below Vue 7.4 the semantics of that code are different, so do not copy it verbatim. We got burned in staging and rolled back once.

19
Hhuang_ke·2 days ago

I just read the Vue source — the author actually explains the reasoning in a comment, roughly "so that it degrades into predictable behaviour in extreme cases".

105
Bbob_chen·28 minutes ago

Has anyone run a controlled experiment? I did, reducing it to a single variable, and the difference was 4% — within noise. So I suspect the main cause is something else.

98
Rran_bo·28 minutes ago

Thanks for sharing real numbers — far more useful than the articles that only cover concepts.

96
Ddev_zhouOP·1 hour ago

I see point 3 differently. The trade-off depends on your read/write ratio: read-heavy with little writing means caching actually widens the inconsistency window.

24
Kkernel_panic·2 hours agoedited

Worth learning from this debugging approach. We went straight at the logs and took a much longer route.

519
Zzhu_zong·2 days ago

Has anyone run a controlled experiment? I did, reducing it to a single variable, and the difference was 4% — within noise. So I suspect the main cause is something else.

274
Hhuang_ke·2 days ago

We have run this in production for two years without hitting it. That said, we never reached this scale, so our experience is not really evidence here.

118
Zzhou_yiOPMod·2 days ago

Sharing our numbers, 8 cores 16GB, same scenario:

| Concurrency | P50 | P99 |
|---|---|---|
| 200 | 12ms | 88ms |
| 500 | 31ms | 340ms |

P99 clearly collapses at 500 concurrency, which lines up with your knee point.

18
Lli_mingMod·2 days ago

A question: what changes in a container with a 512Mi memory limit? That is how we run it in production.

73
Nnikic·2 days agoLevel 6

Thanks for sharing real numbers — far more useful than the articles that only cover concepts.

440
Zzhou_yi·2 days agoLevel 6

This matches what we see in production. We only hit it past 3k QPS; the earlier load tests showed nothing — the test traffic was too clean, with no long-tail requests.

4
Bbob_chen·2 days ago

One counter-example: below Vue 7.4 the semantics of that code are different, so do not copy it verbatim. We got burned in staging and rolled back once.

457
Llinlin·5 hours ago

Agreeing with the above. One addition: with this option enabled the GC count in your metrics doubles, so adjust the alert threshold at the same time or it will keep firing.

258
Zzhu_zong·2 days ago

This matches what we see in production. We only hit it past 3k QPS; the earlier load tests showed nothing — the test traffic was too clean, with no long-tail requests.

107
Llinlin·2 days ago

This is not a Vue problem, it is a usage problem. The docs say this API is not thread-safe and you must lock around it yourself.

77
Ddev_zhou·2 days agoedited

A question: what changes in a container with a 512Mi memory limit? That is how we run it in production.

1
Rran_bo·2 days ago

I see point 3 differently. The trade-off depends on your read/write ratio: read-heavy with little writing means caching actually widens the inconsistency window.

393
Zzhou_yi·2 days ago

Worth learning from this debugging approach. We went straight at the logs and took a much longer route.

364
Wwinter·2 days ago

I just read the Vue source — the author actually explains the reasoning in a comment, roughly "so that it degrades into predictable behaviour in extreme cases".

70
Kkernel_panic·2 days ago

Has anyone run a controlled experiment? I did, reducing it to a single variable, and the difference was 4% — within noise. So I suspect the main cause is something else.

1
Aalice_dev·2 days agoedited

Agreeing with the above. One addition: with this option enabled the GC count in your metrics doubles, so adjust the alert threshold at the same time or it will keep firing.

517
Sslow_query·2 days ago

We have run this in production for two years without hitting it. That said, we never reached this scale, so our experience is not really evidence here.

145
Rran_bo·2 days ago

This matches what we see in production. We only hit it past 3k QPS; the earlier load tests showed nothing — the test traffic was too clean, with no long-tail requests.

163
Sswoole_lee·2 days ago

One counter-example: below Vue 7.4 the semantics of that code are different, so do not copy it verbatim. We got burned in staging and rolled back once.

350
Sswoole_lee·2 hours agoedited

This is not a Vue problem, it is a usage problem. The docs say this API is not thread-safe and you must lock around it yourself.

5
Hhuang_ke·28 minutes ago

Can you give a minimal reproduction? I ran it locally for ten minutes and could not reproduce on macOS with the latest version.

9
Lli_ming·2 days ago

We have run this in production for two years without hitting it. That said, we never reached this scale, so our experience is not really evidence here.

165
Bbob_chen·2 days ago

There is actually a simpler fix that needs no architecture change: move this check up to the gateway and the problem disappears. The cost is one extra lookup at the gateway.

93
LlinlinOP·just now

This is not a Vue problem, it is a usage problem. The docs say this API is not thread-safe and you must lock around it yourself.

18
Sslow_queryOP·2 days ago

A question: what changes in a container with a 512Mi memory limit? That is how we run it in production.

17
Rran_bo·12 minutes ago

One counter-example: below Vue 7.4 the semantics of that code are different, so do not copy it verbatim. We got burned in staging and rolled back once.

73
Ddev_zhou·2 hours ago

Sharing our numbers, 8 cores 16GB, same scenario:

| Concurrency | P50 | P99 |
|---|---|---|
| 200 | 12ms | 88ms |
| 500 | 31ms | 340ms |

P99 clearly collapses at 500 concurrency, which lines up with your knee point.

73
Kkernel_panic·2 days ago

This is not a Vue problem, it is a usage problem. The docs say this API is not thread-safe and you must lock around it yourself.

117
Kkernel_panic·28 minutes ago

A question: what changes in a container with a 512Mi memory limit? That is how we run it in production.

2
Llinlin·yesterday

Thanks for sharing real numbers — far more useful than the articles that only cover concepts.

362
Kkernel_panic·2 days ago

Worth learning from this debugging approach. We went straight at the logs and took a much longer route.

409
WwinterOP·2 days ago

Can you give a minimal reproduction? I ran it locally for ten minutes and could not reproduce on macOS with the latest version.

48
Cchen_dev·2 days agoeditedLevel 6

Can you give a minimal reproduction? I ran it locally for ten minutes and could not reproduce on macOS with the latest version.

237
RraseOP·2 days ago

Thanks for sharing real numbers — far more useful than the articles that only cover concepts.

1
Zzhou_yi·3 minutes agoedited

We have run this in production for two years without hitting it. That said, we never reached this scale, so our experience is not really evidence here.

236
Zzhu_zong·2 days agoedited

This matches what we see in production. We only hit it past 3k QPS; the earlier load tests showed nothing — the test traffic was too clean, with no long-tail requests.

52
Nnikic·2 days ago

This matches what we see in production. We only hit it past 3k QPS; the earlier load tests showed nothing — the test traffic was too clean, with no long-tail requests.

510
Kkernel_panicOP·2 days ago

Saved. I am reworking this area this week — this saves a lot of wrong turns.

96
Mmike_xu·2 days ago

This is not a Vue problem, it is a usage problem. The docs say this API is not thread-safe and you must lock around it yourself.

51
Nnikic·2 days ago

Saved. I am reworking this area this week — this saves a lot of wrong turns.

25
Cchen_dev·2 days ago

Sharing our numbers, 8 cores 16GB, same scenario:

| Concurrency | P50 | P99 |
|---|---|---|
| 200 | 12ms | 88ms |
| 500 | 31ms | 340ms |

P99 clearly collapses at 500 concurrency, which lines up with your knee point.

1
Kkernel_panicOP·12 minutes ago

This matches what we see in production. We only hit it past 3k QPS; the earlier load tests showed nothing — the test traffic was too clean, with no long-tail requests.

8
Aalice_dev·2 days ago

There is actually a simpler fix that needs no architecture change: move this check up to the gateway and the problem disappears. The cost is one extra lookup at the gateway.

466
Oops_wang·yesterday

Worth learning from this debugging approach. We went straight at the logs and took a much longer route.

335
Cchen_dev·2 days ago

Saved. I am reworking this area this week — this saves a lot of wrong turns.

114
Aalice_dev·2 days ago

Sharing our numbers, 8 cores 16GB, same scenario:

| Concurrency | P50 | P99 |
|---|---|---|
| 200 | 12ms | 88ms |
| 500 | 31ms | 340ms |

P99 clearly collapses at 500 concurrency, which lines up with your knee point.

47
Zzhu_zong·2 days ago

Sharing our numbers, 8 cores 16GB, same scenario:

| Concurrency | P50 | P99 |
|---|---|---|
| 200 | 12ms | 88ms |
| 500 | 31ms | 340ms |

P99 clearly collapses at 500 concurrency, which lines up with your knee point.

32
Wwinter·yesterday

Has anyone run a controlled experiment? I did, reducing it to a single variable, and the difference was 4% — within noise. So I suspect the main cause is something else.

151
Ttang_hao·2 days agoedited

Thanks for sharing real numbers — far more useful than the articles that only cover concepts.

14
Oops_wang·28 minutes ago

I see point 3 differently. The trade-off depends on your read/write ratio: read-heavy with little writing means caching actually widens the inconsistency window.

242
Llinlin·2 days agoLevel 6

One counter-example: below Vue 7.4 the semantics of that code are different, so do not copy it verbatim. We got burned in staging and rolled back once.

202
Kkernel_panic·2 days ago

Worth learning from this debugging approach. We went straight at the logs and took a much longer route.

11
Zzhou_yi·2 days agoeditedLevel 6

I just read the Vue source — the author actually explains the reasoning in a comment, roughly "so that it degrades into predictable behaviour in extreme cases".

400
Aalice_dev·2 days ago

I just read the Vue source — the author actually explains the reasoning in a comment, roughly "so that it degrades into predictable behaviour in extreme cases".

64
Nnikic·3 minutes ago

We have run this in production for two years without hitting it. That said, we never reached this scale, so our experience is not really evidence here.

123
Hhuang_ke·2 days ago

There is actually a simpler fix that needs no architecture change: move this check up to the gateway and the problem disappears. The cost is one extra lookup at the gateway.

463
Mmike_xu·2 days ago

I just read the Vue source — the author actually explains the reasoning in a comment, roughly "so that it degrades into predictable behaviour in extreme cases".

187
Rrase·2 days ago

Has anyone run a controlled experiment? I did, reducing it to a single variable, and the difference was 4% — within noise. So I suspect the main cause is something else.

51
Kkite·2 days ago

Can you give a minimal reproduction? I ran it locally for ten minutes and could not reproduce on macOS with the latest version.

33
Zzhu_zong·2 days ago

I just read the Vue source — the author actually explains the reasoning in a comment, roughly "so that it degrades into predictable behaviour in extreme cases".

33
Nnikic·12 minutes ago

This is not a Vue problem, it is a usage problem. The docs say this API is not thread-safe and you must lock around it yourself.

28
Rrase·2 days ago

Can you give a minimal reproduction? I ran it locally for ten minutes and could not reproduce on macOS with the latest version.

14
Ttang_hao·2 days ago

Sharing our numbers, 8 cores 16GB, same scenario:

| Concurrency | P50 | P99 |
|---|---|---|
| 200 | 12ms | 88ms |
| 500 | 31ms | 340ms |

P99 clearly collapses at 500 concurrency, which lines up with your knee point.

157
Kkite·2 days ago

Sharing our numbers, 8 cores 16GB, same scenario:

| Concurrency | P50 | P99 |
|---|---|---|
| 200 | 12ms | 88ms |
| 500 | 31ms | 340ms |

P99 clearly collapses at 500 concurrency, which lines up with your knee point.

69
Ddev_zhou·2 days ago

Agreeing with the above. One addition: with this option enabled the GC count in your metrics doubles, so adjust the alert threshold at the same time or it will keep firing.

1
Mmike_xu·1 hour ago

We have run this in production for two years without hitting it. That said, we never reached this scale, so our experience is not really evidence here.

13
Kkernel_panic·12 minutes ago

A question: what changes in a container with a 512Mi memory limit? That is how we run it in production.

116
Kkernel_panic·2 days ago

A question: what changes in a container with a 512Mi memory limit? That is how we run it in production.

315
Rrase·2 days ago

A question: what changes in a container with a 512Mi memory limit? That is how we run it in production.

100
Ttang_hao·2 days ago

Sharing our numbers, 8 cores 16GB, same scenario:

| Concurrency | P50 | P99 |
|---|---|---|
| 200 | 12ms | 88ms |
| 500 | 31ms | 340ms |

P99 clearly collapses at 500 concurrency, which lines up with your knee point.

8
Sslow_query·12 minutes agoedited

I just read the Vue source — the author actually explains the reasoning in a comment, roughly "so that it degrades into predictable behaviour in extreme cases".

6
Oops_wang·2 days ago

One counter-example: below Vue 7.4 the semantics of that code are different, so do not copy it verbatim. We got burned in staging and rolled back once.

342
Sslow_query·2 days ago

Can you give a minimal reproduction? I ran it locally for ten minutes and could not reproduce on macOS with the latest version.

6
Rran_bo·2 days ago

I see point 3 differently. The trade-off depends on your read/write ratio: read-heavy with little writing means caching actually widens the inconsistency window.

6
Cchen_dev·yesterday

Saved. I am reworking this area this week — this saves a lot of wrong turns.

4
Sswoole_lee·2 days ago

Saved. I am reworking this area this week — this saves a lot of wrong turns.

273
Sslow_query·5 hours ago

A question: what changes in a container with a 512Mi memory limit? That is how we run it in production.

206
Wwinter·2 days ago

There is actually a simpler fix that needs no architecture change: move this check up to the gateway and the problem disappears. The cost is one extra lookup at the gateway.

224
Hhuang_ke·2 days ago

Worth learning from this debugging approach. We went straight at the logs and took a much longer route.

216
Zzhou_yi·5 hours ago

There is actually a simpler fix that needs no architecture change: move this check up to the gateway and the problem disappears. The cost is one extra lookup at the gateway.

4
Zzhu_zong·2 days ago

Agreeing with the above. One addition: with this option enabled the GC count in your metrics doubles, so adjust the alert threshold at the same time or it will keep firing.

250

This is the post detail page /en/c/vue/post/p2. Posts and comments are generated deterministically from a seeded PRNG, so the same post always renders the same content and the link can be shared, reloaded and indexed. In production this page reads MySQL for the post, Redis for hot-post caching, and fetches the whole comment tree in a single query on the path column.

See the database schema →