Skip to content

Warnings in the watch mode #8158

Closed
Closed

Description

@alex35mil

I have N warnings in the app. I run rescript watch - it shows all of them and editor integration shows all of them as well. Then I save some file in the editor, and all of the warnings disappear from diagnostics.

This is what I see in the console:

Image

After each consequent save, compiler stops outputting warnings - I guess it's related to the reason they disappear from editor diagnostics?


Also, two kinda unrelated remarks:

  1. Feedback time - from save to update - noticeably increased compared to v11. Is this expected or is it something with my setup?
  2. Seems like if I have 3 packages in a workspace, each package has own namespace in editor integration? With Rewatch, I hoped to get workspace wide diagnostics as it's done in rust-analyzer, but apparently it's not how it works in ReScript LSP?

Activity

  1. nojaf commented on Jan 8, 2026

    @nojaf
    Collaborator

    Could you share some more details, at first glance I don't have these problems.
    N warnings stay visible on edits in watch mode and my editor keeps highlighting them.
    I assume so, but do you have latest rescript npm package? Are you on prerelease editor tooling?
    What is LSP client? Operating system?


    1. I can't say much about that, never used v11.
    2. ReScript LSP will only capture diagnostics for any open files. I suppose this is somewhat historically, unfortunately the LSP server does not have the same context as rescript watch has. Nor do they communicate.
  2. alex35mil commented on Jan 8, 2026

    @alex35mil
    ContributorAuthor

    Sure, I recorded video illustrating the issue - things are quite racy.

    Context:

    • a workspace with 3 packages (2 apps and 1 shared lib)
    • editor: neovim
    • rescript: v12.0.2 (from npm)
    • rescript-language-server: v1.72.0 (installed via mason)
    • os: macOS

    Quick rundown:

    1. I do rescript clean && rescript watch -> all warnings from 1 app appear: 1/9 (1 in the current file, 9 total in the current package)
    2. I save the file -> only 1 warning from the current file remains
    3. I save again -> console reprints only 1 warning from the current file
    4. I open file with no warnings and hit save -> all warnings disappear from both - editor and console
    5. I save again -> console reprints 4 warnings which appear in the editor
    6. I save again -> all warnings are gone
    7. I save again -> console reprints 4->7 warnings which appear in the editor
    8. etc

    FWIW there are around 90 warnings across the workspace - sometimes editor can show all of them, but it's rare.

    CleanShot.2026-01-08.at.11.46.51.mp4
  3. nojaf commented on Jan 8, 2026

    @nojaf
    Collaborator

    Thanks, this is helpful! I can't explain all of it but you see the 9 error of the package after the initial build and I believe rewatch will only show you the warnings of the changed files in subsequent entries.

    The same might be true for the editor warnings, initially these probably come from the .compiler.log file and we read all of them. Subsequently, we only take them from the open files into account and most likely clean up those of non-open files.

    I haven't fact checked this yet, but that is my current train of thought.

  4. alex35mil commented on Jan 8, 2026

    @alex35mil
    ContributorAuthor

    ReScript LSP will only capture diagnostics for any open files

    I guess it's partially explains what's happening. Yesterday, I didn't have any files with warnings opened in the editor, so 3 consecutive saves gave me zero warnings in the editor diagnostics. Today, I had some buffers with warnings opened, and it resulted in 4/7 reported warnings after double-save dance.

  5. dkirchhof commented on Jan 19, 2026

    @dkirchhof
    Contributor

    Is it a monorepo?
    I observed that editing files of a package generated only warnings of this one - not of all packages.

  6. cknitt commented on Jan 23, 2026

    @cknitt
    Member

    Easy to reproduce even without monorepo:

    Let's say I have A.res and A.resi with some unused variable warning in A.res.

    When re-saving A.res, this unused variable warning still shows up.
    When saving a different file B.res, the warning disappears.

  7. nojaf commented on Jan 23, 2026

    @nojaf
    Collaborator

    Is there a link between A and B in your example?

  8. cknitt commented on Jan 23, 2026

    @cknitt
    Member

    Is there a link between A and B in your example?

    No

  9. cristianoc commented on Jan 23, 2026

    @cristianoc
    Collaborator

    do you need both .res and .resi to exist to repro?

  10. cknitt commented on Jan 23, 2026

    @cknitt
    Member

    Actually no, I should have been clearer on that. Just had the .resi because I wanted something unused (unexported) at the top level of the module.

    This works just as well to reproduce without .resi (unused x):

    let f = () => {
      let x = 42
    }
  11. cknitt commented on Oct 19, 2026

    @cknitt
    Member

    This works on current master. With @cknitt's minimal repro (an unused x in A.res), saving an unrelated B.res in rescript watch prints the warning for A.res again after the rebuild, and lib/bs/.compiler.log still contains it, so editor diagnostics keep it as well. See #8216, #8358 and #8408.

    The other points (the language server only reporting diagnostics for open files, and workspace-wide diagnostics) are about the editor tooling. Please open an issue in rescript-vscode if they are still relevant. Closing.

    🤖 Generated with Claude Code

    https://claude.ai/code/session_01Kr4cjoUi2f5VpMvE6wT9bo

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions