Skip to content

Fix double error reporting in eager watch mode. - #16900

Merged
mefyl merged 1 commit into
mainfrom
fix-eager-rpc-double-diagnostics
Nov 10, 2026
Merged

mefyl merged 1 commit into
mainfrom
fix-eager-rpc-double-diagnostics

Conversation

@mefyl

@mefyl mefyl commented Nov 6, 2026 •

Copy link
Copy Markdown
Collaborator

Description

Enrich Memo API to split the installation of an error handler and the run/collection of errors, so that running multiple goals in parallel can still share an error handler and eventually deduplicate them between goals.

Related Issue and Motivation

Fixes #15609.

The root cause is pretty clear: we split the run of goals for several good reasons, but in the process we lost deduplication of errors between goals.

I tried several approaches to make the diff as minimal as possible; the most obvious & sensible one to me was to accumulate the errors in the handler itself. The whole point of it is to centralize the errors of every sub-computation, so deduplicating there seemed like a no brainer, but it ended up being a headache:

  • It changes what version of the exception are reported. I think the current implementation is timing dependent too, so maybe we can just accept it. A proper fix would be to not use a set of exceptions at all levels, but a map that deduplicates but still keeps a deterministic version of the stack. This would however mean comparing stacks whenever errors arise, so maybe too impactful performance-wise.
  • It reports more error: in the current version, some errors are passed to the handler but are absent in the final report. AFAICT it's already a bug, since an early report will happen for an error that actually disappears at the end, but relying on the handler for the final reports makes it worse since the extra error is now also part of the final report.
Scenario to trigger a phantom error in the error handler that is absent from the final report ``` - Run 1: A depends on B. B returns 0 and A returns 1, no errors. - B is invalidated. Both functions have internal state, so on the next computation A no longer needs B, while B now depends on A. - Run 2, building A: a. Memo tries to restore A from the cache. To do that, it first checks A's recorded dependency, B. B is out of date, so Memo recomputes it. b. B's new computation calls A, which is still being restored. That's a cycle, and B fails with Cycle_error. c. Because of the failure, B's error goes through report_and_collect_errors in compute, so the handler receives it. d. Since its dependency changed, A is recomputed. It doesn't call B anymore and returns Ok 0. ```

I don't mind digging into this approach, which I think is fundamentally better, but it's going to take some decision making and some adjacent bug fixing. This fix is a bit more grunty, but it does the deed in a reasonable, if not elegant way, I think.

Checklist

  • Tests added, if applicable.
  • Change log entry added for any user-facing changes.
  • Documentation added for any user-facing changes.

@mefyl mefyl self-assigned this Nov 6, 2026
@mefyl
mefyl force-pushed the fix-eager-rpc-double-diagnostics branch 2 times, most recently from 782abce to 964bb87 Compare November 6, 2026 08:56
@mefyl
mefyl requested a review from Alizter November 6, 2026 09:07
@mefyl
mefyl force-pushed the fix-eager-rpc-double-diagnostics branch from 964bb87 to ed76485 Compare November 6, 2026 10:27

@rgrinberg rgrinberg left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

What's the difference between this PR and the one that Ali made?

@mefyl

mefyl commented Nov 6, 2026

Copy link
Copy Markdown
Collaborator Author

Ali pointed me to this issue and I did not notice he already attempted a fix, sorry; regarding your "I think we need a fix that doesn't raise the errors twice in the first place" feedback, my understanding is that we have two different goals running in parallel, and that they will both fail on the same error, so they need to somehow individually see this error to determine that they failed and why, hence the fact we raise it twice ? If not, I'm not sure how one of the two goals will come to a halt, but I might be missing something.

@rgrinberg

Copy link
Copy Markdown
Member

Here it is for reference: #16491

@rgrinberg

Copy link
Copy Markdown
Member

I think there's two concerns:

  1. Collecting errors per goal. That should definitely "duplicate" errors across the goals.

  2. Reporting errors as diagnostics. This should always be once per memo node, regardless of how many goals we build.

Does your PR add deduplication to 2? That is what I object to.

@rgrinberg

Copy link
Copy Markdown
Member

Do you think you could simplify the api before fixing the bug first? There's a bunch of stuff that we support that we have no need for.

Setting multiple error handler to take one example. This also costing a fiber variable, which slows down everything else for nothing. There's other functions that can perhaps be fused to reduce the api surface.

@mefyl

mefyl commented Nov 6, 2026

Copy link
Copy Markdown
Collaborator Author

This patch definitely does deduplication after-the-fact, which IIUC is what you object to. However my understanding is that it was already relying on deduplication before (via the exception set), and we accidentally broke that by having two sets instead of one, thus deduplication doesn't happen between them.

Maybe it's possible to change the design so that we report everything only once instead of deduplicating, but I need to dig into memo, which I never truly did so far. I'm keen with simplifying the API too (I'll do this in the background however, as this was intended as a quick win side quest).

@rgrinberg rgrinberg left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Alright let's go with this hack for now.

In the future, let's spend some effort on reducing the entropy around this part of the codebase. It is quite hard to understand.

@mefyl

mefyl commented Nov 10, 2026

Copy link
Copy Markdown
Collaborator Author

Indeed, I myself only scratched the surface so far and indeed it's a bit convoluted.

@mefyl
mefyl merged commit 8d48a15 into main Nov 10, 2026
38 checks passed
@mefyl
mefyl deleted the fix-eager-rpc-double-diagnostics branch November 10, 2026 16:20
@Alizter Alizter added this to the 3.26.0 milestone Nov 11, 2026
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.

dune build over RPC reports diagnostics twice

3 participants