Skip to content

Conversation

@Shougo
Copy link
Contributor

@Shougo Shougo commented Sep 23, 2025

Use loop to fix import error like this.

[denops] Update cache of the following files. Call `denops#cache#update(#{reload: v:true})` to forcibly update.
[denops] /home/shougo/work/denops.vim/denops/@denops-private/mod.ts
[denops] /home/shougo/work/dpp.vim/denops/dpp/app.ts
[denops] /home/shougo/.cache/dpp/repos/github.com/lambdalisue/kensaku.vim/denops/kensaku/main.ts
[denops] /home/shougo/work/ddc.vim/denops/ddc/app.ts
[denops] /home/shougo/work/ddt.vim/denops/ddt/app.ts
[denops] /home/shougo/work/ddu.vim/denops/ddu/app.ts
[denops] Download https://jsr.io/@std/json/meta.json
[denops] Download https://jsr.io/@std/json/1.0.2_meta.json
[denops] Download https://jsr.io/@lambdalisue/workerio/4.0.1/types.ts
[denops] Download https://jsr.io/@std/json/1.0.2/types.ts
[denops] error: Relative import path "@core/unknownutil/is" not prefixed with / or ./ or ../ and not in import map from "file:///home/shougo/work/dpp.vim/denops/dpp/app.ts"
[denops]   hint: If you want to use a JSR or npm package, try running `deno add jsr:@core/unknownutil/is` or `deno add npm:@core/unknownutil/is`
[denops]     at file:///home/shougo/work/dpp.vim/denops/dpp/app.ts:21:20
[denops] Deno cache is updated.

Summary by CodeRabbit

  • Refactor

    • Caching now processes each entry individually instead of one batch; each entry is handled and awaited separately.
    • Per-entry reload option applied per file; progress messages shown per entry.
  • Bug Fixes

    • Added per-run summary reporting failures and listing failed entries when any occur.
    • Improved per-entry error reporting and clearer final success/failure notification.

@coderabbitai
Copy link

coderabbitai bot commented Sep 23, 2025

Walkthrough

Replaces the batched deno cache invocation with a per-entry loop that builds args (optional --reload), starts and awaits a Denops job per entry, collects failures, updates on_exit signature, and prints a final success/failure summary listing failed entries.

Changes

Cohort / File(s) Summary
Per-entry caching & failure collection
autoload/denops/cache.vim
Replace single aggregated deno cache call with a loop over [s:mod] and plugin entry files; construct l:args per entry (add --reload when requested), start and wait a Denops job per entry, collect l:failures, change s:on_exit signature to s:on_exit(failures, entryfile, job, status, event), and print per-run success/failure summary listing failed entries.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  actor User
  participant Vim as denops#cache#update()
  participant Denops as denops job runner
  participant Deno as deno

  User->>Vim: call denops#cache#update(reload?)
  Vim->>Vim: gather [s:mod] + plugin entry files
  loop for each entryfile
    Vim->>Vim: build l:args (add --reload if requested)
    Vim->>Denops: start job: deno cache <entryfile> (env: NO_COLOR,DENO_NO_PROMPT)
    Denops->>Deno: execute deno cache <entryfile>
    Deno-->>Denops: exit status
    Denops-->>Vim: s:on_exit(failures, entryfile, job, status, event)
    Vim->>Vim: record failure if status != 0
  end
  alt any failures
    Vim-->>User: echo warning with failed count and list of entries
  else all succeeded
    Vim-->>User: echo final success message
  end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

  • Review s:on_exit signature change and ensure callers/closures match.
  • Verify failure collection and reported entry paths are correct and escaped.
  • Confirm per-entry job lifecycle and environment isolation behave as intended.

Possibly related PRs

Poem

Hop, one file at a time I go,
nibbling bytes where soft winds blow.
Deno hums, each job a bite,
I mark the ones that didn't bite.
Thump-thump, report — the patch is right. 🥕🐇

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The title "Fix denops#cache#update()" directly identifies the primary change in the pull request—modifications to the denops#cache#update() function to resolve an import error. The title is clear, specific, and properly identifies what was changed without using vague terminology. While the title does not detail the specific implementation change (switching from batch to per-entry processing), it appropriately communicates the main objective that a fix was applied to this function, which is sufficient for scanning commit history and understanding the primary change at a glance.
✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix_deno_cache_update

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@codecov
Copy link

codecov bot commented Sep 23, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.07%. Comparing base (5cfca39) to head (60709f4).

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #461   +/-   ##
=======================================
  Coverage   97.07%   97.07%           
=======================================
  Files          11       11           
  Lines         924      924           
  Branches      146      146           
=======================================
  Hits          897      897           
  Misses         24       24           
  Partials        3        3           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a278b83 and b648ed2.

📒 Files selected for processing (1)
  • autoload/denops/cache.vim (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (5)
  • GitHub Check: test (macos-latest, 2.x, v9.1.1646, v0.11.3)
  • GitHub Check: test (ubuntu-latest, 2.x, v9.1.1646, v0.11.3)
  • GitHub Check: test (macos-latest, 2.3.0, v9.1.1646, v0.11.3)
  • GitHub Check: test (windows-latest, 2.x, v9.1.1646, v0.11.3)
  • GitHub Check: test (windows-latest, 2.3.0, v9.1.1646, v0.11.3)
🔇 Additional comments (5)
autoload/denops/cache.vim (5)

9-11: Message on non-reload path — LGTM.

Helpful guidance for forcing reload. No change needed.


13-15: Per‑file caching loop — LGTM.

Sequentializing isolates failures and matches the PR goal.


16-21: Argument construction — LGTM.

Simple and clear; per‑file --reload wiring is correct.


32-32: No-op change.

Nothing to flag here.


22-30: Handle per-file failures, respect each plugin’s cwd, and use string env values.

Failures/timeouts currently report success and per-plugin deno.json import-maps can be skipped because cwd isn't set; env values should be strings for job portability.

  • Initialize: let l:failures = [] before the loop.
  • In the loop when starting the job: add cwd: fnamemodify(l:entryfile, ':h') and make env values strings (e.g. '1').
  • Capture wait result: let l:done = denops#_internal#wait#for(60 * 1000, { -> s:job is# v:null }, 100).
  • If !l:done || s:last_status != 0 then call add(l:failures, l:entryfile).
  • At top-level: let s:last_status = 0 and update s:on_exit(job, status, event) to set s:last_status = a:status and let s:job = v:null.

This prevents false “success” and ensures each cache runs from the plugin directory so per‑plugin import‑maps are respected.

@lambdalisue
Copy link
Member

lambdalisue commented Oct 26, 2025

I don't remember but do we still need this?

@Shougo
Copy link
Contributor Author

Shougo commented Oct 26, 2025

The error still exists. I will fix the conflict.

@Shougo Shougo force-pushed the fix_deno_cache_update branch from b648ed2 to 74266d8 Compare October 26, 2025 10:36
@Shougo
Copy link
Contributor Author

Shougo commented Oct 26, 2025

Fixed.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

♻️ Duplicate comments (1)
autoload/denops/cache.vim (1)

33-33: Report failures instead of unconditional success.

This was already flagged in the previous review. Once you add failure tracking in the loop above, update this line to report errors when files fail to cache.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between b648ed2 and 74266d8.

📒 Files selected for processing (1)
  • autoload/denops/cache.vim (1 hunks)

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
autoload/denops/cache.vim (1)

14-32: Consider handling job timeouts explicitly.

If a job doesn't complete within 60 seconds, s:job won't be set to v:null by the on_exit callback. When the next iteration starts a new job, the timed-out job reference is overwritten. If the timed-out job eventually exits, its on_exit callback could interfere with a subsequently started job's state.

Consider adding explicit cleanup after the wait:

     call denops#_internal#wait#for(60 * 1000, { -> s:job is# v:null }, 100)
+    if s:job isnot# v:null
+      " Job timed out - add to failures and clean up
+      call add(l:failures, l:entryfile)
+      " Optionally: call denops#_internal#job#stop(s:job) if available
+      let s:job = v:null
+    endif
   endfor
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 74266d8 and 60709f4.

📒 Files selected for processing (1)
  • autoload/denops/cache.vim (2 hunks)
🔇 Additional comments (2)
autoload/denops/cache.vim (2)

8-8: Previous review feedback successfully addressed.

The failure tracking initialization and error reporting implementation correctly addresses the previous review comments. The code now collects failures during the loop and provides a clear summary with the count and list of failed entries.

Also applies to: 34-43


54-59: LGTM!

The updated callback signature with partial application correctly tracks failures when jobs exit with non-zero status. The implementation cleanly integrates with the failure collection mechanism.

Copy link
Member

@lambdalisue lambdalisue left a comment

Choose a reason for hiding this comment

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

I don't understand how this fixes the issue — it looks like it just skips the failure instead. Was that intentional?

@Shougo
Copy link
Contributor Author

Shougo commented Oct 27, 2025

The key point of this change is not to ignore errors. By reloading modules one at a time, it avoids producing unnecessary errors.

Note: I'm not ignoring errors, just to be clear.

@lambdalisue
Copy link
Member

The key point of this change is not to ignore errors. By reloading modules one at a time, it avoids producing unnecessary errors.

Then I don’t understand why “reloading modules one at a time” solves the issue. Do you have any perspective on that? I’m just afraid that this “fix” might unintentionally conceal the actual bugs or behaviors of Deno.

@Shougo
Copy link
Contributor Author

Shougo commented Oct 27, 2025

I'm not very familiar with the details here either, but it's clear that reloading all the plugins at once causes them not to work properly. Each denops plugin is loading plugins independently via deno.jsonc, so they might be conflicting with each other.

@lambdalisue
Copy link
Member

As long as my understanding, this PR won't fix the issue while https://github.com/lambdalisue/deno-import-map-importer does nothing on deno cache. However, you said this PR fixes the issue so I want to know the mechanisms to accept this PR.

@Shougo
Copy link
Contributor Author

Shougo commented Oct 27, 2025

As long as my understanding, this PR won't fix the issue while https://github.com/lambdalisue/deno-import-map-importer does nothing on deno cache. However, you said this PR fixes the issue so I want to know the mechanisms to accept this PR.

The error occurs in a plugin that uses deno-import-map-importer, so I think they're related, but I don't know the exact reason myself.

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.

3 participants